fix(mcp): guide agents through exec discovery - #72403
Conversation
Make CLI-mode capability discovery explicit and return actionable recovery guidance for scope-gated tools. Generated-By: PostHog Code Task-Id: 8f51bdaa-77c5-4d23-bf3d-85fce84aa820
|
Hey @dmarticus! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
|
Reviews (1): Last reviewed commit: "fix(mcp): guide agents through exec disc..." | Re-trigger Greptile |
| } | ||
| const available = tools.map((t) => t.name).join(', ') | ||
| throw new Error(`Unknown tool: "${name}". Available tools: ${available}`) | ||
| const scopeGatedTool = scopeGatedTools.find((candidate) => candidate.name === name) |
skoob13
left a comment
There was a problem hiding this comment.
Trying to understand what happened here, as we're in the the caveman mode for characters in the exec tool. Can you expand a bit on how I can reproduce it?
| **Commands (in order):** | ||
|
|
||
| ```text | ||
| # 1. Find unknown tools |
There was a problem hiding this comment.
These comments were reasoning steps. I'd keep them.
|
|
||
| - If a tool call fails, the error includes a suggestion and similar tool names. Read the suggestion before retrying. | ||
| - If a tool name doesn't exist, run `tools` again to find the correct name. | ||
| - If a tool name doesn't exist, run `search <term>` to find the current name before claiming the capability is unavailable. |
There was a problem hiding this comment.
The changes to the prompt here are a bit confusing. It feels to me like a side effect rather than the root cause. Specifically for this line, what is the behavior you've observed? Does GPT use "list" before search?
|
okay, tried reproducing this in both codex and claude (a friend had reported it to me with codex), but I couldn't reproduce it. I think the changes to services/mcp/src/tools/exec.ts are worth keeping, but I'm not gonna mess with the harness. Thanks for looking! |
Generated-By: PostHog Code Task-Id: 8f51bdaa-77c5-4d23-bf3d-85fce84aa820
Problem
In CLI mode, scope-gated tools can look like unknown tools when called directly through
exec.Why: Authorization failures should explain how to restore MCP access instead of looking like an unsupported capability.
Changes
info,schema, orcalltargets a scope-gated tool.How did you test this code?
pnpm --filter @posthog/mcp exec vitest run tests/unit/exec.test.ts(99 tests passed)pnpm --filter @posthog/mcp typecheckAutomatic notifications
Docs update
Not applicable. This change only improves runtime error guidance.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Codex implemented the runtime recovery behavior using the
/implementing-mcp-toolsand/writing-testsskills. The broader instruction and documentation changes were removed after the issue could not be reproduced.Created with PostHog Code