x-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@x-mcp-servershow me the latest posts from @OpenAI"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
X MCP Server
TypeScript Model Context Protocol (MCP) server for the official X API.
This project lets MCP-compatible agents, including ChatGPT agents, safely read from and publish to X accounts through a local server that runs on your own computer.
The server supports:
Reading the authenticated X account.
Looking up X users by username.
Reading posts by ID.
Listing recent posts from a user.
Searching recent posts with X search syntax.
Creating posts and replies when write mode is explicitly enabled.
Selecting a different X account per local computer installation.
Running over
stdiofor local MCP hosts.Running over local Streamable HTTP for ChatGPT through OpenAI Secure MCP Tunnels.
Project Status
This is a functional MVP.
Implemented:
MCP server over
stdio.MCP server over Streamable HTTP.
Official X API client.
Local multi-account configuration.
Recommended
xurlauthentication provider, using X's official CLI for OAuth token storage, refresh and rotation.Safe
read-onlymode by default.Explicit
read-writemode for publishing and replies.Legacy local OAuth 2.0 Authorization Code + PKCE helper for direct env-token setups.
Unit tests with Vitest.
ChatGPT connection guide through OpenAI Secure MCP Tunnels.
Local server lifecycle guide for manual and automatic startup on Windows.
Related MCP server: X API FastMCP Server
How It Works
For local MCP hosts:
MCP host
-> stdio
-> x-mcp-server
-> official X APIFor ChatGPT agents:
ChatGPT agent
-> custom MCP app
-> OpenAI Secure MCP Tunnel
-> tunnel-client on your computer
-> http://127.0.0.1:3001/mcp
-> x-mcp-server
-> official X APIThe X credentials stay local. ChatGPT connects to the local MCP server through the tunnel; it does not receive your X access tokens.
Available MCP Tools
Tool | Type | Description |
| Read | Returns the selected local profile, configured accounts, auth provider, mode, and authenticated X user. |
| Read | Returns the authenticated X user. |
| Read | Looks up an X user by username. |
| Read | Reads a post by ID. |
| Read | Lists recent posts authored by a user ID. |
| Read | Searches recent posts using the official X query syntax. |
| Write | Publishes a new post. Requires |
| Write | Replies to a post. Requires |
Write tools are blocked unless X_MCP_MODE=read-write is set.
Requirements
Node.js 20 or newer.
An X Developer account.
An X Developer App with OAuth 2.0 enabled.
X read scopes:
tweet.read users.read.X write scope for publishing and replies:
tweet.write.Recommended X token manager: X's official
xurlCLI.For ChatGPT: Developer Mode enabled.
For ChatGPT local connections: an OpenAI Secure MCP Tunnel and
tunnel-client.
Step-by-Step Installation
1. Clone the Repository
git clone https://github.com/lluisfont/x-mcp-server.git
cd x-mcp-serverIf you already have the repository:
cd C:\Repos\x-mcp-server
git pull2. Install Dependencies
npm install3. Create a Local Environment File
Copy-Item .env.example .envEdit .env locally.
Do not commit .env. It may contain local app names, usernames, access tokens,
refresh tokens, client secrets, and private API keys.
4. Configure the Active X Account
Recommended setup: use xurl as the token manager.
X_AUTH_PROVIDER=xurl
X_XURL_APP=fcbnews
X_XURL_USERNAME=FCBNews2026
X_MCP_ACCOUNT=fcbnews2026
X_MCP_MODE=read-only
X_API_BASE_URL=https://api.x.comConfigure xurl once outside this project:
$secret = Read-Host "X OAuth Client Secret" -AsSecureString
$plain = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($secret)
)
npx -y @xdevplatform/xurl auth apps add fcbnews --client-id "<OAuth 2.0 Client ID>" --client-secret $plain --redirect-uri http://localhost:8080/callback
npx -y @xdevplatform/xurl auth oauth2 --app fcbnews FCBNews2026Register this callback URI in the X Developer App:
http://localhost:8080/callbackxurl stores tokens in its own local store and refreshes/persists them when
needed. The MCP server calls:
npx -y @xdevplatform/xurl token --app fcbnews -u FCBNews2026Legacy direct-token setup is still available with X_AUTH_PROVIDER=env:
X_AUTH_PROVIDER=env
X_MCP_ACCOUNT=fcbnews2026
X_MCP_MODE=read-only
X_ACCOUNT_FCBNEWS2026_USER_ACCESS_TOKEN=
X_ACCOUNT_FCBNEWS2026_REFRESH_TOKEN=
X_ACCOUNT_LLUISFONT_USER_ACCESS_TOKEN=
X_ACCOUNT_LLUISFONT_REFRESH_TOKEN=The legacy single-account env-token mode is also supported:
X_AUTH_PROVIDER=env
X_MCP_ACCOUNT=default
X_USER_ACCESS_TOKEN=New installations should prefer X_AUTH_PROVIDER=xurl.
5. Choose the Transport
For local MCP hosts that start the process directly:
X_MCP_TRANSPORT=stdioFor ChatGPT through a local tunnel:
X_MCP_TRANSPORT=http
X_MCP_HTTP_PORT=3001
X_MCP_HTTP_PATH=/mcp6. Run Type Checks and Tests
npm run typecheck
npm test
npm run build7. Start the MCP Server
For stdio:
npm run devFor local HTTP:
npm run dev:httpThe default HTTP MCP endpoint is:
http://127.0.0.1:3001/mcpHealth check:
Invoke-RestMethod http://127.0.0.1:3001/healthz | ConvertTo-Json -CompressExpected response:
{"ok":true,"transport":"http","activeAccount":"fcbnews2026","mode":"read-only"}Local MCP Server Lifecycle
When ChatGPT uses this MCP through a tunnel, two local processes must be running:
1. The MCP HTTP server
-> npm run dev:http
-> http://127.0.0.1:3001/mcp
2. tunnel-client
-> .\.tools\tunnel-client\tunnel-client.exe run --profile <profile>
-> OpenAI Secure MCP TunnelIf either process is stopped, ChatGPT cannot use the MCP tools.
Start Manually
Terminal 1:
cd C:\Repos\x-mcp-server
npm run dev:httpTerminal 2:
cd C:\Repos\x-mcp-server
.\.tools\tunnel-client\tunnel-client.exe run --profile x-fcbnewsKeep both terminals open.
Verify Local Availability
Check the MCP server:
Invoke-RestMethod http://127.0.0.1:3001/healthz | ConvertTo-Json -CompressCheck the tunnel client:
Invoke-WebRequest http://127.0.0.1:8080/readyz -UseBasicParsingThe tunnel readiness endpoint should return HTTP 200.
Stop Manually
Press Ctrl+C in:
The terminal running
npm run dev:http.The terminal running
tunnel-client run.
Once both are stopped, ChatGPT no longer has access to the local MCP server.
Change Account or Safety Mode
Edit .env.
Change active account:
X_MCP_ACCOUNT=fcbnews2026Enable write mode:
X_MCP_MODE=read-writeReturn to safe read-only mode:
X_MCP_MODE=read-onlyRestart the MCP HTTP server after changing .env:
Ctrl+C
npm run dev:httpThe tunnel can remain running if the local port and MCP path did not change.
Start Automatically on Windows Login
For a computer that should regularly host this MCP, use Windows Task Scheduler.
Create a local startup script, for example:
C:\Users\<user>\mcp-start\x-fcbnews-start.ps1Script:
$repo = "C:\Repos\x-mcp-server"
$profile = "x-fcbnews"
Set-Location $repo
Start-Process powershell.exe -ArgumentList @(
"-NoExit",
"-ExecutionPolicy", "Bypass",
"-Command", "cd `"$repo`"; npm run dev:http"
) -WindowStyle Minimized
Start-Sleep -Seconds 5
Start-Process powershell.exe -ArgumentList @(
"-NoExit",
"-ExecutionPolicy", "Bypass",
"-Command", "cd `"$repo`"; .\.tools\tunnel-client\tunnel-client.exe run --profile $profile"
) -WindowStyle MinimizedRegister the scheduled task:
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-ExecutionPolicy Bypass -File `"C:\Users\<user>\mcp-start\x-fcbnews-start.ps1`""
$trigger = New-ScheduledTaskTrigger -AtLogOn
Register-ScheduledTask `
-TaskName "X MCP FCBNews2026" `
-Action $action `
-Trigger $trigger `
-Description "Starts the local X MCP server and OpenAI tunnel-client at Windows logon."Disable automatic startup:
Disable-ScheduledTask -TaskName "X MCP FCBNews2026"Enable it again:
Enable-ScheduledTask -TaskName "X MCP FCBNews2026"Delete it:
Unregister-ScheduledTask -TaskName "X MCP FCBNews2026" -Confirm:$falseFull lifecycle guide:
docs/local-server-lifecycle.md
Connect to ChatGPT
High-level flow:
1. Run the MCP server over local HTTP.
2. Create a tunnel in OpenAI Platform.
3. Create a local tunnel-client profile pointing to http://127.0.0.1:3001/mcp.
4. Start tunnel-client.
5. Create a custom MCP app in the ChatGPT agent using Connection: Tunnel.
6. Test x_get_active_account or x_get_me before any write operation.Recommended ChatGPT custom MCP settings:
Connection: Tunnel
Tunnel: <your OpenAI tunnel>
Authentication: No authenticationUse No authentication when the MCP server manages the final service
credentials locally, for example through .env.
Full ChatGPT setup guide:
Reauthorize an X Account
Recommended xurl flow:
npx -y @xdevplatform/xurl auth oauth2 --app fcbnews FCBNews2026Use the legacy helper only for X_AUTH_PROVIDER=env:
$env:X_OAUTH_CLIENT_ID = "<OAuth 2.0 Client ID>"
$env:X_MCP_ACCOUNT = "fcbnews2026"
npm run x:oauthRestart the MCP server after reauthorization:
npm run dev:httpThen verify with:
x_get_active_accountDetailed OAuth guide:
Safety Model
The server starts in read-only mode by default:
X_MCP_MODE=read-onlyWrite tools require:
X_MCP_MODE=read-writeBefore publishing:
Verify the active account with
x_get_active_account.Confirm the exact text to publish.
Ensure the X token has
tweet.write.Prefer
X_AUTH_PROVIDER=xurlso X token refresh and rotation are handled by X's official CLI.Ask the agent to return the generated
post_id.Do not treat a post as published until X returns an ID.
Scripts
Script | Purpose |
| Starts the MCP server over |
| Starts the MCP server over local HTTP. |
| Runs the local X OAuth authorization helper. |
| Compiles TypeScript to |
| Starts the compiled server over |
| Starts the compiled server over HTTP. |
| Runs TypeScript without emitting files. |
| Runs the Vitest test suite. |
Documentation
docs/project-architecture.md: project architecture.
docs/configuration.md: environment variables and multi-account setup.
docs/local-server-lifecycle.md: start, stop, and automate the local MCP server.
docs/tools.md: MCP tools and usage contracts.
docs/x-oauth.md: X OAuth reauthorization.
docs/development.md: development, testing, and change guidelines.
docs/chatgpt-mcp-setup.md: step-by-step ChatGPT MCP setup.
Operational Security
Keep credentials outside Git.
Keep
read-onlyas the default mode.Enable
read-writeonly for controlled workflows.Verify the active account before publishing.
Do not log access tokens or refresh tokens.
Do not paste tokens into chats, issues, docs, or pull requests.
Do not run automatic startup in
read-writemode on shared computers.
License
No open-source license has been selected yet.
Available Tools
8 toolsx_create_postB
Publish a new X post. Requires X_MCP_MODE=read-write and tweet.write scope.
Inputs: text (required).
x_get_active_accountARead-only
Get the local X account profile selected for this MCP server installation. Does not expose tokens.
Inputs: no named parameters.
x_get_meBRead-only
Get the authenticated X user.
Inputs: no named parameters.
x_get_postBRead-only
Get a single X post by ID.
Inputs: postId (required).
x_get_userCRead-only
Get an X user by username.
Inputs: username (required).
x_get_user_postsCRead-only
Get recent posts authored by an X user ID.
Inputs: userId (required), maxResults.
x_reply_postA
Reply to an X post. Requires X_MCP_MODE=read-write and tweet.write scope.
Inputs: text (required), postId (required).
x_search_postsCRead-only
Search recent X posts using the official X query syntax.
Inputs: query (required), maxResults.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
TDQS
Scored across 8 tools
Tools have largely distinct purposes: get_active_account (local config) vs get_me (authenticated API user) vs get_user (by username) are differentiated by descriptions, and get_post vs get_user_posts vs search_posts are clearly separated. Minor potential confusion among the three user-retrieval tools, but descriptions resolve it adequately.
All tools follow a consistent snake_case pattern with an x_ prefix and verb_noun structure (e.g., x_get_user, x_create_post, x_reply_post). No deviations in style or convention.
Eight tools is well-scoped for a focused X API server covering basic read and write operations. Each tool earns its place, with no redundant or excessive entries.
The surface covers reading posts/users and creating posts/replies, but notable gaps exist: no delete or edit post, no like/retweet, and no follow/unfollow. These missing operations limit common agent workflows.
Maintenance
Related MCP Connectors
Official MCP server for twitterapis.com. Twitter/X search, users, DMs, Grok, monitoring and writes.
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Twitter/X read-only MCP server — 12 tools: search, users, tweets, followers, timelines, trends.
Official twitterapi.io hosted MCP: Twitter/X tweets, users, followers, trends. OAuth or API key.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides AI agents with full access to the X (Twitter) API for posting, searching, and managing engagement through natural language. It supports comprehensive tools for tweet management, media uploads, and account analytics across multiple MCP-compatible clients.1560MIT

X API FastMCP Serverofficial
FlicenseNot gradedqualityDmaintenanceA local MCP server that exposes the X API (formerly Twitter API) as tools, enabling operations like posting, searching, user management, and more via natural language commands.867-- AlicenseAqualityCmaintenanceMCP server for Twitter/X enabling AI agents to search, post, reply, and engage with tweets.147 npm2MIT
- AlicenseAqualityBmaintenanceMCP server for the Twitter/X API, enabling search, user profiles, tweets, followers, and more via natural language.941,043 npm6MIT