
X API FastMCP Server (xmcp)
MCPFrom the X (Twitter) developer platform: a FastMCP server that turns the X API into tools to post, search posts and users, and manage DMs and lists, with an allowlist for which tools load. Needs X developer app credentials and a locally started Python server.
X API FastMCP Server
Run a local MCP server that exposes the X API OpenAPI spec as tools using FastMCP. Streaming and webhook endpoints are excluded.
Prerequisites
- Python 3.9+
- An X Developer Platform app (to get tokens)
- Optional: an xAI API key if you want to run the Grok test client
Setup (local)
- Create a virtual environment and install dependencies:
python -m venv .venvsource .venv/bin/activatepip install -r requirements.txt
- Create your local
.env:cp env.example .env- Required values (do not skip):
X_OAUTH_CONSUMER_KEYX_OAUTH_CONSUMER_SECRETX_BEARER_TOKEN(required for this setup; keep it set even if using OAuth1)
- OAuth1 callback (defaults are fine):
X_OAUTH_CALLBACK_HOST(default127.0.0.1)X_OAUTH_CALLBACK_PORT(default8976)X_OAUTH_CALLBACK_PATH(default/oauth/callback)X_OAUTH_CALLBACK_TIMEOUT(default300)
- Server settings (optional):
X_API_BASE_URL(defaulthttps://api.x.com)X_API_TIMEOUT(default30)MCP_HOST(default127.0.0.1)MCP_PORT(default8000)X_API_DEBUG(default1)
- Tool filtering (optional, comma-separated):
X_API_TOOL_ALLOWLIST
- Optional Grok test client:
XAI_API_KEYXAI_MODEL(defaultgrok-4-1-fast)MCP_SERVER_URL(defaulthttp://127.0.0.1:8000/mcp)
- Optional OAuth2 token generation:
CLIENT_IDCLIENT_SECRETX_OAUTH_ACCESS_TOKEN-X_OAUTH_ACCESS_TOKEN_SECRET(optional)
- Optional OAuth1 debug output:
X_OAUTH_PRINT_TOKENSX_OAUTH_PRINT_AUTH_HEADER
- Register the callback URL in your X Developer App:
http://<X_OAUTH_CALLBACK_HOST>:<X_OAUTH_CALLBACK_PORT><X_OAUTH_CALLBACK_PATH>
Example (defaults):
http://127.0.0.1:8976/oauth/callback
- Start the server:
python server.py
The MCP endpoint is http://127.0.0.1:8000/mcp by default.
- Connect an MCP client:
- Local client: point it to
http://127.0.0.1:8000/mcp. - Remote client: tunnel your local server (e.g., ngrok) and use the public URL.
Whitelisting tools
Use X_API_TOOL_ALLOWLIST to load a small, explicit set of tools:
X_API_TOOL_ALLOWLIST=getUsersByUsername,createPosts,searchPostsRecent
Whitelisting is applied at startup when the OpenAPI spec is loaded, so restart the server after changes. See the full tool list below before building your allowlist.
OAuth1 flow (startup behavior)
On startup, the server opens a browser for OAuth1 consent and waits for the
callback. Tokens are kept in memory only for the lifetime of the server
process. Set X_OAUTH_PRINT_TOKENS=1 to print tokens, or
X_OAUTH_PRINT_AUTH_HEADER=1 to print request headers.
Available tool calls (allowlist-ready)
Below is the full list of tool calls you can whitelist via
X_API_TOOL_ALLOWLIST. Copy any of these into your .env allowlist.
addListsMemberaddUserPublicKeyappendMediaUploadblockUsersDmscreateCommunityNotescreateComplianceJobscreateDirectMessagesByConversationIdcreateDirectMessagesByParticipantIdcreateDirectMessagesConversationcreateListscreateMediaMetadatacreateMediaSubtitlescreatePostscreateUsersBookmarkdeleteActivitySubscriptiondeleteAllConnectionsdeleteCommunityNotesdeleteConnectionsByEndpointdeleteConnectionsByUuidsdeleteDirectMessagesEventsdeleteListsdeleteMediaSubtitlesdeletePostsdeleteUsersBookmarkevaluateCommunityNotesfinalizeMediaUploadfollowListfollowUsergetAccountActivitySubscriptionCountgetActivitySubscriptionsgetChatConversationgetChatConversationsgetCommunitiesByIdgetComplianceJobsgetComplianceJobsByIdgetConnectionHistorygetDirectMessagesEventsgetDirectMessagesEventsByConversationIdgetDirectMessagesEventsByIdgetDirectMessagesEventsByParticipantIdgetInsights28HrgetInsightsHistoricalgetListsByIdgetListsFollowersgetListsMembersgetListsPostsgetMarketplaceHandleAvailabilitygetMediaAnalyticsgetMediaByMediaKeygetMediaByMediaKeysgetMediaUploadStatusgetNewsgetOpenApiSpecgetPostsAnalyticsgetPostsByIdgetPostsByIdsgetPostsCountsAllgetPostsCountsRecentgetPostsLikingUsersgetPostsQuotedPostsgetPostsRepostedBygetPostsRepostsgetSpacesBuyersgetSpacesByCreatorIdsgetSpacesByIdgetSpacesByIdsgetSpacesPostsgetTrendsByWoeidgetTrendsPersonalizedTrendsgetUsagegetUserPublicKeysgetUsersAffiliatesgetUsersBlockinggetUsersBookmarkFoldersgetUsersBookmarksgetUsersBookmarksByFolderIdgetUsersByIdgetUsersByIdsgetUsersByUsernamegetUsersByUsernamesgetUsersFollowedListsgetUsersFollowersgetUsersFollowinggetUsersLikedPostsgetUsersListMembershipsgetUsersMegetUsersMentionsgetUsersMutinggetUsersOwnedListsgetUsersPinnedListsgetUsersPostsgetUsersRepostsOfMegetUsersTimelinehidePostsReplyinitializeMediaUploadlikePostmediaUploadmuteUserpinListremoveListsMemberByUserIdrepostPostsearchCommunitiessearchCommunityNotesWrittensearchEligiblePostssearchNewssearchPostsAllsearchPostsRecentsearchSpacessearchUserssendChatMessageunblockUsersDmsunfollowListunfollowUserunlikePostunmuteUserunpinListunrepostPostupdateActivitySubscriptionupdateLists
Generate an OAuth2 user token (optional)
- Add
CLIENT_IDandCLIENT_SECRETto your.env. - Update
redirect_uriingenerate_authtoken.pyto match your app settings. - Run
python generate_authtoken.pyand follow the prompts. - Copy the printed access token into
.envasX_OAUTH_ACCESS_TOKEN. If your flow returns a secret, store it asX_OAUTH_ACCESS_TOKEN_SECRET.
Run the Grok MCP test client (optional)
- Set
XAI_API_KEYin.env. - Make sure your MCP server is running locally (or set
MCP_SERVER_URL). - If Grok is not running on your machine, use ngrok to expose your local MCP
server and set
MCP_SERVER_URLto the public HTTPS URL that ends with/mcp. Example flow:ngrok http 8000thenMCP_SERVER_URL=https://<id>.ngrok-free.dev/mcp. - Run
python test_grok_mcp.py.
Notes
- Endpoints with
/streamor/webhooksin the path are excluded. - Operations tagged
StreamorWebhooks, or marked withx-twitter-streaming: true, are excluded. - The OpenAPI spec is fetched from
https://api.twitter.com/2/openapi.jsonat startup.
Ressources associées

X Article Publisher
SkillLays out a finished Markdown long-form post in the X (Twitter) Articles editor: title, bold, links, cover and inline images, with tables and Mermaid diagrams turned into images. Saves a draft only, never publishes. Needs X Premium Plus, Playwright MCP and Python (macOS/Windows).
wshuyi/x-article-publisher-skill873
Postiz
MCPMCP built into the open-source social media scheduler Postiz: agents draft, schedule and publish posts and view analytics across 30+ platforms including X, LinkedIn, Instagram and YouTube. The cloud version uses browser OAuth, no API key (paid after a 7-day trial); self-hosting is free.
gitroomhq/postiz-app37.3k
Streamlink
CLIPipes live streams from Twitch, YouTube and many other platforms to a local player, or saves them to video files with --output or --record, for keeping and re-editing replays of your own or partners' streams. Viewing needs a player like VLC. Only record content you have rights to.
streamlink/streamlink11.9k
xurl
CLIX's (formerly Twitter) official API command-line tool. Once authorized, agents can post for you, upload images and video, and query post and account data; it can also run as an MCP server for Claude. Needs an X developer account and app; the X API is pay-per-use, so buy credits first.
xdevplatform/xurl1.4k
Marketing Skills
SkillMarketing skill collection: 50 skills covering SEO audits, conversion optimization, landing page copy, pricing, paid ads, email and social media, all sharing a common product marketing context. Supports Claude Code, Codex and more.
coreyhaines31/marketingskills55k
Marketing Skills
PluginMarketing skills for technical marketers and founders: 50 skills covering conversion optimization, copywriting, SEO and AI search, paid ads, email and cold outreach, pricing, customer research and launch strategy, all sharing one product-marketing context.
coreyhaines31/marketingskills55k