You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MCP] Newly added tools not included in subsequent completion calls #261611
Does this issue occur when all extensions are disabled?: Yes/No
VS Code Version:
1.104.0 (Insider)
OS Version:
Windows 11
Steps to Reproduce:
Create an MCP server that can update its tools dynamically.
For example, the server starts with 3 tools: "greet", "calculate", and "get-status".
After calling any of these tools, a new tool is added — for example, "followup".
Add the MCP server to your workspace.
Run this prompt:
Greet Lukasz and then do a follow-up
Check the debug logs.
On the second completion call, you’ll see that only the original 3 tools are included, even though all 4 tools were discovered.
changed the title [-][MCP] Tools list is not updated on the next completion call[/-][+][MCP] Newly added tools not included in subsequent completion calls[/+]on Aug 14, 2025
My guess is this is just a race condition on your device since this scenario works in other cases. We need to make sure that the tool list change notification is received and processed, and that new tools are retrieved, before the next agent turn happens.
Connor Peet (@connor4312) This might be a race condition, but I'm able to reproduce it consistently. Would you have some time to investigate this further?
I'm going to add logic such that if the tool list changed notification is received before the response to the tool call, we'll wait for the tools to refresh before proceeding.
Note that this is going to be inherently hit-and-miss (and often miss) with HTTP MCP servers that deliver out-of-bounds notifications, like the example server, because the notification for the tool list changed is sent on the separate streamable HTTP endpoint from the one the tool call request is sent to. There is nothing we can do about this aside from adding some arbitrary delay to tool calls in hopes that we might get a changed notifications. I'm not going to implement that and would instead suggest (for now) that servers that need this case add some short delay if they have a tool call that is expected to enable additional tools, or deliver it as part of a response stream from the tool call.
the important detail here is sending the "tools changed" event to the client before the completion of the tool that triggered it. Doing so seems to work.
Activity
[-][MCP] Tools list is not updated on the next completion call[/-][+][MCP] Newly added tools not included in subsequent completion calls[/+]connor4312 commentedon Aug 14, 2025
Please share some repro code, thanks
lukasz-zoglowek commentedon Aug 14, 2025
Sure here is the sample server I used: https://github.com/lukasz-zoglowek/dynamic-mcp-server/blob/main/src/index.js
lukasz-zoglowek commentedon Aug 22, 2025
Connor Peet (@connor4312) did you have a chance to repro the issue?
connor4312 commentedon Aug 22, 2025
My guess is this is just a race condition on your device since this scenario works in other cases. We need to make sure that the tool list change notification is received and processed, and that new tools are retrieved, before the next agent turn happens.
lukasz-zoglowek commentedon Sep 11, 2025
Connor Peet (@connor4312) This might be a race condition, but I'm able to reproduce it consistently. Would you have some time to investigate this further?
connor4312 commentedon Sep 23, 2025
I'm going to add logic such that if the tool list changed notification is received before the response to the tool call, we'll wait for the tools to refresh before proceeding.
TylerLeonhardt commentedon Sep 23, 2025
I can probably validate this using our playwright vscode MCP server when a change comes around since I saw it there as well
connor4312 commentedon Sep 23, 2025
Note that this is going to be inherently hit-and-miss (and often miss) with HTTP MCP servers that deliver out-of-bounds notifications, like the example server, because the notification for the tool list changed is sent on the separate streamable HTTP endpoint from the one the tool call request is sent to. There is nothing we can do about this aside from adding some arbitrary delay to tool calls in hopes that we might get a changed notifications. I'm not going to implement that and would instead suggest (for now) that servers that need this case add some short delay if they have a tool call that is expected to enable additional tools, or deliver it as part of a response stream from the tool call.
mcp: ensure tool refresh finishes after dynamic tool call
mcp: ensure tool refresh finishes after dynamic tool call (#268025)
TylerLeonhardt commentedon Oct 1, 2025
the important detail here is sending the "tools changed" event to the client before the completion of the tool that triggered it. Doing so seems to work.