grok-x-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
grok-x-mcp
Search X (Twitter) from ChatGPT, Claude or Gemini through your own Grok Bot.
You already pay for Grok Bot. Its X connector can search X. This small server lets your chat apps use that search, with no X API account and no extra cost beyond your Grok Bot plan.
It is an MCP server that you run on your own machine or VPS.
It has one tool:
x_search.It has no npm dependencies. It uses only Node.js 22.
It has its own OAuth server, so ChatGPT, Claude and Gemini can connect with no client ID.
How it works
Grok Bot has no API for its X search. Only the model of the Bot can call it. A Grok Bot routine with a webhook trigger is the way in:
Your chat app calls
x_searchon this server.The server POSTs the search to the webhook of your routine.
The routine runs the
x_searchskill of your Bot. The skill calls the X connector of the Bot.The routine POSTs the posts back to this server, at
<PUBLIC_URL>/callback, with a one-time token.The server gives the posts to your chat app.
One search takes 20 to 40 seconds. If it takes longer, the tool gives a req_id, and the chat app asks again.
Each post comes with its media: type, size, direct URL and the author's alt text ("none" when there is none). With images: true, the tool also attaches up to 4 photos (or video posters) as images, at most 1 MB each and 3 MB in total. A photo that fails to download becomes a note, and the text stays.
Related MCP server: grok-mcp-server
What you need
Item | Why |
Grok Bot, with its X connector | It does the search. Grok Bot comes with X Premium, Super and Ultra. |
A machine that stays on, with Node.js 22 or later | It runs the server. A small VPS is the easy choice. Your own computer also works while it is on. |
A public https address on port 443 for that machine | Your chat app and the routine must reach the server. A Grok Bot routine reaches only port 443, so do not use another port. Tailscale Funnel and cloudflared are free, and need no domain. |
A chat app that takes a custom MCP connector | ChatGPT, Claude or Gemini. Check that your plan allows custom connectors. |
You do not need a database, an X API key, or a GitHub or Google app.
Set up
1. Get the code and choose the address
git clone https://github.com/marciob/grok-x-mcp.git
cd grok-x-mcp
export PUBLIC_URL="https://your-host.example/$(node bin/grok-x-mcp.mjs random)"The path of PUBLIC_URL is random. It is the MCP endpoint. Keep it.
2. Make the skill and the routine in Grok Bot
node bin/grok-x-mcp.mjs setup-promptCopy the text that it prints.
Paste it into a normal chat with your Grok Bot, in the app. The Bot makes the skill
x_searchand the routinex_search webhook. Do not send it through a routine or an automation: a routine run cannot make another routine.Open the routine in the Grok Bot desktop app. In the Webhook section, copy the POST to URL and the key.
The routine accepts only a callback that starts with your PUBLIC_URL. If you change PUBLIC_URL, run setup-prompt again and give the new text to the Bot.
3. Store the webhook
mkdir -p ~/.grok-x-mcp && chmod 700 ~/.grok-x-mcp
pbpaste > ~/.grok-x-mcp/routine.key # or paste the key with an editor
chmod 600 ~/.grok-x-mcp/routine.key
export GROK_ROUTINE_URL="https://…" # the POST to URL
export GROK_ROUTINE_KEY_FILE=~/.grok-x-mcp/routine.key4. Put the server online
The server listens on 127.0.0.1:7815. Put an https proxy or a tunnel in front of it. The proxy must send these paths to the server:
the route (the path of
PUBLIC_URL), and all paths under it, which includes/callbackand/oauth//.well-known/oauth-protected-resource<route>/.well-known/oauth-authorization-server<route>/.well-known/openid-configuration<route>
Use port 443. A Grok Bot routine cannot reach another port (such as 8443 or 10000): its POST fails with a TLS error, and no result arrives.
With Tailscale Funnel, for each path above:
tailscale funnel --bg --set-path /<route> http://127.0.0.1:7815/<route>With cloudflared or Caddy, send the whole host to http://127.0.0.1:7815.
5. Test, then run
node bin/grok-x-mcp.mjs test "from:xai" # one real search through your routine
node bin/grok-x-mcp.mjs servetest prints the first posts and the time. If it fails, it says why.
6. Add the connector
In ChatGPT, Claude or Gemini, add a custom connector with the URL
PUBLIC_URL.The app opens the approval page of the server. Enter the approval secret:
cat ~/.grok-x-mcp/approval.secretAsk, for example: "Search X for the latest posts from @xai about Grok Bot."
Configuration
Variable | Required | Default | Meaning |
| yes | Public https address of the MCP endpoint, with a random path. | |
| yes | The webhook URL of your routine. | |
| yes, or | File with the webhook key, mode 600. | |
| no |
| A cap on searches, 1 to 200. |
| no | made in | The secret that the approval page asks for. |
| no | none | A fixed bearer token, for curl. 32 characters or more. |
| no | Gemini, claude.ai, chatgpt.com, localhost | OAuth redirect hosts. |
| no |
| Listen address. |
| no |
| Listen port. |
| no |
| OAuth clients and tokens. |
Search operators
from:user, to:user, @user, "exact phrase", OR, -word, lang:pt, filter:replies, -filter:replies, filter:media, filter:images, filter:videos, filter:links, min_faves:N, within_time:2d, since:YYYY-MM-DD, until:YYYY-MM-DD, since_time:UNIX, until_time:UNIX.
The server changes them to the operators of the X API v2. min_faves is applied to the result, because the v2 search has no likes filter. min_retweets and min_replies do not work.
Limits and cost
Cost. Each search is one routine run, and each run spends usage of your Grok Bot plan. There is no other cost.
Grok Bot routines. A routine runs at most 200 times an hour, and all your routines together at most 300 times an hour (docs).
MAX_SEARCHES_PER_HOURkeeps the server under that.The X connector. The instructions of the connector give 30 calls a minute, 1,000 a day (reset at 00:00 UTC), and at most 25 posts a call. These numbers come from the Bot, not from a public page, and can change.
Speed. 20 to 40 seconds a search.
Use it fairly
This server is for your own searches with your own Grok Bot. Read the xAI Acceptable Use Policy. It forbids, among other things, "Scraping, harvesting or reselling any Input or Output" and "circumventing any rate limits". Do not share your server with other people, do not resell results, and do not use it for bulk collection. Your Grok account is the one at risk.
Security model
The routine checks the callback. It sends results only to an address that starts with your
PUBLIC_URL.One-time tokens. Each search has its own random token in the callback URL. The server keeps only its SHA-256 digest, and forgets it after 15 minutes.
Old requests do nothing. Each request has
expires_at, 5 minutes after it is sent. The routine drops a request after that time.OAuth approval. A chat app must pass the approval page, which asks for the approval secret. Access tokens last 1 hour.
Post text is data. The routine and the skill treat the webhook body and the posts as data, not as instructions.
The log has one line for each request, with no content, tokens or secrets.
Commands
grok-x-mcp setup-prompt # text for your Grok Bot
grok-x-mcp test "<query>" # one real search
grok-x-mcp serve # start the server
grok-x-mcp clients # list the OAuth clients
grok-x-mcp revoke <id> # remove one client and its tokens ("all" for every client)
grok-x-mcp random # a random value for a route or a secretTests
npm testThe tests need no Grok Bot and no network. They use a fake routine.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
X/Twitter search, posts, comments, user profiles, user posts/replies and video transcripts.
Look up users, search and read posts, and publish or delete your own posts in X.
X (formerly Twitter) posts, profiles, and search for AI agents. Free key, self-minted, no signup.
Read public Twitter/X data: tweets, profiles, followers, search. No X developer account.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI assistants to search X posts and read user timelines without API costs, using cookie authentication.2MIT
- AlicenseNot gradedqualityDmaintenanceSearch X (formerly Twitter) in real-time from your AI assistant using xAI's Grok API, with no X API account required.473 npmMIT
- AlicenseAqualityDmaintenanceEnables real-time search of X.com (Twitter) posts, users, threads, and trends via xAI's Grok API, directly from Claude.559 PyPI4MIT
- AlicenseAqualityDmaintenanceEnables searching X (Twitter) posts, discussions, trends, and web content via Grok API using natural language.31MIT