Skip to content

chore: use the mcp for codex to search#66

Open
joeldierkes wants to merge 2 commits intomainfrom
chore/use-mcp-for-code
Open

chore: use the mcp for codex to search#66
joeldierkes wants to merge 2 commits intomainfrom
chore/use-mcp-for-code

Conversation

@joeldierkes
Copy link
Contributor

@joeldierkes joeldierkes commented Dec 3, 2025

Codex is sandboxed so hard that the cli tool needs a manual approval
every time. Let's use the mcp to bypass that.


Note

Adds an MCP server exposing a semantic search tool and updates Codex/Droid installers to register mgrep via MCP.

  • MCP Server (src/commands/watch_mcp.ts)
    • Add MCP server command with --expose-tools option.
    • Implement search tool (ListTools + CallTool) to run semantic search scoped to a path and return formatted results.
    • Background sync continues via startWatch.
  • Installers
    • Codex (src/install/codex.ts): Register mgrep via codex mcp add mgrep -- mgrep mcp --expose-tools; simplify SKILL text; improve install/uninstall cleanup and messaging.
    • Droid (src/install/droid.ts): Replace hook-based setup with droid mcp add/remove mgrep; remove Python hook management; keep skill file install; add exec utilities.
  • Search CLI (src/commands/search.ts)
    • Export formatSearchResponse for reuse by MCP.

Written by Cursor Bugbot for commit 07c5b9c. This will update automatically on new commits. Configure here.

Codex is sandboxed so hard that the cli tool needs a manual approval
every time. Let's use the mcp to bypass that.
default: 10,
},
},
required: ["path"],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing required query parameter in search tool schema

The MCP search tool schema marks only path as required but not query. When clients call the search tool without providing a query parameter, args?.query as string evaluates to undefined and gets passed to store.search(), resulting in a search with an undefined query. The query field is the essential search term and must be included in the required array.

Fix in Cursor Fix in Web

? (args?.path as string)
: normalize(join(process.cwd(), (args?.path as string) ?? ""));

const store = await createStore();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Interactive prompts corrupt MCP server communication stream

When createStore() is called from the MCP tool handler, it invokes ensureAuthenticated() which may trigger interactive prompts via @clack/prompts if the user isn't authenticated. Since the MCP server uses stdin/stdout for JSON-RPC communication via StdioServerTransport, these interactive prompts would corrupt the protocol stream, causing the MCP connection to break or behave unexpectedly.

Fix in Cursor Fix in Web

hookConfig,
);
saveSettings(settingsPath, settings as Record<string, unknown>);
await execAsync("droid mcp add mgrep -- mgrep mcp", {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Droid installation missing --expose-tools flag for MCP

The droid installation command droid mcp add mgrep -- mgrep mcp is missing the --expose-tools flag that the codex installation includes. Without this flag, exposeTools defaults to false, causing the ListToolsRequestSchema handler to return an empty tools array. This means the search tool won't be available through the MCP server when installed via droid, contradicting the PR's purpose of exposing search tools.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant