Skip to main content
Two MCP (Model Context Protocol) servers are available for working with X from AI tools:
ServerWhat it doesURL
XMCPCall X API endpoints (create posts, search, look up users, etc.)http://127.0.0.1:8000/mcp (local)
Docs MCPSearch and read X API documentationhttps://docs.x.com/mcp (hosted)

XMCP — X API endpoints

XMCP is an official MCP server that exposes X API endpoints as callable tools. Run it locally and connect any MCP-compatible client — like Cursor, Windsurf, or your own agent — to read and write to X programmatically.

GitHub repository

Source code, setup instructions, and configuration.

What is MCP?

Learn about the Model Context Protocol standard.
XMCP loads the X API OpenAPI specification at startup and converts every operation into an MCP tool. Your AI assistant can then call these tools to interact with the X API — creating posts, searching, looking up users, and more. Key features:
  • 200+ tools automatically generated from the OpenAPI spec — search posts, create posts, look up users, manage likes, and more
  • OAuth 1.0a authentication with browser-based consent flow
  • Tool allow-listing via X_API_TOOL_ALLOWLIST to restrict which API operations are available
  • Works with any MCP client — Cursor, Windsurf, or custom implementations
  • Optional Grok test client using the xAI API

Quick setup

1

Clone and install

Requires Python 3.9+.
git clone https://github.com/xdevplatform/xmcp && cd xmcp
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
2

Configure credentials

Copy the example environment file and add your X API credentials:
cp env.example .env
Edit .env with your app’s OAuth consumer key, consumer secret, and bearer token from the Developer Console. Set your callback URL (e.g., http://127.0.0.1:8976/oauth/callback) — make sure to register it in the Developer Console too.
3

Start the server

python server.py
The MCP server starts at http://127.0.0.1:8000/mcp by default. Host and port are configurable via environment variables.
4

Connect your AI tool

Point your MCP-compatible client to http://127.0.0.1:8000/mcp. See the XMCP README for client-specific configuration.

Configuration

Add XMCP to your MCP client settings:
{
  "mcpServers": {
    "xmcp": {
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}
Once connected, you can ask your AI assistant to interact with X directly — “search for recent posts about AI”, “look up @XDevelopers”, or “create a post”.

Tool allow-listing

By default, XMCP exposes all X API operations as tools. Use the X_API_TOOL_ALLOWLIST environment variable to restrict which tools are available:
X_API_TOOL_ALLOWLIST="createPosts,getUsersByUsername,searchPostsRecent,likePost"
This is useful for limiting what an AI agent can do — for example, allowing read-only operations while blocking post creation or deletion.

Limitations

  • No streaming or webhook endpoints — these require persistent connections that don’t fit the MCP request/response model
  • Spec fetched at startup — restart the server to pick up any API spec updates
  • Tokens stored in memory — OAuth tokens are not persisted across restarts

An MCP server for the X API documentation is hosted at https://docs.x.com/mcp. Connect it to your AI tool to search and read documentation pages without leaving your workflow.

Available tools

ToolDescription
search_xSearch across the X documentation for relevant information, code examples, API references, and guides
get_page_xRetrieve the full content of a specific documentation page by its path

Configuration

Add the docs MCP server to your MCP client configuration:
{
  "mcpServers": {
    "x-docs": {
      "url": "https://docs.x.com/mcp"
    }
  }
}
This is useful when you’re building with the X API and want your AI assistant to look up endpoint details, authentication guides, or code examples on the fly.

Using both servers together

You can connect both MCP servers simultaneously. This gives your AI assistant the ability to both look up documentation and call the API:
{
  "mcpServers": {
    "xmcp": {
      "url": "http://127.0.0.1:8000/mcp"
    },
    "x-docs": {
      "url": "https://docs.x.com/mcp"
    }
  }
}

OpenAPI specification

The machine-readable API specification for all X API v2 endpoints. This is the same spec that XMCP uses to generate its tools.
ResourceURL
OpenAPI Spec (JSON)https://api.x.com/2/openapi.json
curl https://api.x.com/2/openapi.json -o openapi.json
You can use it to auto-generate API clients, import into Postman, feed into custom AI agents, or validate request/response schemas.