Fix ask mode MCP tool availability after server discovery - #334641
Fix ask mode MCP tool availability after server discovery#334641luotianyiismywife wants to merge 1 commit into
Conversation
When the user references an MCP server in ask mode, the toolReferences in the request are a snapshot taken when the request was parsed. If the MCP server is still discovering its tools at that point, the snapshot contains only the tools registered so far, and any tools discovered later are reported as "disabled by the user" when the model tries to call them (they are not in availableTools). Include all currently registered MCP tools in the ask agent tool filter when the user referenced an MCP server, so availability reflects the live registration state rather than the possibly-stale snapshot. Fixes microsoft#334569
There was a problem hiding this comment.
🟡 Changes recommended
The code fails unused-local checks and exposes tools from unreferenced MCP servers.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes ask-mode MCP availability when discovery completes after request parsing.
Changes:
- Adds live MCP tool filtering for ask mode.
- Adds six unit tests for tool inclusion behavior.
File summaries
| File | Description |
|---|---|
askAgentIntent.ts |
Expands MCP tool availability after discovery. |
askAgentIntent.spec.ts |
Tests ask-mode tool filtering. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
This PR is superseded by #334657 📌 Copilot's review confirmed the concern with the The proper fix is implemented in #334657 (Scope MCP tool availability to referenced servers only), which:
I'll leave this PR open for reference, but #334657 is the recommended one to merge. Happy to close this if preferred. |
|
Closing in favor of #334657 (server-scoped fix). As Copilot's review noted, the |
Description
Fixes #334569 — MCP tool calls intermittently rejected with "disabled by the user" while the cache shows enabled and the server log shows execution.
Root Cause
In ask mode, MCP tools can only enter
availableToolsviarequest.toolReferences(theaskAgentToolFilterinaskAgentIntent.ts). When the user references an MCP server (via the@picker), the toolset is expanded into a static snapshot at request-parse time (chatRequestParser.ts):MCP servers connect and discover their tools asynchronously (observed ~6s in the issue's reproduction: server start →
Discovered 48 tools). If the request is parsed while discovery is still in progress, the snapshot only contains the tools registered up to that point. Tools discovered later are registered in the tools service but never enteravailableTools— the model's calls to them are then rejected with the misleading errorTool ... is currently disabled by the user.Fix
In
askAgentIntent.ts, when the user referenced an MCP server (anytoolReferencesentry starts with themcp_prefix used by MCP tool names), include all currently registered MCP tools in the filter. Availability now reflects the live registration state rather than the possibly-stale request snapshot:Validation
askAgentIntent.spec.tswith 6 unit tests covering:vitest run src/extension/intents/test/node/askAgentIntent.spec.ts).Related