Post X MCP

by codechap

Not rated
GitHub

About

MCP server for posting to X (Twitter) with multi-account support

Details

Author
codechap
Categories
Communication, Other

Setup

Install Post X MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/codechap/mcp-server-post-x

Follow the installation instructions in the repository README, then restart your MCP client.

An MCP (Model Context Protocol) server for X (Twitter). Built in Rust using OAuth 1.0a and the X API v2. Supports multiple accounts.

Communicates via stdio using JSON-RPC 2.0.

All tools accept an optionalaccountparameter to select which X account to use. Omit it to use the default account.

Producestarget/release/mcp-server-x(optimized with LTO, stripped).

The server looks for the config at the first existing of:

- $XDG_CONFIG_HOME/mcp-server-x/config.toml
- ~/.config/mcp-server-x/config.toml
- $XDG_CONFIG_HOME/mcp-server-post-x/config.toml(legacy)
- ~/.config/mcp-server-post-x/config.toml(legacy)

You can also runwithout any config fileby providing credentials via environment variables (great for containers/CI):

export X_API_KEY=... export X_API_KEY_SECRET=... export X_ACCESS_TOKEN=... export X_ACCESS_TOKEN_SECRET=... # Optional: # export X_ACCOUNT_NAME=myaccount

POST_X_/POST_X_ACCOUNT_NAMEare still accepted if theX_vars are unset.

Create the config file (classic approach):

Create~/.config/mcp-server-x/config.toml:

Single account(nodefault_accountneeded):

[accounts.myaccount] api_key = "your-api-key" api_key_secret = "your-api-key-secret" access_token = "your-access-token" access_token_secret = "your-access-token-secret"
default_account = "myaccount" [accounts.myaccount] api_key = "your-api-key" api_key_secret = "your-api-key-secret" access_token = "your-access-token" access_token_secret = "your-access-token-secret" [accounts.otheraccount] api_key = "your-api-key" api_key_secret = "your-api-key-secret" access_token = "other-access-token" access_token_secret = "other-access-token-secret"

- Account keys are X usernames (e.g.[accounts.codechap])
- If you have multiple accounts,default_accountis required
- If you have one account,default_accountis optional (auto-detected)
- Multiple accounts can share the sameapi_key/api_key_secret(same X app). Only theaccess_token/access_token_secretdiffer per account.

chmod 700 ~/.config/mcp-server-x chmod 600 ~/.config/mcp-server-x/config.toml

SeeGetting credentialsbelow for how to obtain these.

{ "mcpServers": { "x": { "command": "/path/to/mcp-server-x" } } }

- "Post a tweet saying hello world"
- "Post a tweet as securechap saying hello world"
- "Search for tweets about Rust"
- "Show me my timeline"
- "Like this tweet:
https://x.com/someone/status/123456"
- "Who are my followers?"
- "Look up @elonmusk"
- "List my accounts"

No required parameters. Returns available account names, which is the default, and cached usernames.

delete_tweet / like_tweet / unlike_tweet / retweet / unretweet / bookmark_tweet / unbookmark_tweet

All accept URLs likehttps://x.com/user/status/123456— the ID is extracted automatically.

Returns amedia_idto use withpost_tweet'smedia_idsparam.

Update the authenticated user's profile text fields. At least one field must be provided; only the fields you pass are changed, and passing an empty string clears that field.

  • At least one ofdescription,name,location, orurlis required.
Uses the legacyPOST /1.1/account/update_profile.jsonendpoint (no v2 equivalent). Requires the app to haveRead and Writepermission; without it the endpoint returns 403.

Uses the legacyPOST /1.1/account/update_profile_banner.jsonendpoint (base64bannerparam; no v2 equivalent). Success returns HTTP 200 with no body.

Returns trend names and approximate post volumes.

lookup_user / follow_user / unfollow_user

Auto-paginates through results (100 per page) with a 200ms delay between pages. For accounts with tens of thousands of followers, prefer the paginatedget_followers/get_followingtools instead.

Returns your user ID, display name, and @username.

To add another X account to an existing app (without a separate developer account), use the included OAuth authorization script:

export X_API_KEY="your-app-api-key" export X_API_KEY_SECRET="your-app-api-key-secret" ./oauth-authorize.sh

Important:The script no longer contains any hardcoded credentials. You must provide your own app's Consumer Keys via the two environment variables shown above.

This runs the 3-legged OAuth 1.0a PIN-based flow:
- Opens a URL where the new account authorizes your app
- You paste the PIN back into the terminal
- It outputs the
[accounts.username]config block to add to yourconfig.toml

All accounts you authorize share the same X App (and its rate limits + billing). This is the normal pattern for multi-account usage.
- Go todeveloper.x.comand sign up for a developer account
- Create a Project and an App in the Developer Console
- In your App settings, set upUser authentication:

- App permissions:Read and write(andDirect Messagesif you want DM support)
- Type:Web App, Automated App or Bot
- Callback URL:https://example.com(not used, but required)
- Website URL: any valid URL

- API KeyandAPI Key Secret(under Consumer Keys)
- Access TokenandAccess Token Secret(under Authentication Tokens)

The server validates credentials at startup. If you get persistent 401 errors, regenerate your tokens atdeveloper.x.com.

cargo build # debug build cargo run # run in dev mode RUST_LOG=debug cargo run # debug logging (credentials are redacted) cargo test # run unit tests cargo clippy -- -D warnings # strict lint check (must pass) cargo build --release # optimized binary

- Auth:OAuth 1.0a with HMAC-SHA1 signatures (RFC 5849, RFC 3986 percent-encoding)
- Multi-account:Multiple X accounts per server instance, selectable per tool call
- Tweet API:X API v2 (api.x.com/2/)
- Media upload:v1.1 chunked upload (upload.twitter.com/1.1/media/upload.json) — INIT/APPEND/FINALIZE/STATUS flow for video/GIF, simple multipart for images
- Media limits:JPEG/PNG/WebP up to 5MB, GIF up to 15MB, MP4 up to 512MB
- Media validation:Max 4 images OR 1 video OR 1 GIF per tweet (no mixing)
- Thread posting:500ms delay between tweets, chained viain_reply_to_tweet_id
- Retry logic:Automatic retry with exponential backoff on 503 errors
- Rate limits:429 responses include reset timestamp in error message (no auto-retry — the caller decides)
- Safety:get_all_followers/get_all_followingare capped at 10k users by default to avoid destroying LLM context windows
- Rust edition:2021 (broad compatibility)

src/ main.rs — entry point, config loading, tracing, stdio transport server.rs — MCP tool handlers, response formatting, multi-account routing api.rs — X API client: OAuth signing, tweet/media/user/DM endpoints params.rs — tool parameter types (serde + JSON Schema)

Manage your X (Twitter) account using the Apex social media infrastructure. Requires an Apex API Key.

Twitter/X tools for AI agents — read timelines, post tweets, search, and engage

Interact with Twitter to post and search for tweets.

A server for interacting with Twitter, allowing you to post tweets, read timelines, and manage your account through the MCP standard.

Provides Twitter API access without requiring local credential setup. Credentials must be provided at runtime.

An MCP server for interacting with the X (Twitter) API, requiring developer credentials.

Integrate with the X (Twitter) API for workflow automation, enhanced error handling, and real-time documentation.

Official MCP server for twitterapis.com: Twitter/X search, users, followers, tweets, threads, lists, likes, bookmarks, DMs, plus post/like/retweet/follow actions as native Claude/Cursor tools.

Schedule and queue text, image, and video posts to many social networks, including LinkedIn, X, Bluesky, Instagram, Facebook, Threads, Tiktok.

MCP server for AgentHive, the microblogging social network for AI agents. Post, reply, boost, follow, search, and discover agents.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.