Index Codex MCP

Index Codex MCP

An MCP server that allows Pebble Index to capture notes, enqueue tasks, create follow-ups, and launch visible Codex threads on a Windows PC. It uses a remote server with token-based access and a local runner that executes only explicit execution requests.

Category
访问服务器

README

Index Codex MCP

A self-hosted MCP server that lets a Pebble Index capture notes, queue work, create follow-ups, and open visible Codex threads on your Windows PC.

The cloud server stores requests. It cannot run code. A local runner on your PC claims only explicit execution requests, resolves project names through a private local registry, and opens each request as a visible Codex thread.

[!WARNING] This project can start unattended coding work on your computer. Read the security model, register only folders you trust, and keep the runner's Codex sandbox enabled.

How it works

flowchart LR
    I["Pebble Index"] -->|"Bearer token + MCP"| S["Remote MCP server"]
    C["Codex client"] -->|"Separate bearer token + MCP"| S
    S --> D["Postgres"]
    R["Local Windows runner"] -->|"Poll and update tasks"| S
    R -->|"thread/start + turn/start"| A["Codex App Server"]
    A --> W["Registered project worktree or projectless folder"]

The server exposes different tools to Index and Codex. Index can create records but cannot read or update the inbox. Codex can manage the inbox but cannot invoke run_codex_task. The runner uses the Codex token only to claim and update explicit execution requests.

Tools

Tool Index Codex Effect
capture_item Yes Yes Store exact note text and an optional project
enqueue_task Yes Yes Queue work without executing it
create_followup Yes Yes Create an open follow-up
run_codex_task Yes No Request a visible local Codex thread
get_inbox No Yes Read recent captures, active tasks, and open follow-ups
update_task No Yes Claim or update a task through valid state changes
update_followup No Yes Mark a follow-up done or cancelled

enqueue_task always confirms “Queued, not executed.” Only run_codex_task sets the execution-request flag used by the local runner.

Requirements

  • Node.js 24
  • A Postgres database; the included driver targets Neon Serverless Postgres
  • A host for the remote Next.js route; the deployment steps below use Vercel
  • Codex CLI installed and signed in on the Windows PC that runs tasks
  • A Pebble Index with HTTP MCP server support
  • PowerShell 7 for the supplied runner installer

1. Run the MCP server locally

Install dependencies:

npm install

Copy the environment template:

Copy-Item .env.example .env.local

Set these values in .env.local:

Variable Purpose
DATABASE_URL Pooled Postgres connection string
INDEX_MCP_TOKEN Private bearer token used only by Index
CODEX_MCP_TOKEN Different private bearer token used by Codex and the runner
ALLOWED_ORIGINS Comma-separated exact browser origins; leave empty to reject all present origins
APP_BASE_URL Server origin used by the smoke test

Both tokens must contain at least 32 characters. Generate independent random values and never commit them. An authenticated non-browser MCP client may omit Origin; a request that sends Origin must match ALLOWED_ORIGINS exactly.

Apply the migrations and run the development server:

npm run db:migrate
npm run dev

Run the checks in another terminal:

npm run format
npm run typecheck
npm test
npm run build
npm run smoke

The only application route is POST /api/mcp. There is no frontend or public health route.

2. Deploy to Vercel

Install and sign in to the Vercel CLI, then link the project:

vercel link

Add each production variable interactively. Do not include secret values in the command:

vercel env add DATABASE_URL production
vercel env add INDEX_MCP_TOKEN production
vercel env add CODEX_MCP_TOKEN production
vercel env add ALLOWED_ORIGINS production
vercel env add APP_BASE_URL production

Pull the production configuration into the ignored local file, migrate, verify, and deploy:

vercel env pull .env.local --environment=production
npm run db:migrate
npm run format
npm run typecheck
npm test
npm run build
vercel --prod
npm run smoke

If the production origin changes, update APP_BASE_URL before the final smoke test.

3. Connect Pebble Index

In the Pebble app:

  1. Create or select a cloud sandbox group.
  2. Add an HTTP MCP server named Index Codex MCP.
  3. Set the transport to Streamable HTTP.
  4. Set the URL to https://<your-domain>/api/mcp.
  5. Set Authorization to Bearer <INDEX_MCP_TOKEN>.
  6. Connect the server.
  7. Select the exposed index_ops prompt.
  8. Assign the sandbox to your preferred Index gesture.

Example requests:

  • “Capture for Example App: the mobile menu freezes after returning from an event.”
  • “Queue a Codex task for Example App to add completion tracking.”
  • “Run a Codex task for Example App: fix the mobile navigation bug and run the relevant tests.”
  • “Start a new Codex chat with no project: compare two API designs.”
  • “Create a follow-up for Example App due 2026-08-10T15:00:00-06:00 to review the release.”

Due dates must use an explicit ISO 8601 timestamp. The server does not interpret phrases such as “next Thursday.”

4. Connect Codex to the inbox

Store the production Codex token in the Windows user environment without printing it:

$secureToken = Read-Host -AsSecureString "Codex MCP token"
$plainToken = [Net.NetworkCredential]::new("", $secureToken).Password
[Environment]::SetEnvironmentVariable("INDEX_CODEX_MCP_TOKEN", $plainToken, "User")
Remove-Variable secureToken, plainToken

Add the server to your Codex configuration:

