Repository navigation
Description
Description
MCP tools do not participate in the development-mode policy that governs every other tool. mcp-client.ts hand-rolls its own approval predicate instead of routing through the central mode system, and MODE_EXCLUDED_TOOLS only contains built-in tool names so MCP tools slip past mode filtering entirely.
This fails in both directions from a single root cause:
| Mode | Expected | Actual |
|---|---|---|
plan |
Blocked — plan mode is documented as "show tool calls but don't execute" | An alwaysAllow-ed MCP tool executes immediately, with no approval prompt |
headless |
Runs unattended, like execute_bash and the file tools do |
Auto-denied with "Tool execution was denied by the user." — no user is present |
Root cause
source/mcp/mcp-client.ts:444-446 builds its own policy:
const isAutoApproved = this.isToolAutoApproved(toolName, serverName);
const approval: ToolApprovalPolicy = isAutoApproved
? false
: (_args, mode) => mode !== 'auto-accept';isAutoApproved→approval: false→resolveToolApprovalrule CLI crashes if model tries to use a tool that doesn't exist. #3 (boolean short-circuit) returns "no approval" in every mode, includingplan.- Otherwise →
'headless' !== 'auto-accept'→true→ approval required in headless, where no approval handler exists (tool-approval-queue.ts:23defaults to() => false), so the call is silently denied.
Two supporting gaps let this reach the user:
source/tools/tool-manager.ts:42-55—MODE_EXCLUDED_TOOLS.planlists only built-ins (write_file,execute_bash,git_commit, …). MCP tool names are never in it.source/tools/tool-manager.ts:194-203— the plan/headless filter only consultsthis.customTools;if (!meta) return truewaves MCP tools straight through.
Compare source/tools/execute-bash.tsx:179 and source/utils/tool-approval.ts:18 both explicitly special-case headless. MCP was never updated to match.
Environment
- OS: Windows 11 (platform-independent, this is pure policy logic)
- Node version: v22.22.3
- Nanocoder version: 1.30.0 (current
main, tagv1.30.0) - Provider: Any, reproduces regardless of provider
- Model: Any, reproduces regardless of model
Steps to Reproduce
A. Plan mode executes a mutation (no MCP server needed for the unit repro)
- Configure any MCP server in
.mcp.jsonwith a mutating tool in itsalwaysAllowlist the format documented insource/commands/mcp.tsx:66:{ "mcpServers": { "github": { "command": "...", "alwaysAllow": ["create_issue"] } } } - Start nanocoder and switch to plan mode (Shift+Tab).
- Ask the model to do something that calls
create_issue. - The issue is created. No approval prompt appears.
B. Headless denies an ordinary MCP tool
- Configure any MCP server without the tool in
alwaysAllow. - Add a skill with a
subscribe:block onfile.changedwhose subagent uses that MCP tool. - Start the daemon:
nanocoder daemon start. - Touch a watched file.
- The run returns
Tool execution was denied by the user.no user was ever prompted.
Unit-level repro (drop into source/tools/, no MCP server or daemon required):
import test from 'ava';
import {resolveToolApproval} from './approval-policy.js';
// Mirrors exactly what mcp-client.ts:444-446 constructs.
const autoApproved = {approval: false as const};
const ordinary = {approval: (_a: unknown, mode: string) => mode !== 'auto-accept'};
test('plan mode must not execute an alwaysAllow-ed MCP tool', async t => {
t.true(await resolveToolApproval('create_issue', autoApproved, {}, {mode: 'plan'}));
});
test('headless must not require approval for an ordinary MCP tool', async t => {
t.false(await resolveToolApproval('create_issue', ordinary as any, {}, {mode: 'headless'}));
});Both assertions fail on current main.
Expected Behavior
- Plan mode: no MCP tool that mutates state is reachable, and no
alwaysAllowentry can override that. Plan mode is the safety mode users switch into precisely to inspect an untrusted model's intentions without side effects. - Headless mode: MCP tools behave like
execute_bashand the file tools they run unattended, since headless exists specifically for daemon-triggered runs with no foreground prompt available.
Actual Behavior
- Plan mode:
alwaysAllow-ed MCP tools execute silently. The documented contract ("Show tool calls but don't execute") is violated with no warning to the user. - Headless mode: ordinary MCP tools are denied with a message claiming a user declined, when no user was present. Any triggered skill that depends on MCP silently fails, and the error message actively misdirects debugging.
Logs/Screenshots
Output from the unit repro above against v1.30.0:
✔ PLAN MODE: alwaysAllow-ed MCP tool executes with NO approval
✘ [fail]: HEADLESS: ordinary MCP tool is auto-DENIED
Value is not `false`:
true
Additional Context
Suggested fix make MCP entries first-class participants in the existing policy rather than special-casing them:
- Have
getToolEntries()returnreadOnlyalongsideapproval, derived from the MCP tool's own annotations (readOnlyHintwhere the server provides it), soresolveToolApprovalrule Feature Request: Include files as context in messages using@syntax #5 works for MCP the way it already does for built-ins. - Replace the hand-rolled predicate with the shared helper, so
headlessis handled once:mode !== 'auto-accept' && mode !== 'headless'matchingcreateFileToolApprovalinsource/utils/tool-approval.ts:18. - Make plan-mode filtering in
tool-manager.tsdeny-by-default for any non-read-only tool instead of enumerating built-in names, so future tool sources cannot silently inherit this bug. - Consider whether a server-level
alwaysAllowshould be able to override a mode at all currently it short-circuits ahead of every other rule.
Happy to open a PR with the fix plus the regression tests above.
- I have searched existing issues to ensure this is not a duplicate
- I can reproduce this issue consistently
- This issue occurs with the latest version of nanocoder
Activity
addyCooks commentedon Aug 27, 2026
Hey @akramcodez !
I’ve already started going through this issue and looking into the policy flow
I’d be happy to take it up and work on the fix.
fix(mcp): route MCP tools through the development-mode policy
Fix: mcp development mode policy (#994)