Grok BotResearchKnowledge managementAI score · 78/100AI-assisted edit · no obvious prompt-injection riskX

Low-Cost X Retrieval via Grok Bot: BDK+MCP Direct vs Webhook+Worker Bridge

Input: research question; Process: Codex calls Grok Bot's built-in X tools via BDK MCP or Cloudflare Worker bridge; Output: structured search results with original post links and summaries

ExperiencedStepsWorkflowPromptTip
Who
Developers and individuals with existing Codex/Agent workflows who want to replace metered X API for X retrieval
You get
Use Grok Bot's 1,000 daily built-in X tool calls to replace pay-per-use X API; author estimates ~$150/month savings at 1,000 reads/day
You need
Grok Bot

Constraints

Requires: Grok Bot account (with Bot creation permission), Cursor account (for BDK login), Node.js ≥22.13, npm; Webhook option additionally requires Cloudflare account and Wrangler. BDK path needs a local persistent Node process; Worker path requires deploying and maintaining a Worker, D1, and callback scripts. Grok Bot quota: 1,000 calls/day, 30 calls/minute built-in X tool usage.

What they did

Bytec99 originally used the X API to supply data for Codex X account operations analysis, at $0.005 per post read (~$5 per 1,000). Seeking to reduce costs, he discovered Grok Bot's built-in X retrieval capability (1,000 daily tool call quota) and explored a path for Codex to call Grok Bot. He first built a Webhook + Cloudflare Worker bridge for task dispatch and result callback, then found Cursor's BDK offers a Grok Bot extension enabling direct MCP connection with simpler configuration. Both paths were verified working.

How it went

Author report: BDK + MCP is lighter for personal use without maintaining a Worker and database; Webhook + Worker provides persistence, task IDs, idempotency, and duplicate protection, suitable when results need to callback to business interfaces. In one Worker path test, querying 'Opus 5.5 video-related posts in last 30 days' took about 162 seconds from submission to result persistence, returning 6 posts with Bot reporting 3 searches used. The ~$150/month savings is an estimate at 1,000 reads/day; actual billing depends on search result counts, duplicates, and extra profile fetches.

Worth knowing

The Bot cannot see the full context of the current Codex chat; each task must include a complete requirements description. The BDK path requires a local persistent Node process that must be restarted if disconnected. The Worker path requires additional maintenance of Cloudflare infrastructure, automation tasks, and callback scripts, and is not inherently more stable than BDK. Grok Bot quota: 1,000 calls/day, 30 calls/minute built-in X tool usage; can connect own X account via plugin to check bookmarks, home, DMs, follower lists. The Bot retains its own session, memory, and tools, but Codex cannot read the Bot's full chat history. No third-party independent verification provided; not tested by this site.

