Safety-first X (Twitter) API v2 MCP server: 41 typed tools across 12 packages, policy-gated.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
An MCP server that exposes the X (Twitter) API v2 to MCP clients β Claude Code, Claude Desktop, VS Code, Cursor, or any MCP-compatible agent β as a curated set of typed tools, gated by a two-axis policy model and aware of the 2026 pay-per-use pricing so an agent can never quietly overspend.
Status: pre-1.0, under active development, published on npm as
x-mcp-ai(currently0.8.0, published from CI with npm provenance). Pin an exact version while the project is on0.x(Setup). 41 tools across 12 packages are registered today; the full designed surface lives indocs/03-tool-catalog.mdand has landed in full. The public API is unstable until1.0.0.
Contents: Quick demo Β· Features Β· Requirements Β· Setup Β· Configure credentials Β· Cost Β· Run / debug Β· Develop Β· Tools Β· Resources Β· Prompts Β· Project structure Β· Security notes Β· Data handling Β· Documentation Β· Support Β· Trademark
Once the server is wired into your MCP client, you drive it in natural language and the model picks the tool. Three representative asks:
operation:domain) with five presets β read-only (default),
engage, publish, manage, full. Writes are opt-in; deny beats allow beats
preset, per cell. Direct-message cells are double-locked: read:dm/write:dm are in
no preset, not even full.cost_usd and the running session_total_usd; an operator-set
X_MCP_CREDIT_BUDGET with X_MCP_BUDGET_MODE=hard refuses calls that would exceed it,
and the model cannot raise the cap.Authorization header, redirects never followed
on token-bearing requests, 0600 token file written with O_NOFOLLOW/O_EXCL,
untrusted-content marking on returned text, and media upload default-deny outside a
realpath-contained X_MCP_MEDIA_DIR.retryable and
fix: "agent" | "operator", so the model retries what is retryable and escalates what is
not.outputSchema and returns
structuredContent alongside the text block..nvmrc).The recommended install is the published package, pinned to an exact version while the
project is on 0.x β nothing to clone or build:
Then point your MCP client at it:
Running from a local checkout instead? Use "command": "node" with
"args": ["/abs/path/to/x-mcp/build/src/index.js"] and the same env map.
Claude Code from the CLI:
Per-client instructions β Claude Desktop, Claude Code, VS Code (.vscode/mcp.json),
Cursor and MCP Inspector β are in
docs/10-operator-guide.md Β§4, together with the authorize
flow and ready-made env recipes.
Still fully supported β build the entry point and spawn it with node instead of npx:
The server never prompts interactively; all configuration comes from environment variables
(canonical table: docs/02-architecture.md Β§4; a starting point:
.env.example).
Auth modes (X_MCP_AUTH_MODE):
oauth2 (default) β OAuth 2.0 with PKCE. Run the one-time authorization flow with the
authorize subcommand; tokens land in X_MCP_TOKEN_FILE and are refreshed automatically.app-only β application-only bearer token (X_MCP_BEARER_TOKEN); read endpoints only, no
user context.| Variable | Default | Secret | Purpose |
|---|---|---|---|
X_MCP_AUTH_MODE | oauth2 | oauth2 | app-only. | |
X_MCP_CLIENT_ID | OAuth 2.0 client ID (required for authorize and refresh). | ||
X_MCP_CLIENT_SECRET | β | OAuth 2.0 client secret (confidential clients only). | |
X_MCP_BEARER_TOKEN | β | App-only bearer token; valid only with app-only. | |
X_MCP_TOKEN_FILE | OS-resolved | Path to the rotating OAuth 2.0 token store (~ expanded). | |
X_MCP_TOKEN_KEYCHAIN | 0 | 1 β store tokens in the OS keychain (macOS security, Linux secret-tool). Mutually exclusive with X_MCP_TOKEN_FILE. | |
X_MCP_POLICY | read-only | Preset: read-only | engage | publish | manage | full. | |
X_MCP_POLICY_ALLOW | Comma-separated operation:domain cells to add. | ||
X_MCP_POLICY_DENY | Comma-separated cells to remove (wins over allow and preset). | ||
X_MCP_HIDE_DENIED | 0 | 1 β drop denied tools from registration entirely. | |
X_MCP_CREDIT_BUDGET | Session spend cap, USD (e.g. 5.00). Unset = no cap. | ||
X_MCP_BUDGET_MODE | warn | warn | hard. | |
X_MCP_AVAILABILITY | Comma-separated availability classes to enable (pilot, premium-user, enterprise). | ||
X_MCP_MEDIA_DIR | Directory uploads must realpath inside (media default-deny). | ||
X_MCP_PROFILES_FILE | Multi-account profiles file. | ||
X_MCP_PROFILE | Active profile name (required with a profiles file). | ||
X_MCP_BASE_URL | https://api.x.com | API base URL; must be https:// and *.x.com. | |
X_MCP_ALLOW_INSECURE_BASE_URL | 0 | 1 β permit a non-x.com base URL (testing only). | |
X_MCP_TIMEOUT_MS | 30000 | Per-request timeout, milliseconds. | |
X_MCP_LOG_LEVEL | info | silent | error | info | debug. |
Any other X_MCP_* variable is ignored with a startup warning β that is the typo detector.
Every fatal configuration error names the variable at fault.
Every tool maps to one policy cell β an operation:domain pair. Operations escalate
read β write β destructive; domains are content, user, account, engagement,
social-graph, moderation, dm. A preset unlocks a set of the 12 valid cells;
X_MCP_POLICY_ALLOW adds cells, X_MCP_POLICY_DENY removes them, and
deny > allow > preset.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/x-mcp-ai)<a href="https://allmcps.com/mcp/x-mcp-ai"><img src="https://allmcps.com/api/badge/x-mcp-ai?style=directory" alt="X MCP AI on AllMCPs" /></a>