Files
context-mode/configs/cursor/hooks.json
T
Mert Koseoglu 7dc26dd4a8 feat(cursor): route external MCP tools through PreToolUse (closes #529 partial — cursor)
Extends PR #532's external-MCP routing protection to Cursor. Adds
`MCP:(?!ctx_)` to the preToolUse matcher (Cursor's MCP wire shape is
`MCP:<tool>`, with own tools at `MCP:ctx_*` — verified via
tests/fixtures/cursor/pretooluse-mcp.json and hooks/cursor/posttooluse.mjs).

Also extends `routing.mjs` `isExternalMcpTool` to recognise the `MCP:` prefix
shape so the routing branch returns external-MCP guidance instead of silently
passing through. The shared detection function now classifies Cursor `MCP:*`,
Claude `mcp__*`, and Kiro `@*/` tools uniformly.

- src/adapters/cursor/hooks.ts: export EXTERNAL_MCP_MATCHER_PATTERN, append to PRE_TOOL_USE_MATCHERS
- hooks/core/routing.mjs: extend isExternalMcpTool to detect `MCP:` (cursor) prefix
- configs/cursor/hooks.json, hooks/cursor/hooks.json: mirror runtime matcher
- tests/adapters/cursor-external-mcp-routing.test.ts: 6-test vertical slice covering matcher regex, adapter config, and routing.mjs integration
2026-05-12 13:19:45 +03:00

22 lines
479 B
JSON

{
"version": 1,
"hooks": {
"preToolUse": [
{
"command": "context-mode hook cursor pretooluse",
"matcher": "Shell|Read|Grep|WebFetch|mcp_web_fetch|mcp_fetch_tool|Task|MCP:ctx_execute|MCP:ctx_execute_file|MCP:ctx_batch_execute|MCP:(?!ctx_)"
}
],
"postToolUse": [
{
"command": "context-mode hook cursor posttooluse"
}
],
"stop": [
{
"command": "context-mode hook cursor stop"
}
]
}
}