Threads
一個開源的 MCP (Model Context Protocol) server,將 Threads API 包裝成 6 個 AI 可呼叫的工具,用於社群媒體內容管理。
- 維護者
- asgard-ai-platform
- 授權
- MIT
- 地區
- global
簡介
一個開源的 MCP (Model Context Protocol) server,將 Threads API 包裝成 6 個 AI 可呼叫的工具,用於社群媒體內容管理。
支援 Claude Code、Claude Desktop 與任何相容 MCP 的 AI client。讓 AI agent 透過自然語言讀取個人檔案、列出貼文、回覆與提及、查詢發文額度,以及發佈文字貼文。
聲明:這個專案需要有效的 Threads account token。僅供個人使用與內部工具用途。
Usage Examples
User: 幫我看一下最近被提及的 Threads 貼文
Claude 會根據語意呼叫 threads_mentions_list,帶入推測出的參數:
{
"fields": ["id", "text", "timestamp"],
"limit": 10
}
Claude: 最近有 10 則 mentions,我幫你整理成可讀摘要:...
需求
- Python 3.14+
- uv
THREADS_TOKEN
Install
uv sync
如何取得 Token
這個專案不會在執行時替你登入或交換 token。你需要先透過外部流程取得 Threads 的 account token,然後把它設定到 THREADS_TOKEN。
在本機開發時,你可以把 token 放進 shell 環境變數,或寫到 .env 後再透過 uv 執行指令。
Usage
作為 MCP Server(Claude Desktop / Claude Code)
專案內附有 .mcp.json,可直接給本機的 MCP host 使用:
{
"mcpServers": {
"threads": {
"command": "uv",
"args": ["run", "mcp-threads", "serve"],
"cwd": "${PWD}",
"env": {
"THREADS_TOKEN": "XXXXX"
}
}
}
}
目前會暴露六個 tool:
threads_profile_me — 讀取已驗證的 profile
回傳目前登入的 Threads 使用者資料。
threads_posts_list — 列出自己的貼文
回傳已驗證使用者建立的 Threads 貼文。
threads_publishing_limit — 讀取發文額度
回傳已驗證使用者的 quota usage 與 config。
threads_mentions_list — 列出提及你的貼文
回傳提及已驗證使用者的公開 Threads 貼文。
threads_replies_list — 列出自己的回覆
回傳已驗證使用者建立的回覆。
threads_post_text — 建立並發佈文字貼文
建立文字貼文或回覆,並立即發佈。
直接執行 CLI(除錯用)
# 顯示 CLI 說明
uv run mcp-threads --help
# 啟動 MCP stdio server
uv run mcp-threads serve
開發與測試
# 同步相依套件
uv sync
# 讀取自己的 profile
uv run mcp-threads me
# 列出自己的貼文
uv run mcp-threads posts --limit 10
# 讀取發文額度
uv run mcp-threads publishing-limit
# 讀取 mentions
uv run mcp-threads mentions --limit 10
# 讀取 replies
uv run mcp-threads replies --limit 10
# 發佈文字貼文
uv run mcp-threads post-text "Hello from Threads API"
備註
- 這個專案只使用
THREADS_TOKEN,不需要其他 auth 環境變數。 - 需要 user id 時,程式會透過
/me自動取得THREADS_USER_ID。 - Threads 文字貼文上限是 500 字元。
- 貼文發佈分成兩步:先建立 container,再 publish。
serve會啟動 MCP stdio server;mcp-threads-server保留作為相容別名。