MCP server by poisonstefani-dev
Threads MCP Server
threads-mcp is a stdio MCP server for the official Threads API. It is designed to stay close to the published Meta Threads documentation while exposing a practical MCP tool surface for auth, publishing, reading, moderation, insights, discovery, locations, and setup diagnostics.
The current build is intentionally limited to officially documented Threads capabilities and the official Postman collection. It does not rely on undocumented fallback endpoints or convenience wrappers that would be difficult to maintain in a public package.
Highlights
- Official Threads API scope only
- MCP tools for auth, profile lookup, publishing, reading, replies, insights, search, locations, oEmbed, and diagnostics
- Publish inputs modeled in camelCase and serialized internally to the snake_case parameters expected by Threads
- Multi-step carousel publishing support
- Shared client layer for retries, polling, pagination, and normalized Meta API errors
Quick start
- Install dependencies:
npm install
- Build the server:
npm run build
-
Create your local environment file and set at least
THREADS_ACCESS_TOKEN. -
If you still need a token, run the local OAuth helper:
npm run auth:token
- Start the server:
node dist/index.js
- Call
validate_setupbefore using publish or moderation flows against a real account.
Tool catalog
Auth
exchange_code_for_tokenget_long_lived_access_tokenrefresh_access_tokenget_app_access_token
Profiles and discovery
get_meget_profileget_profile_threads
Publishing and lifecycle
get_publishing_limitcreate_thread_containerpublish_threadcreate_and_publish_threadrepost_threaddelete_thread
Reading and replies
get_threadsget_threadget_repliesget_thread_conversationget_pending_repliesmanage_replymanage_pending_reply
Insights, search, and embeds
get_user_insightsget_thread_insightssearch_threadsget_mentionsget_oembed
Locations and diagnostics
search_locationsget_locationvalidate_setup
Explicitly out of scope for v1
- Webhooks
- Embedded OAuth callback hosting
- Any undocumented fallback endpoints or convenience features that are not covered by the official docs or official Postman collection
Architecture
The server is split into a few clear layers:
src/index.tsbootstraps the MCP stdio transport.src/threads/client.tsowns authenticated HTTP calls, retries, pagination, polling, and normalized Meta API errors.src/tools/contains one module per tool family plus shared schemas.
The publish input model is exposed as a single public discriminated union covering text, image, video, carousel, and reply.
Prerequisites
You need all of the following before the server can make live API calls:
- A Meta app configured for the Threads use case
- A Threads user access token for the account you want to operate on
- Advanced access and app review where your integration requires it
- Node.js 20+ on the machine where the server will run
Environment variables
Required for most user-token tools:
THREADS_ACCESS_TOKEN
Optional:
THREADS_APP_IDTHREADS_APP_SECRETTHREADS_REDIRECT_URITHREADS_API_BASE_URLTHREADS_USER_IDTHREADS_MAX_RETRIESTHREADS_RETRY_BASE_DELAY_MSTHREADS_TIMEOUT_MSTHREADS_PUBLISH_STATUS_TIMEOUT_MSTHREADS_PUBLISH_STATUS_POLL_INTERVAL_MS
Copy .env.example and set at least the access token. THREADS_APP_ID and THREADS_APP_SECRET are also needed for the auth helper tools and for get_oembed when you do not pass an explicit app access token.
Where to get THREADS_APP_ID
- Open your app in the Meta for Developers dashboard: https://developers.facebook.com/apps/
- Open the app created with the Threads use case
- Go to
Use Cases->Threads->Customize->Settings - Copy the Threads App ID from that page
- Use that value as
THREADS_APP_ID
Important:
- Do not use the general Meta app ID from the top-level app dashboard or settings page
- Use the Threads use-case-specific credentials from
Use Cases->Threads->Customize->Settings
THREADS_APP_SECRET comes from the same Threads use-case settings page. Keep it private.
Token helper script
The repository includes a local OAuth helper that follows the Meta Threads access-token flow:
- Open the Threads authorization window
- Receive the authorization code on a local callback URL
- Exchange it for a short-lived token
- Exchange that for a long-lived token
- Save the result into
.envasTHREADS_ACCESS_TOKEN
Setup:
- Add your Meta app credentials to
.env - Make sure your app's valid OAuth redirect URI matches
THREADS_REDIRECT_URI
Run:
npm run auth:token
Optional flags:
--redirect-uri http://127.0.0.1:8788/callback--env-file .env.local--no-open
Required scopes by tool family
threads_basicUsed byget_me,get_profile,get_threads,get_thread, and baseline setup validation.threads_content_publishUsed byget_publishing_limit,create_thread_container,publish_thread, andcreate_and_publish_thread.threads_read_repliesUsed byget_repliesand safe reply-read probes invalidate_setup.threads_manage_repliesUsed bymanage_reply.threads_manage_insightsUsed byget_user_insightsandget_thread_insights.threads_keyword_searchUsed bysearch_threads.threads_profile_discoveryUsed byget_profileandget_profile_threadsfor public account discovery scenarios.threads_location_taggingUsed bysearch_locations,get_location, and publish flows that setlocationId.threads_deleteUsed bydelete_thread.
validate_setup performs safe probes to infer access for threads_basic, threads_content_publish, threads_read_replies, threads_manage_insights, threads_keyword_search, threads_profile_discovery, and threads_location_tagging. It deliberately does not perform destructive probes for threads_manage_replies or threads_delete, so those scopes are not actively validated by setup.
Publish behavior
The server models official container options in camelCase and serializes them internally to the snake_case parameters expected by the Threads API.
Supported inputs include:
- Common fields:
text,replyControl,replyToId,quotePostId,topicTag,locationId,textEntities,allowlistedCountryCodes - Text-only fields:
linkAttachment,pollAttachment,textAttachment,gifAttachment,enableReplyApprovals,autoPublishText,isGhostPost - Image or video fields:
imageUrl,videoUrl,altText,isSpoilerMedia - Carousel items: validated arrays of image or video items with per-item media fields
Carousel publishing follows the official multi-step flow:
- Create one item container per image or video with
is_carousel_item=true - Create the parent carousel container with
children=[...] - Publish the parent container
Coverage notes
The repository currently covers these official Threads API families:
- Authorization helpers
- Publishing, including quote posts, repost publishing, and container status polling
- User profile lookup and public profile post retrieval
- Threads media retrieval
- Reply retrieval, flattened conversations, pending replies, hide and unhide, and approve and ignore flows
- User and post insights
- Keyword search and mentions
- Location search and location retrieval
- oEmbed
- Setup diagnostics
Local MCP config example
Example Claude Desktop style config:
{
"mcpServers": {
"threads": {
"command": "node",
"args": ["/absolute/path/to/threads-mcp/dist/index.js"],
"env": {
"THREADS_ACCESS_TOKEN": "thdt_your_user_access_token",
"THREADS_APP_ID": "optional_app_id",
"THREADS_APP_SECRET": "optional_app_secret"
}
}
}
}
If you later publish this package as a CLI, the command can become threads-mcp.
Publishing
The package metadata is already configured for npm publication as a public package:
- package name:
threads-mcp - current version:
0.0.0 - CLI entrypoint:
threads-mcp - publish access:
public
Before publishing, run:
npm run build
npm test
npm publish --access public
prepublishOnly is configured to run the build and test steps automatically during npm publish.
Development
Install dependencies once Node.js is available:
npm install
npm run build
npm test
Suggested manual checks:
- Run
npm run buildto verify TypeScript compilation. - Run
npm testto execute the schema, client, and tool registration tests. - Start the server with
node dist/index.js. - Call
validate_setupfirst with a real token. - Exercise
create_thread_containerandpublish_threadagainst a test Threads account.
Known limitations
- Transport is stdio only in v1
- There is no embedded OAuth callback server; token exchange helpers are exposed as MCP tools instead
validate_setupcannot safely verifythreads_manage_replieswithout performing a state-changing moderation callvalidate_setupalso does not perform a state-changing delete probecreate_and_publish_threadintentionally rejectsautoPublishText=truebecause that flag conflicts with the tool's explicit two-step contract- Reply publishing is modeled as a dedicated
replyvariant backed by the officialreply_to_idparameter and currently targets text replies in the public schema - Verification of live API behavior still depends on valid app credentials, approved scopes, and a real Threads account
Sources used for API scope and endpoint selection
- Meta Threads API reference: https://developers.facebook.com/docs/threads/reference
- Meta Threads publishing reference: https://developers.facebook.com/docs/threads/reference/publishing
- Meta official Postman workspace: https://www.postman.com/meta/threads/documentation/dht3nzz/threads-api