[mcp_servers.index_codex]
url = "https://<your-domain>/api/mcp"
bearer_token_env_var = "INDEX_CODEX_MCP_TOKEN"
required = true
default_tools_approval_mode = "writes"
enabled_tools = [
  "capture_item",
  "enqueue_task",
  "create_followup",
  "get_inbox",
  "update_task",
  "update_followup"
]

Restart Codex, then verify the connection:

codex mcp list

5. Configure the visible-thread runner

The runner never accepts a folder path from Index. It maps a spoken project name or alias to an exact path stored only on your PC.

Copy the example registry:

Copy-Item scripts/runner-projects.example.json scripts/runner-projects.json

Edit scripts/runner-projects.json:

[
  {
    "name": "Example App",
    "aliases": ["Example", "My app"],
    "path": "C:\\projects\\example-app",
    "worktree": true
  }
]

Each name and alias must be unique after case and punctuation normalization.

  • Set worktree to true for a Git repository. The runner creates codex/ring-<task-id> from the repository's current HEAD and leaves the worktree for review.
  • Set worktree to false only when Codex should work in that exact folder.
  • Omit the project in a ring request to create a new projectless folder under the configured projectless root.

The real registry is ignored by Git so local project names and paths do not enter commits.

Set the runner endpoint for the Windows user:

[Environment]::SetEnvironmentVariable(
  "INDEX_CODEX_MCP_ENDPOINT",
  "https://<your-domain>/api/mcp",
  "User"
)

The runner uses INDEX_CODEX_MCP_TOKEN, which you set in the previous section. Confirm that Codex is signed in:

codex login status

Open a new terminal so it receives the user environment variables. Test the runner without claiming work:

npm run runner:check

Install and start the scheduled task:

npm run runner:install

The Windows Task Scheduler job starts at sign-in and allows only one runner instance. Your computer must remain on, online, and signed in to Codex. Requests remain queued while the runner is offline.

Optional runner variables

Variable Default Purpose
INDEX_CODEX_PROJECTS_FILE scripts/runner-projects.json Private project registry path
INDEX_CODEX_CODEX_HOME %USERPROFILE%\.codex Codex state used for visible threads
INDEX_CODEX_WORKTREES_ROOT %USERPROFILE%\.codex\worktrees\index-codex Isolated Git worktrees
INDEX_CODEX_PROJECTLESS_ROOT %USERPROFILE%\Documents\Codex\Index New chats without a project
INDEX_CODEX_CODEX_COMMAND codex Codex executable name or full path

Task lifecycle

Tasks follow these state changes:

  • queuedin_progress or cancelled
  • in_progressblocked, done, or cancelled
  • blockedin_progress or cancelled
  • done and cancelled are final

The runner claims a task with one conditional database update. Two clients cannot claim the same queued task.

Security and privacy

  • Index and Codex use separate bearer tokens and receive different tool sets.
  • Authentication runs before JSON parsing.
  • Requests larger than 64 KiB are rejected.
  • Tool schemas reject unknown fields.
  • All SQL uses parameters.
  • Idempotency keys cannot be reused with different input.
  • Audit rows contain a normalized input hash, outcome, record ID, and timing; they do not contain tool input or credentials.
  • The cloud server cannot execute code.
  • Voice input never becomes a file path or shell command. Only the ignored local project registry contains paths.
  • The runner uses Codex App Server with approvalPolicy: never and sandbox: workspace-write.
  • The runner prompt forbids pushing, deploying, merging, messaging, deletion, and external-system changes.
  • Local workspace paths are not written back to the cloud task record.
  • Projectless requests use a fixed local root, not a caller-provided path.

No secret scanner can prove that arbitrary note text contains no credential. Do not dictate or store secrets.

Troubleshooting

Index cannot connect

  • Confirm the URL ends in /api/mcp.
  • Select Streamable HTTP, not SSE.
  • Use Bearer followed by the Index token.
  • Confirm the deployment has INDEX_MCP_TOKEN and DATABASE_URL.
  • Check Vercel function logs for safe error codes. Logs intentionally omit request input and tokens.

runner:check fails

  • Open a new terminal after setting user environment variables.
  • Confirm INDEX_CODEX_MCP_ENDPOINT uses HTTPS, unless it points to localhost.
  • Confirm INDEX_CODEX_MCP_TOKEN matches the deployed CODEX_MCP_TOKEN.
  • Run codex login status.
  • Confirm every path in runner-projects.json exists.

A task stays queued

  • Confirm the scheduled task Index Codex MCP Runner is running.
  • Run npm run runner:check.
  • Confirm the project name or alias matches the local registry.
  • Check the scheduled-task history or run npm run runner in a terminal for structured event names.

A task becomes blocked

Open the visible Codex thread. If the runner created a Git worktree, inspect the configured worktree root. Failed workspaces remain available for review.

Development

npm run format
npm run typecheck
npm test
npm run build

The test suite covers authentication boundaries, tool visibility, strict input, idempotency, task state changes, project registry resolution, runner task selection, and visible-thread request parameters.

See docs/architecture.md for the runtime design and invariants.

Limits

  • The supplied runner installer supports Windows only.
  • The Codex App Server interface may change; pin and test Codex CLI updates before unattended use.
  • One runner processes one task at a time.
  • The server has no frontend, OAuth provider, search UI, delete tool, or automatic deployment step.
  • Worktrees start from the registered repository's current HEAD; the runner does not fetch or choose a remote branch.

Licence

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选