Skip to main content

A self-hosted MCP lets chat apps search X through a Grok Bot webhook routine

GitHubGitHubmarciob2026-11-26

Code and reposSource read in fullRead first
GitHubGitHubmarciob2026-11-26

Open original

Overview

Someone who already has Grok Bot and its X connector can run this Node server so ChatGPT, Claude or Gemini can search X without an X API key, if they can expose HTTPS on port 443.

Workflow

  1. What it is: A self-hosted MCP server that lets ChatGPT, Claude or Gemini search X through the owner's Grok Bot. The README presents it as a way to use the X connector the owner already pays for, with no X API account and no extra cost beyond the Grok Bot plan. It uses only Node.js 22, has no npm dependencies, and includes its own OAuth server so those chat apps can connect with no client ID.
  2. Grok Bot parts used: A webhook routine plus an x_search skill that calls the Bot's X connector; an optional x_video skill uses watchVideo. The chat app calls x_search on this server; the server POSTs the search to the routine webhook; the routine runs the skill; the routine POSTs posts back to <PUBLIC_URL>/callback with a one-time token; the server returns them to the chat app. Optional x_video (off by default, ENABLE_X_VIDEO=1) has the routine fetch a post, download its MP4 (up to 720p) to the Bot's computer, and hand it to watchVideo. The webhook URL and key do not change when that skill is added. Not part of Grok Bot: the Node MCP server you run on your own machine or VPS, its OAuth approval page, and the public HTTPS proxy or tunnel (Tailscale Funnel or cloudflared are cited as free options). Grok Bot has no API for X search; only the Bot model can call the connector, which is why the webhook routine is the way in. No x.ai/bot/... template link is in the repo.
  3. You need: A Grok Bot plan with the X connector (the README says Grok Bot comes with X Premium, Super and Ultra), a machine that stays on with Node.js 22 or later, a public HTTPS address on port 443, and a chat app plan that allows custom MCP connectors. A Grok Bot routine reaches only port 443; another port fails with a TLS error and no result arrives. You do not need a database, an X API key, or a GitHub or Google app. Optional: a VPS if you do not want to keep your own computer on.
  4. Install: Clone the repo, set PUBLIC_URL, paste a generated setup prompt into a normal Grok Bot chat, store the webhook, put HTTPS in front of 127.0.0.1:7815, then test and add the connector.
    • Step 1: Clone the repo, enter it, and set PUBLIC_URL. The path of PUBLIC_URL is random and is the MCP endpoint; keep it.

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)"

  • Step 2: Run node bin/grok-x-mcp.mjs setup-prompt, copy the printed text, and paste it into a normal chat with the Grok Bot in the app. The Bot makes the skill x_search and the routine x_search webhook. Do not send that text through a routine or automation: a routine run cannot make another routine. Then open the routine in the Grok Bot desktop app and copy the Webhook POST to URL and the key. If PUBLIC_URL changes, run setup-prompt again and give the new text to the Bot. The generated prompt is printed by the CLI and is not stored as a file in the repository, so it is not copied here.
  • Step 3: mkdir -p ~/.grok-x-mcp && chmod 700 ~/.grok-x-mcp, store the key in ~/.grok-x-mcp/routine.key with mode 600, and export GROK_ROUTINE_URL and GROK_ROUTINE_KEY_FILE.
  • Step 4: The server listens on 127.0.0.1:7815. Put an HTTPS proxy or tunnel in front, on port 443, including the route and paths under it (/callback, /oauth/) and the /.well-known/ OAuth routes listed in the README. With Tailscale Funnel the README shows tailscale funnel --bg --set-path /<route> http://127.0.0.1:7815/<route> for each path; with cloudflared or Caddy, send the whole host to http://127.0.0.1:7815.
  • Step 5: node bin/grok-x-mcp.mjs test "from:xai" runs one real search through the routine; then node bin/grok-x-mcp.mjs serve. In the chat app, add a custom connector with PUBLIC_URL, enter the approval secret from ~/.grok-x-mcp/approval.secret, and try a search.
  1. After install: A search from the chat app takes 20 to 40 seconds; a slower job returns a req_id to poll again. Each post can include media type, size, a direct URL and alt text (none when there is none). With images: true, up to 4 photos or video posters are attached, at most 1 MB each and 3 MB in total. Optional x_video returns what a video shows, on-screen text, a speech transcript and other sound; a question asks for one thing in the video. Nothing in x_video runs on your machine. MAX_SEARCHES_PER_HOUR defaults to 60 (1 to 200) as a cap on routine runs.
  2. Did the author run it: The repository has no separate run-record files. The README reports that one video reading took 103 seconds for an 18-second video, with the Bot asleep at the start (author's claim, not reproduced). test is said to print the first posts and the time. npm test uses a fake routine and needs no Grok Bot and no network.

Key points and results

  • Maturity: At fetch time on 2026-11-28 the repo was created 2026-11-26T03:27:02Z, last pushed 2026-11-27T01:08:21Z, with 6 commits, 1 star, 0 forks, 0 open issues or PRs, and an MIT license. There is no Grok Bot template link, and no Grok Bot skill or routine files were in the extracted repo files; the setup prompt is generated by the CLI.
  • Permissions and boundaries: The routine sends results only to a callback that starts with your PUBLIC_URL; each search uses a one-time token (the server stores a SHA-256 digest and forgets it after 15 minutes); requests expire (5 minutes, or 10 for a video reading); chat apps must pass an approval page that asks for an approval secret; access tokens last 1 hour. The log is one line per request with no content, tokens or secrets. The README tells owners not to share the server, resell results, or use it for bulk collection, citing the xAI Acceptable Use Policy language on scraping and circumventing rate limits.
  • Known limits: Each search is one routine run and spends Grok Bot plan usage; a routine runs at most 200 times an hour, and all routines together at most 300, per the docs the README cites. The X connector instructions, as relayed from the Bot, give 30 calls a minute, 1,000 a day (reset at 00:00 UTC), and at most 25 posts a call; the README says those numbers are not from a public page and can change. min_retweets and min_replies do not work; min_faves is applied after the result. watchVideo is not documented by xAI; its model, limits and cost are unknown, and its reading should be treated as a reading, not as fact. Video reading is slower and costs more plan usage than a search.
  • Worth borrowing: Keep the webhook callback locked to your own public URL and use one-time tokens rather than sending post text as instructions. This is stated in the README security model.
  • Worth borrowing: Generate the skill and routine from a normal chat, not from a routine run, because a routine cannot create another routine. From the setup steps in the README.
  • Worth borrowing: Put a running commit or request-id style check aside; here, require port 443 because a Grok Bot routine cannot reach another port. From the install notes in the README.

Source

Platform
GitHub
Author
marciob
Published
Categories
Code and repos

What this evidence label means

Source read in full

We read the source (post, article or transcript). That only means the original was read. It does not mean this site reproduced the author's results.

Read the editorial and evidence policy

Other cases in this scenario

This unofficial community project is independent of xAI. xAI has neither approved nor endorsed it. No sign-up. The methods and figures come from the original authors.