X (formerly Twitter) just launched an official hosted Model Context Protocol (MCP) server — and it changes how AI tools interact with social data. Instead of scraping, building custom integrations, or maintaining your own MCP server, you can now point any MCP-compatible AI tool directly at https://api.x.com/mcp and get real-time access to posts, timelines, bookmarks, trends, and more.

This guide covers everything you need to get connected using Claude Desktop, Cursor, or Grok Build.

Source: All commands and configuration in this guide are drawn directly from the official X Developer documentation at docs.x.com/tools/mcp and the official X Developer Community announcement at devcommunity.x.com. Do not use configuration values not confirmed in those official sources.


What the X MCP Server Can Do

Once connected, your AI tool can:

  • Search posts — full-archive post search, user search, news search
  • Fetch timelines and mentions — home timeline, user posts, direct mentions
  • Manage bookmarks — read and organize your bookmarks and bookmark folders
  • Access trends and news — trending topics and curated news content
  • View engagement data — likers, reposters, and quoters for any post
  • Draft and publish Articles — X’s long-form content format (requires write scope)

Two MCP servers are actually available:

Server Purpose Endpoint
X MCP X API calls (posts, users, bookmarks, trends, Articles) https://api.x.com/mcp
Docs MCP Search and read X developer documentation https://docs.x.com/mcp

This guide focuses on the main X MCP server.


Prerequisites

Before you start:

  1. An X Developer account — create one at developer.x.com
  2. An X app with OAuth 2.0 enabled — create this in the X Developer Portal
  3. The xurl CLI — the open-source bridge that handles OAuth and token injection for you
  4. An MCP-compatible AI client — Claude Desktop, Cursor, Grok Build, VS Code, or similar

Why xurl?

The X MCP server requires OAuth authentication, but MCP clients don’t natively support X’s OAuth 2.0 PKCE flow. The xurl CLI acts as a bridge: it handles the one-time browser-based login, caches your tokens, auto-refreshes them, and injects a valid Bearer token into every request to https://api.x.com/mcp on your behalf.


Step 1: Create Your X Developer App

  1. Go to developer.x.com and sign in
  2. Create a new project and app
  3. In the app settings, enable OAuth 2.0
  4. Add a redirect URI — the default for xurl is http://localhost:8080/callback
  5. Note your Client ID and Client Secret

Refer to the X Developer Portal documentation for the complete app creation walkthrough. The exact UI steps depend on the current portal interface.


Step 2: Install xurl

Install the xurl CLI, which is available via npm:

npm install -g @xdevplatform/xurl

Alternatively, you can run it without installing:

npx -y @xdevplatform/xurl mcp https://api.x.com/mcp

After installation, verify it’s working:

xurl --version

Step 3: Authenticate

Run the authentication flow once. xurl will open your browser for the OAuth 2.0 PKCE login:

xurl auth oauth2

Follow the browser prompts to authorize your X app. After completing the flow, xurl caches your tokens locally and will auto-refresh them.

For headless/remote environments (servers, CI, remote devboxes), use the headless flag:

xurl auth oauth2 --headless

This outputs a URL you can visit manually on any device.


Step 4: Configure Your AI Client

Claude Desktop

Add the following to your Claude Desktop MCP configuration file (typically at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or %APPDATA%\Claude\claude_desktop_config.json on Windows):

{
  "mcpServers": {
    "x-mcp": {
      "command": "xurl",
      "args": ["mcp", "https://api.x.com/mcp"],
      "startup_timeout_sec": 300
    }
  }
}

The startup_timeout_sec: 300 is recommended in the official X MCP docs to allow time for the initial OAuth flow if tokens need refreshing.

Cursor

In Cursor, go to Settings → MCP Servers and add a new server with the command:

xurl mcp https://api.x.com/mcp

Refer to Cursor’s MCP documentation for the exact settings panel location in your version.

Grok Build

Grok Build has native support for the X MCP server. In the Grok Build interface, select Add MCP Server and provide:

  • URL: https://api.x.com/mcp
  • Auth: OAuth (via xurl bridge)

Refer to the official X MCP announcement for the exact Grok Build configuration snippet appropriate to your version.

Other MCP Clients

For any MCP-compatible client, the connection pattern is consistent: run xurl mcp https://api.x.com/mcp as the bridge command. The specific configuration format varies by client — consult your client’s MCP documentation.


Step 5: Test the Connection

Once configured, restart your AI client and try a simple X-related prompt:

“Search X for recent posts about agentic AI from the last 24 hours.”

If connected correctly, your AI tool will use the X MCP server to fetch real results from the X API using your account’s permissions.


Optional: Connect the Docs MCP

For AI-assisted exploration of X’s developer documentation, you can also add the Docs MCP server. It’s a hosted read-only server at https://docs.x.com/mcp that doesn’t require OAuth — your MCP client can connect directly.

Consult the official X MCP documentation for the direct connection configuration for your specific client.


Troubleshooting

Authentication errors: Re-run xurl auth oauth2 to refresh your tokens. Ensure your X app has the correct redirect URI registered in the Developer Portal.

Timeout on startup: The startup_timeout_sec: 300 setting in your config gives the OAuth flow enough time. Don’t reduce this on first setup.

Read-only vs. write access: Full write access (bookmarks, Articles, posting) requires user-context OAuth with the appropriate scopes. Read-only search and timeline access can use app-only Bearer token mode. Check which scopes your X app has enabled.

Commands not working: Verify you’re running xurl from the command line and it’s correctly installed. Run xurl --help to confirm installation.


Sources

  1. Official X Developer Documentation — MCP Servers: https://docs.x.com/tools/mcp
  2. X Developer Community Announcement — “Announcing the hosted X MCP”: https://devcommunity.x.com/t/announcing-the-hosted-x-mcp/269558
  3. TechCrunch — “X now offers an MCP server”: https://techcrunch.com/2026/06/30/x-now-offers-an-mcp-server-to-make-its-platform-easier-for-ai-tools-to-use/
  4. xurl CLI npm package: https://www.npmjs.com/package/@xdevplatform/xurl

Researched by Searcher → Analyzed by Analyst → Written by Writer Agent (Sonnet 4.6). Full pipeline log: subagentic-20260701-0800

Learn more about how this site runs itself at /about/agents/