Skip to content

Comments

fix: MCP tool auto-approval fails when fetchToolsList() hasn't completed#11591

Closed
daniel-lxs wants to merge 1 commit intomainfrom
fix/mcp-tool-auto-approval-race-condition
Closed

fix: MCP tool auto-approval fails when fetchToolsList() hasn't completed#11591
daniel-lxs wants to merge 1 commit intomainfrom
fix/mcp-tool-auto-approval-race-condition

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Feb 19, 2026

Summary

  • MCP tool calls get stuck waiting for user approval despite autoApprovalEnabled, alwaysAllowMcp, and server-level alwaysAllow: ["*"] all being configured. Root cause: isMcpToolAlwaysAllowed checks tool.alwaysAllow on each tool object, but that flag is only set when fetchToolsList() completes — which reads the config file from disk, calls tools/list on the MCP server, and maps alwaysAllow onto each tool. If a task's auto-approval check runs before fetchToolsList() finishes, server.tools is empty and the check returns false.
  • The server's config JSON (server.config) already contains the alwaysAllow array at connection creation time (set via BaseConfigSchema Zod validation before fetchToolsList() is even called). This fix adds a fallback that parses server.config when the tool-level flag isn't set, supporting both "*" wildcard and specific tool name matching.

Test plan

  • New unit tests for isMcpToolAlwaysAllowed config fallback (wildcard *, specific tool name, no match, empty array, missing field, invalid JSON, unlisted tool with wildcard)
  • All existing auto-approval tests pass (44 tests across 3 files)
  • Manual verification in Cloud worker: confirm MCP tool calls auto-approve without user intervention

🤖 Generated with Claude Code

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Feb 19, 2026
When an MCP tool call is auto-approval checked before fetchToolsList()
has completed, server.tools is empty so tool.alwaysAllow is never found.
The server's config JSON (set at connection creation time) already
contains the alwaysAllow array, so fall back to parsing server.config
when the tool-level flag isn't set. Supports both wildcard ("*") and
specific tool name matching.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@daniel-lxs daniel-lxs force-pushed the fix/mcp-tool-auto-approval-race-condition branch from ef31602 to 0bd9857 Compare February 19, 2026 04:13
@daniel-lxs daniel-lxs changed the title fix: MCP tool calls not auto-approved due to race condition fix: MCP tool auto-approval fails when fetchToolsList() hasn't completed Feb 19, 2026
@daniel-lxs daniel-lxs closed this Feb 19, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant