x-mcp-server
X MCP Server
X公式API向けのTypeScript Model Context Protocol (MCP) サーバー。
このプロジェクトにより、ChatGPTエージェントを含むMCP互換エージェントは、自分のコンピュータ上で動作するローカルサーバーを介して、Xアカウントから安全に読み取り、Xアカウントに投稿することができます。
サーバーがサポートする機能:
認証済みXアカウントの読み取り。
ユーザー名によるXユーザーの検索。
IDによる投稿の読み取り。
ユーザーの最近の投稿の一覧表示。
X検索構文を使用した最近の投稿の検索。
書き込みモードが明示的に有効になっている場合の投稿と返信の作成。
ローカルコンピュータのインストールごとに異なるXアカウントを選択。
ローカルMCPホスト向けの
stdio経由の実行。OpenAI Secure MCP Tunnelsを通じたChatGPT向けのローカルStreamable HTTP経由の実行。
プロジェクトステータス
これは機能するMVPです。
実装済み:
stdio上のMCPサーバー。Streamable HTTP上のMCPサーバー。
X公式APIクライアント。
ローカルでの複数アカウント設定。
デフォルトの安全な
read-onlyモード。投稿と返信のための明示的な
read-writeモード。Xアカウント再認証のためのローカルOAuth 2.0 Authorization Code + PKCEヘルパー。
Vitestを使用したユニットテスト。
OpenAI Secure MCP Tunnelsを通じたChatGPT接続ガイド。
Windowsでの手動および自動起動のためのローカルサーバーライフサイクルガイド。
Related MCP server: X API FastMCP Server
仕組み
ローカルMCPホストの場合:
MCP host
-> stdio
-> x-mcp-server
-> official X APIChatGPTエージェントの場合:
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 APIXの認証情報はローカルに保持されます。ChatGPTはトンネルを通じてローカルMCPサーバーに接続しますが、あなたのXアクセストークンは受け取りません。
利用可能なMCPツール
ツール | タイプ | 説明 |
| 読み取り | 選択されたローカルプロファイル、設定済みアカウント、モード、認証済みXユーザーを返します。 |
| 読み取り | 認証済みXユーザーを返します。 |
| 読み取り | ユーザー名でXユーザーを検索します。 |
| 読み取り | IDで投稿を読み取ります。 |
| 読み取り | ユーザーIDによって作成された最近の投稿を一覧表示します。 |
| 読み取り | 公式のXクエリ構文を使用して最近の投稿を検索します。 |
| 書き込み | 新しい投稿を公開します。 |
| 書き込み | 投稿に返信します。 |
書き込みツールは、X_MCP_MODE=read-writeが設定されていない限りブロックされます。
要件
Node.js 20以上。
X Developerアカウント。
OAuth 2.0が有効なX Developer App。
X読み取りスコープ:
tweet.read users.read。投稿と返信のためのX書き込みスコープ:
tweet.write。推奨されるX更新スコープ:
offline.access。ChatGPTの場合:Developer Modeを有効にする。
ChatGPTローカル接続の場合:OpenAI Secure MCP Tunnelと
tunnel-client。
ステップバイステップのインストール
1. リポジトリのクローン
git clone https://github.com/lluisfont/x-mcp-server.git
cd x-mcp-serverすでにリポジトリを保有している場合:
cd C:\Repos\x-mcp-server
git pull2. 依存関係のインストール
npm install3. ローカル環境ファイルの作成
Copy-Item .env.example .env.envをローカルで編集してください。
.envをコミットしないでください。アクセストークン、リフレッシュトークン、クライアントシークレット、プライベートAPIキーが含まれる可能性があります。
4. アクティブなXアカウントの設定
名前付きローカルアカウントの場合:
X_MCP_ACCOUNT=fcbnews2026
X_MCP_MODE=read-only
X_API_BASE_URL=https://api.x.com
X_ACCOUNT_FCBNEWS2026_USER_ACCESS_TOKEN=
X_ACCOUNT_FCBNEWS2026_REFRESH_TOKEN=同じコンピュータで複数のアカウントを使用する場合:
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=X_MCP_ACCOUNTは、このインストールで使用されるローカルプロファイルを選択します。コードを変更することなく、コンピュータごとに異なるアカウントを選択できます。
従来の単一アカウントモードもサポートされています:
X_MCP_ACCOUNT=default
X_USER_ACCESS_TOKEN=新しいインストールでは、名前付きアカウントを推奨します。
5. トランスポートの選択
プロセスを直接起動するローカルMCPホストの場合:
X_MCP_TRANSPORT=stdioローカルトンネルを通じたChatGPTの場合:
X_MCP_TRANSPORT=http
X_MCP_HTTP_PORT=3001
X_MCP_HTTP_PATH=/mcp6. 型チェックとテストの実行
npm run typecheck
npm test
npm run build7. MCPサーバーの起動
stdioの場合:
npm run devローカルHTTPの場合:
npm run dev:httpデフォルトのHTTP MCPエンドポイントは次のとおりです:
http://127.0.0.1:3001/mcpヘルスチェック:
Invoke-RestMethod http://127.0.0.1:3001/healthz | ConvertTo-Json -Compress期待される応答:
{"ok":true,"transport":"http","activeAccount":"fcbnews2026","mode":"read-only"}ローカルMCPサーバーのライフサイクル
ChatGPTがトンネルを通じてこのMCPを使用する場合、2つのローカルプロセスが実行されている必要があります:
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 Tunnelどちらかのプロセスが停止すると、ChatGPTはMCPツールを使用できません。
手動での起動
ターミナル1:
cd C:\Repos\x-mcp-server
npm run dev:httpターミナル2:
cd C:\Repos\x-mcp-server
.\.tools\tunnel-client\tunnel-client.exe run --profile x-fcbnews両方のターミナルを開いたままにしてください。
ローカルでの利用可能性の確認
MCPサーバーを確認:
Invoke-RestMethod http://127.0.0.1:3001/healthz | ConvertTo-Json -Compressトンネルクライアントを確認:
Invoke-WebRequest http://127.0.0.1:8080/readyz -UseBasicParsingトンネルの準備完了エンドポイントはHTTP 200を返す必要があります。
手動での停止
次の場所でCtrl+Cを押します:
npm run dev:httpを実行しているターミナル。tunnel-client runを実行しているターミナル。
両方が停止すると、ChatGPTはローカルMCPサーバーにアクセスできなくなります。
アカウントまたは安全モードの変更
.envを編集します。
アクティブなアカウントを変更:
X_MCP_ACCOUNT=fcbnews2026書き込みモードを有効にする:
X_MCP_MODE=read-write安全な読み取り専用モードに戻す:
X_MCP_MODE=read-only.envを変更した後、MCP HTTPサーバーを再起動します:
Ctrl+C
npm run dev:httpローカルポートとMCPパスが変更されていない場合、トンネルは実行中のままにできます。
Windowsログイン時に自動起動
このMCPを定期的にホストするコンピュータでは、Windows Task Schedulerを使用します。
ローカル起動スクリプトを作成します。例:
C:\Users\<user>\mcp-start\x-fcbnews-start.ps1スクリプト:
$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 Minimizedスケジュールされたタスクを登録:
$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-ScheduledTask -TaskName "X MCP FCBNews2026"再度有効にする:
Enable-ScheduledTask -TaskName "X MCP FCBNews2026"削除する:
Unregister-ScheduledTask -TaskName "X MCP FCBNews2026" -Confirm:$false完全なライフサイクルガイド:
docs/local-server-lifecycle.md
ChatGPTへの接続
大まかな流れ:
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.推奨されるChatGPTカスタムMCP設定:
Connection: Tunnel
Tunnel: <your OpenAI tunnel>
Authentication: No authenticationMCPサーバーが最終的なサービス資格情報をローカルで管理する場合(たとえば.envを通じて)、No authenticationを使用します。
ChatGPT完全セットアップガイド:
Xアカウントの再認証
X Developerでアプリを設定します:
OAuth 2.0: Enabled
App permissions: Read and write
Callback URI: http://127.0.0.1:3002/callback
Website URL: http://127.0.0.1:3002実行:
$env:X_OAUTH_CLIENT_ID = "<OAuth 2.0 Client ID>"
$env:X_MCP_ACCOUNT = "fcbnews2026"
npm run x:oauth目的のXアカウントにログインした状態で生成されたURLを開きます。承認後、ヘルパーは選択したアカウントトークンで.envを更新します。
再認証後、MCPサーバーを再起動します:
npm run dev:http次に、以下で確認します:
x_get_active_account詳細なOAuthガイド:
安全モデル
サーバーはデフォルトで読み取り専用モードで起動します:
X_MCP_MODE=read-only書き込みツールには以下が必要です:
X_MCP_MODE=read-write公開前:
x_get_active_accountでアクティブなアカウントを確認する。公開する正確なテキストを確認する。
Xトークンが
tweet.writeを持っていることを確認する。エージェントに生成された
post_idを返すように依頼する。XがIDを返すまで、投稿が公開されたと見なさない。
スクリプト
スクリプト | 目的 |
|
|
| ローカルHTTP上でMCPサーバーを起動します。 |
| ローカルX OAuth認可ヘルパーを実行します。 |
| TypeScriptを |
| コンパイル済みサーバーを |
| コンパイル済みサーバーをHTTP上で起動します。 |
| ファイルを出力せずにTypeScriptを実行します。 |
| Vitestテストスイートを実行します。 |
ドキュメント
docs/project-architecture.md: プロジェクトアーキテクチャ。
docs/configuration.md: 環境変数と複数アカウント設定。
docs/local-server-lifecycle.md: ローカルMCPサーバーの起動、停止、自動化。
docs/tools.md: MCPツールと使用契約。
docs/x-oauth.md: X OAuth再認証。
docs/development.md: 開発、テスト、変更に関するガイドライン。
docs/chatgpt-mcp-setup.md: ステップバイステップのChatGPT MCPセットアップ。
運用上のセキュリティ
認証情報をGitの管理外に保持する。
デフォルトモードを
read-onlyに保つ。管理されたワークフローの場合のみ
read-writeを有効にする。公開前にアクティブなアカウントを確認する。
アクセストークンやリフレッシュトークンをログに記録しない。
トークンをチャット、イシュー、ドキュメント、プルリクエストに貼り付けない。
共有コンピュータで
read-writeモードの自動起動を実行しない。
ライセンス
オープンソースライセンスはまだ選択されていません。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceAn 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.1550

X API FastMCP Serverofficial
Flicense-qualityFmaintenanceA 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.851- AlicenseAqualityDmaintenanceMCP server for Twitter/X enabling AI agents to search, post, reply, and engage with tweets.14131MIT
- AlicenseBqualityDmaintenanceMCP server for interacting with the X platform (Twitter) via MCP clients like Claude, Cursor AI, and Windsurf AI.20146MIT
Related MCP Connectors
X (formerly Twitter) posts, profiles, and search for AI agents. Free key, self-minted, no signup.
FastMCP server for posting formatted content to X (Twitter) — Tollbooth-monetized, DPYC-native
Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/lluisfont/x-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server