Steps

  1. Install BDK and log in

    Run global install in terminal, pinning to the version tested in this article (0.2.28). Then log into your Cursor account and verify identity, confirming this account owns the target Grok Bot.

    Execution prompt · Source text。Terminal commands; install BDK, log in, and verify identity

    npm install -g @cursor/[email protected]
    bdk login
    bdk whoami
  2. Initialize the bridge project

    Run the init command in your chosen project directory, using the grokbot-agents template and specifying the Bot name as 'X 研究员'.

    Execution prompt · Source text。Terminal command; create BDK bridge project

    bdk init ./grokbot --template grokbot-agents \
      --var 'agents=X 研究员'
  3. Configure the Bot list

    Open grokbot/bot/extensions/grokbot.ts and modify the config to match your actual Bot name. The name must exactly match the one created in Grok Bot (including spaces), or a new empty Bot may be created instead of reusing memory.

    Execution prompt · Source text。grokbot/bot/extensions/grokbot.ts file content

    import cursorGrokBotAgents from "@cursor/bdk/extensions/cursor-grokbot-agents";
    
    export default cursorGrokBotAgents({
      agents: ["X 研究员"],
    });
  4. Start the local MCP service

    Start the service from the parent directory of the project, keeping the process running. Single mode listens on 127.0.0.1:43127; MCP endpoint is http://127.0.0.1:43127/v1/mcp.

    Execution prompt · Source text。Terminal command; start local MCP service

    bdk serve --dir ./grokbot --mode single \
      --port 43127 --host 127.0.0.1
  5. Connect MCP to Codex

    For temporary use, start Codex with the -c flag; to save configuration, use codex mcp add. After configuration, verify that tools appear.

    Execution prompt · Source text。Terminal commands; persistently add MCP and verify

    codex mcp add grokbot --url http://127.0.0.1:43127/v1/mcp
    codex mcp get grokbot

    Execution prompt · Source text。Terminal command; temporarily start Codex with MCP specified

    codex -c 'mcp_servers.grokbot.url="http://127.0.0.1:43127/v1/mcp"'
  6. Test query

    Send a research task to 'X 研究员' via MCP. The Bot cannot see the full context of your current Codex chat, so write the task description completely.

    Execution prompt · Source text。Codex chat input; send to Bot via grokbot__ask or top-level call_tool

    通过 grokbot MCP 联系「X 研究员」
    调用方是 Codex,我正在找中文 AI 工具的真实使用案例
    请用内置 X 工具搜索最近 7 天的 Claude Code 使用体验,最多执行 2 次搜索,返回最多 3 条相关帖子
    保留原帖链接、作者、发布时间、简短摘录,以及实际取得的互动数据;不知道的填 null
    区分作者自述和已核实事实
    只查询,不发布或互动
  7. Create Bot and Webhook automation task

    In Grok Bot, create 'X 研究员' with the system prompt, then create a Webhook-triggered automation task named '按需检索 X'.

    Execution prompt · Source text。Grok Bot 'X 研究员' system prompt

    你负责通过内置 X 工具查询公开信息
    收到任务后,遵守关键词、时间范围和数量要求,保留原帖链接、作者、发布时间、短摘录和获取时间
    区分原文、自己的总结和作者自述
    拿不到的数据填 null,不猜测
    默认只读,不发布、回复、点赞、关注或私信
    先确认你是否能使用内置 X 搜索工具,暂不执行搜索

    Execution prompt · Source text。Grok Bot chat input; create Webhook automation task

    请为「X 研究员」创建一个 Webhook 触发的自动化任务,名称为「按需检索 X」
    触发后读取请求正文中的 task_id,再按之后提供的任务领取和回传协议执行
    先不要设置定时任务,也不要开始真实搜索
    告诉我在哪里查看这个自动化任务的真实 Webhook URL 和鉴权配置
    回传地址尚未配置时,明确等待配置,不要声称已经接通
  8. Deploy Cloudflare Worker bridge

    Configure Worker, D1, and callback protocol based on the example repo. Use Wrangler to log in, create database, apply migrations, set Secrets, and deploy.

    Execution prompt · Source text。Full configuration instruction for Codex/Agent; deploy Worker bridge based on GitHub example repo

    请基于示例仓库 https://github.com/bytec-ai/grok-x-bridge-example,配置一个 Codex → Cloudflare Worker → Grok Bot Webhook → X 检索 → 回传结果的桥接服务
    
    我会提供已有 Grok Bot 自动化任务的真实 Webhook 地址和鉴权配置;凭据用受保护文件或 Secrets 保存,不写进代码和日志
    
    使用 Wrangler:先核对 Cloudflare 登录态,未登录时引导我完成浏览器授权,再创建独立 Worker 和 D1,不覆盖已有服务
    
    实现提交任务、领取任务、回传结果、按编号查询四个接口
    每个任务有唯一编号和提交幂等键;首次只允许一个活动任务
    领取成功才搜索,相同任务不能重复执行;Webhook 超时标记结果未知,不盲目重发
    回传凭证限定单次任务,管理凭据和回传凭据分开
    
    生成本地 CLI、任务输入示例、结果 JSON Schema,以及 Grok Bot 可运行的 Python 领取和回传脚本
    结果保留原帖链接、作者、时间、摘录、摘要和真实指标;未知值填 null
    对任务身份、重复帖子、URL 与 ID、结果数量做校验
    
    部署后提供可粘贴到已有自动化任务的准确操作说明,保留原 Webhook,不新建重复自动化任务
    先验鉴权、重复提交和领取竞争,再做不搜索的握手
    最后执行最多 2 次搜索、最多 3 条结果的真实查询,确认回传入库且 CLI 能读回
    保存任务编号、原始结果和验收记录,明确未验证的范围
    不要自动创建定时任务或发布 X 内容
  9. Configure Bot task claiming and result callback

    After Worker deployment, generate an integration guide (containing Worker address, Python script usage, result format) and configure it into the existing '按需检索 X' automation task. Update rather than recreate to avoid changing the Webhook URL.

    Execution prompt · Source text。Grok Bot chat input; update existing automation task with integration guide

    请按下面的接入说明,更新已有的「按需检索 X」Webhook 自动化任务
    保留现有 Webhook 地址,把领取任务、执行搜索和回传结果的流程配置进去
    使用说明中固定的 Worker 地址、辅助脚本和结果格式
    领取成功后才开始搜索;收到 saved: true 后才报告结果已保存
    下面是 Codex 根据实际部署生成的接入说明:
    【粘贴接入说明】
  10. Handshake and real search verification

    First run handshake to verify claiming and callback链路, then submit a real query. Use CLI to read task status and results.

    Execution prompt · Source text。Terminal commands; run verification in Worker bridge project directory

    # 不搜索,只验领取和回传
    node --use-env-proxy scripts/bridge.mjs handshake
    
    # 提交真实查询,任务文件需要先准备
    node --use-env-proxy scripts/bridge.mjs submit examples/search.json
    
    # 只读取原任务,不重新搜索
    node --use-env-proxy scripts/bridge.mjs get TASK_ID
    node --use-env-proxy scripts/bridge.mjs wait TASK_ID --seconds 300

Prompt you can copy

Reference prompt · Editorial suggestion。Confirm the destination, input variables and output format before use.

This block is the prompt. Ads are never placed here.

No prompt needed — just follow the steps.

If choosing the Webhook path, replace this prompt with the bridge repo configuration instruction (sourcePrompt[7]) and include the repo link https://github.com/bytec-ai/grok-x-bridge-example

Source

(中文)Codex→BDK MCP→Grok Bot「X 研究员」:系统提示词+Webhook 例程+桥接示例仓 · Bytec99 · X · 2026-10-24T05:21:13.000Z

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related