Threads Scheduler MCP
A local-first MCP server for reading, planning, scheduling, and publishing Meta Threads posts, with OAuth and Keychain integration.
README
Threads Scheduler MCP
A free, local-first MCP server for reading, planning, scheduling, and publishing Meta Threads posts from Codex Desktop.
The current MVP implements:
- SQLite persistence and migrations
- local Meta Threads OAuth with state validation
- short-lived to long-lived access-token exchange
- account profile verification and registration
- macOS Keychain token retrieval
- a typed Threads API adapter
threads_list_poststhreads_get_post- text draft creation, editing, and exact previews
- confirmation-gated immediate publishing
- confirmation-gated scheduling, rescheduling, and cancellation
- durable idempotency records and immutable scheduled snapshots
- local and Cloudflare background publishing workers
- a private hosted dashboard protected by a signed OAuth session
- structured, redacted errors
Remaining hardening and installation work is tracked in TASKS.md.
Requirements
- macOS
- Node.js 22 LTS or newer
- pnpm 10
- Codex Desktop
- a Meta developer app with Threads API access
Install
pnpm install
cp .env.example .env
pnpm build
Set THREADS_GRAPH_API_VERSION to the currently supported version shown in Meta's official Threads API documentation. Do not assume the example value is current.
Configure Meta OAuth
In the Meta developer dashboard:
-
Create an app with the Threads use case.
-
Add your Threads account as an app tester while the app is in development mode.
-
Add this exact valid OAuth redirect URI:
http://127.0.0.1:8787/oauth/callback
4. Enable the permissions required by the MVP:
```text
threads_basic
threads_content_publish
- Put the Threads app ID and Threads app secret in your local
.env.
The redirect URI in .env and Meta must match exactly, including scheme, host, port, path, and trailing slash behavior.
Connect the account:
pnpm build
pnpm connect
Open the printed authorization URL, approve access, and return to the terminal. The local callback listens for up to five minutes. It validates the OAuth state, exchanges the code, upgrades the short-lived token to a long-lived token, verifies the profile identity, stores the token in macOS Keychain, and registers the account in SQLite.
The command never prints the app secret or access token.
Development
pnpm dev
The process speaks MCP JSON-RPC over stdout. Application logs are written to stderr so they cannot corrupt the MCP transport.
Local dashboard
Build and start the private dashboard:
pnpm build
pnpm dashboard
Open http://127.0.0.1:7777. The dashboard reads the same local SQLite database and Keychain-backed Threads connection as the MCP server. It shows connection status, recent posts, drafts, scheduled posts, and publication counts.
The server binds to the loopback interface by default and is not accessible from other computers. Override DASHBOARD_HOST or DASHBOARD_PORT only when needed; keep the host on a loopback address.
To deliver local schedules while Codex Desktop is closed, keep the worker running:
pnpm build
pnpm worker
The Mac must remain awake and online. A launchd installer is still tracked as
follow-up work; the hosted Cloudflare version does not depend on the Mac.
Cloudflare deployment
The repository also includes a Cloudflare Worker for the hosted dashboard, Meta OAuth, deauthorization, data deletion, D1 persistence, and hosted Threads reads.
See Cloudflare deployment for the exact D1, secret, build, and callback configuration.
Run all checks:
pnpm check
Account connection
The server starts normally without an account, but read tools return AUTH_REQUIRED until pnpm connect completes successfully.
Do not place access tokens in .env, source files, SQLite, shell history, or Codex configuration. The OAuth connection flow stores tokens in macOS Keychain.
Codex Desktop configuration
The deployed Worker exposes an authenticated Streamable HTTP MCP endpoint:
https://treads-mcp.elvischukwuemekaekanem.workers.dev/mcp
Register it with a bearer token stored in the Codex process environment:
codex mcp add threads_scheduler \
--url https://treads-mcp.elvischukwuemekaekanem.workers.dev/mcp \
--bearer-token-env-var THREADS_MCP_TOKEN
The Cloudflare MCP_BEARER_TOKEN secret and local
THREADS_MCP_TOKEN value must match. Restart Codex Desktop after changing MCP
configuration.
For local-only development, build and add a stdio MCP entry using absolute paths:
[mcp_servers.threads_scheduler]
command = "/absolute/path/to/node"
args = ["/absolute/path/to/Threads MCP/dist/src/index.js"]
[mcp_servers.threads_scheduler.env]
THREADS_DB_PATH = "/absolute/path/to/application-data/threads.sqlite"
THREADS_GRAPH_API_VERSION = "REPLACE_WITH_CURRENT_VERSION"
DEFAULT_TIMEZONE = "Asia/Kuala_Lumpur"
Do not add THREADS_APP_SECRET or access tokens to this configuration.
The exact Codex Desktop configuration location and syntax can evolve; verify it against the current Codex documentation during installation.
Available tools
threads_list_posts
Read the connected account's recent posts.
{
"limit": 20,
"cursor": "optional-pagination-cursor",
"since": "2026-07-01T00:00:00+08:00",
"until": "2026-07-31T23:59:59+08:00"
}
account_id is optional when exactly one active account is connected.
threads_get_post
Read one post by ID.
{
"post_id": "THREADS_POST_ID",
"account_id": "optional-local-account-id"
}
These tools are read-only.
Draft and publishing tools
threads_create_draftthreads_update_draftthreads_preview_draftthreads_publish_nowthreads_publish_status
Immediate publishing requires confirmed: true and a unique
idempotency_key.
Scheduling tools
threads_schedulethreads_list_scheduledthreads_reschedulethreads_cancel_scheduled
Schedule creation requires an ISO 8601 time with an explicit UTC offset, an
IANA time zone, confirmed: true, and a unique idempotency_key. The scheduler
stores an immutable copy of the approved text, so later edits cannot silently
change a scheduled post.
Local data and secrets
- SQLite stores account metadata, drafts, schedules, publications, and audit events.
- Access tokens belong in the macOS Keychain service named
threads-scheduler-mcp. .env, databases, logs, and generated launch-agent files are ignored by Git.- SQLite uses WAL mode, foreign keys, and a busy timeout.
Project structure
src/
config.ts
index.ts
db/
domain/
lib/
mcp/
providers/threads/
services/
worker/
tests/
See AGENTS.md for engineering rules and TASKS.md for the complete deployment checklist.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。