Skip to content

feat(mcp): refresh a server's tools on notifications/tools/list_changed #13632

Description

@glmn

What would you like to be added?

Handle notifications/tools/list_changed from MCP servers during an interactive session: when a connected server sends it, re-run tools/list for that server and replace its tools in the session's tool registry (the same remove-then-register step SessionMcpView.applyTools already does after a restart).

Today nothing in the CLI path listens for it (checked on main at 2a69a2f and on 0.24.5). connectToMcpServer (packages/core/src/tools/mcp-client.ts) registers only the roots capability. The toolsChanged pool event in mcp-pool-entry.ts is emitted on restart/reconnect, but not when a server sends the notification. The only way to pick up new tools is /mcp → reconnect or restarting the CLI.

Why is this needed?

MCP servers that change their tools at runtime rely on this notification. The spec has had it since 2024-11-05, and Claude Code, Gemini CLI and OpenCode re-list on it. Some examples: a server that only exposes tools after login, or a server that enables tools based on workspace state.

Our case: NeuroSquad, a desktop app, runs Qwen Code as one of several agents. Its MCP server grants tools when the user connects the agent to a new resource mid-session (a terminal, a browser, a note), and sends tools/list_changed. With Qwen Code the new tools only show up after the session restarts. We verified this live on 0.24.5: a note's note_* tools were missing from the request until a restart and present after it.

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category/toolsTool integration and executionpriority/P2Medium - Moderately impactful, noticeable problemscope/mcpModel Context Protocoltype/feature-requestNew feature or enhancement request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions