Skip to content

Add support for MCP tools/list_changed notification#42453

Merged
agu-z merged 5 commits intozed-industries:mainfrom
tsoernes:mcp-tools-list-changed-notification
Dec 16, 2025
Merged

Add support for MCP tools/list_changed notification#42453
agu-z merged 5 commits intozed-industries:mainfrom
tsoernes:mcp-tools-list-changed-notification

Conversation

@tsoernes
Copy link
Contributor

@tsoernes tsoernes commented Nov 11, 2025

Summary

This PR adds support for the MCP (Model Context Protocol) notifications/tools/list_changed notification, enabling dynamic tool discovery when MCP servers add, remove, or modify their available tools at runtime.

Release Notes:

  • Improved: MCP tools are now automatically reloaded when a context server sends a tools/list_changed notification, eliminating the need to restart the server to discover new tools.

Changes

  • Register a notification handler for notifications/tools/list_changed in ContextServerRegistry
  • Automatically reload tools when the notification is received
  • Handler is registered both on initial server startup and when a server transitions to Running status

Motivation

The MCP specification includes a notifications/tools/list_changed notification to inform clients when the list of available tools has changed. Previously, Zed's agent would only load tools once when a context server started. This meant that:

  1. If an MCP server dynamically registered new tools after initialization, they would not be available to the agent
  2. The only way to refresh tools was to restart the entire context server
  3. Tools that were removed or modified would remain in the old state until restart

Implementation Details

The implementation follows these steps:

  1. When a context server transitions to Running status, register a notification handler for notifications/tools/list_changed
  2. The handler captures a weak reference to the ContextServerRegistry entity
  3. When the notification is received, spawn a task that calls reload_tools_for_server with the server ID
  4. The existing reload_tools_for_server method handles fetching the updated tool list and notifying observers

This approach is minimal and reuses existing tool-loading infrastructure.

Testing

  • Code compiles with ./script/clippy -p agent
  • The notification handler infrastructure already exists and is tested in the codebase
  • The reload_tools_for_server method is already tested and working

Benefits

  • Improves developer experience by enabling hot-reloading of MCP tools
  • Aligns with the MCP specification's capability negotiation system
  • No breaking changes to existing functionality
  • Enables more flexible and dynamic MCP server implementations

Related Issues

This implements part of the MCP specification that was already defined in the type system but not wired up to actually handle the notifications.

This commit adds support for the MCP (Model Context Protocol)
notifications/tools/list_changed notification, enabling dynamic tool
discovery when MCP servers add, remove, or modify their available tools.

Changes:
- Register a notification handler for 'notifications/tools/list_changed'
  in ContextServerRegistry
- Automatically reload tools when the notification is received
- Handler is registered both on initial server startup and when a server
  transitions to Running status

This allows the Zed agent to dynamically discover and use new tools from
MCP servers without requiring a server restart, improving the developer
experience and enabling more flexible tool management.
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 11, 2025
@maxdeviant maxdeviant changed the title feat: Add support for MCP tools/list_changed notification Add support for MCP tools/list_changed notification Nov 11, 2025
@SomeoneToIgnore SomeoneToIgnore added the area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features label Nov 14, 2025
@franciskafyi
Copy link
Collaborator

Hey @tsoernes, thank you for this! I'm not so familiar with this – would you be able to share more context / screenshots for how this is done in e.g. Cursor or VS Code or similar? 🙏

@tsoernes
Copy link
Contributor Author

Hey @tsoernes, thank you for this! I'm not so familiar with this – would you be able to share more context / screenshots for how this is done in e.g. Cursor or VS Code or similar? 🙏

https://github.com/microsoft/vscode/blob/2365ea12ec47729ab54e257313180c868d1073a7/src/vs/workbench/contrib/mcp/common/mcpServer.ts#L270

@agu-z agu-z self-assigned this Dec 16, 2025
@agu-z agu-z moved this from Community PRs to In progress in Quality Week – December 2025 Dec 16, 2025
@agu-z
Copy link
Contributor

agu-z commented Dec 16, 2025

@tsoernes Thank you for your contribution! The changes look good overall. I did notice that the existing MCP client didn’t have a way to unregister notification handlers, which meant they could leak when a new agent instance was created. This is now handled by tying the handler’s lifetime to the registry, which is itself scoped to the agent’s lifetime.

@agu-z agu-z enabled auto-merge (squash) December 16, 2025 21:30
@agu-z agu-z merged commit eba811a into zed-industries:main Dec 16, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Quality Week – December 2025 Dec 16, 2025
HactarCE pushed a commit that referenced this pull request Dec 17, 2025
## Summary

This PR adds support for the MCP (Model Context Protocol)
`notifications/tools/list_changed` notification, enabling dynamic tool
discovery when MCP servers add, remove, or modify their available tools
at runtime.

## Release Notes:

- Improved: MCP tools are now automatically reloaded when a context
server sends a `tools/list_changed` notification, eliminating the need
to restart the server to discover new tools.

## Changes

- Register a notification handler for `notifications/tools/list_changed`
in `ContextServerRegistry`
- Automatically reload tools when the notification is received
- Handler is registered both on initial server startup and when a server
transitions to `Running` status

## Motivation

The MCP specification includes a `notifications/tools/list_changed`
notification to inform clients when the list of available tools has
changed. Previously, Zed's agent would only load tools once when a
context server started. This meant that:

1. If an MCP server dynamically registered new tools after
initialization, they would not be available to the agent
2. The only way to refresh tools was to restart the entire context
server
3. Tools that were removed or modified would remain in the old state
until restart

## Implementation Details

The implementation follows these steps:

1. When a context server transitions to `Running` status, register a
notification handler for `notifications/tools/list_changed`
2. The handler captures a weak reference to the `ContextServerRegistry`
entity
3. When the notification is received, spawn a task that calls
`reload_tools_for_server` with the server ID
4. The existing `reload_tools_for_server` method handles fetching the
updated tool list and notifying observers

This approach is minimal and reuses existing tool-loading
infrastructure.

## Testing

- [x] Code compiles with `./script/clippy -p agent`
- The notification handler infrastructure already exists and is tested
in the codebase
- The `reload_tools_for_server` method is already tested and working

## Benefits

- Improves developer experience by enabling hot-reloading of MCP tools
- Aligns with the MCP specification's capability negotiation system
- No breaking changes to existing functionality
- Enables more flexible and dynamic MCP server implementations

## Related Issues

This implements part of the MCP specification that was already defined
in the type system but not wired up to actually handle the
notifications.

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…2453)

## Summary

This PR adds support for the MCP (Model Context Protocol)
`notifications/tools/list_changed` notification, enabling dynamic tool
discovery when MCP servers add, remove, or modify their available tools
at runtime.

## Release Notes:

- Improved: MCP tools are now automatically reloaded when a context
server sends a `tools/list_changed` notification, eliminating the need
to restart the server to discover new tools.

## Changes

- Register a notification handler for `notifications/tools/list_changed`
in `ContextServerRegistry`
- Automatically reload tools when the notification is received
- Handler is registered both on initial server startup and when a server
transitions to `Running` status

## Motivation

The MCP specification includes a `notifications/tools/list_changed`
notification to inform clients when the list of available tools has
changed. Previously, Zed's agent would only load tools once when a
context server started. This meant that:

1. If an MCP server dynamically registered new tools after
initialization, they would not be available to the agent
2. The only way to refresh tools was to restart the entire context
server
3. Tools that were removed or modified would remain in the old state
until restart

## Implementation Details

The implementation follows these steps:

1. When a context server transitions to `Running` status, register a
notification handler for `notifications/tools/list_changed`
2. The handler captures a weak reference to the `ContextServerRegistry`
entity
3. When the notification is received, spawn a task that calls
`reload_tools_for_server` with the server ID
4. The existing `reload_tools_for_server` method handles fetching the
updated tool list and notifying observers

This approach is minimal and reuses existing tool-loading
infrastructure.

## Testing

- [x] Code compiles with `./script/clippy -p agent`
- The notification handler infrastructure already exists and is tested
in the codebase
- The `reload_tools_for_server` method is already tested and working

## Benefits

- Improves developer experience by enabling hot-reloading of MCP tools
- Aligns with the MCP specification's capability negotiation system
- No breaking changes to existing functionality
- Enables more flexible and dynamic MCP server implementations

## Related Issues

This implements part of the MCP specification that was already defined
in the type system but not wired up to actually handle the
notifications.

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Jan 20, 2026
…2453)

## Summary

This PR adds support for the MCP (Model Context Protocol)
`notifications/tools/list_changed` notification, enabling dynamic tool
discovery when MCP servers add, remove, or modify their available tools
at runtime.

## Release Notes:

- Improved: MCP tools are now automatically reloaded when a context
server sends a `tools/list_changed` notification, eliminating the need
to restart the server to discover new tools.

## Changes

- Register a notification handler for `notifications/tools/list_changed`
in `ContextServerRegistry`
- Automatically reload tools when the notification is received
- Handler is registered both on initial server startup and when a server
transitions to `Running` status

## Motivation

The MCP specification includes a `notifications/tools/list_changed`
notification to inform clients when the list of available tools has
changed. Previously, Zed's agent would only load tools once when a
context server started. This meant that:

1. If an MCP server dynamically registered new tools after
initialization, they would not be available to the agent
2. The only way to refresh tools was to restart the entire context
server
3. Tools that were removed or modified would remain in the old state
until restart

## Implementation Details

The implementation follows these steps:

1. When a context server transitions to `Running` status, register a
notification handler for `notifications/tools/list_changed`
2. The handler captures a weak reference to the `ContextServerRegistry`
entity
3. When the notification is received, spawn a task that calls
`reload_tools_for_server` with the server ID
4. The existing `reload_tools_for_server` method handles fetching the
updated tool list and notifying observers

This approach is minimal and reuses existing tool-loading
infrastructure.

## Testing

- [x] Code compiles with `./script/clippy -p agent`
- The notification handler infrastructure already exists and is tested
in the codebase
- The `reload_tools_for_server` method is already tested and working

## Benefits

- Improves developer experience by enabling hot-reloading of MCP tools
- Aligns with the MCP specification's capability negotiation system
- No breaking changes to existing functionality
- Enables more flexible and dynamic MCP server implementations

## Related Issues

This implements part of the MCP specification that was already defined
in the type system but not wired up to actually handle the
notifications.

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
LivioGama pushed a commit to LivioGama/zed that referenced this pull request Feb 15, 2026
…2453)

## Summary

This PR adds support for the MCP (Model Context Protocol)
`notifications/tools/list_changed` notification, enabling dynamic tool
discovery when MCP servers add, remove, or modify their available tools
at runtime.

## Release Notes:

- Improved: MCP tools are now automatically reloaded when a context
server sends a `tools/list_changed` notification, eliminating the need
to restart the server to discover new tools.

## Changes

- Register a notification handler for `notifications/tools/list_changed`
in `ContextServerRegistry`
- Automatically reload tools when the notification is received
- Handler is registered both on initial server startup and when a server
transitions to `Running` status

## Motivation

The MCP specification includes a `notifications/tools/list_changed`
notification to inform clients when the list of available tools has
changed. Previously, Zed's agent would only load tools once when a
context server started. This meant that:

1. If an MCP server dynamically registered new tools after
initialization, they would not be available to the agent
2. The only way to refresh tools was to restart the entire context
server
3. Tools that were removed or modified would remain in the old state
until restart

## Implementation Details

The implementation follows these steps:

1. When a context server transitions to `Running` status, register a
notification handler for `notifications/tools/list_changed`
2. The handler captures a weak reference to the `ContextServerRegistry`
entity
3. When the notification is received, spawn a task that calls
`reload_tools_for_server` with the server ID
4. The existing `reload_tools_for_server` method handles fetching the
updated tool list and notifying observers

This approach is minimal and reuses existing tool-loading
infrastructure.

## Testing

- [x] Code compiles with `./script/clippy -p agent`
- The notification handler infrastructure already exists and is tested
in the codebase
- The `reload_tools_for_server` method is already tested and working

## Benefits

- Improves developer experience by enabling hot-reloading of MCP tools
- Aligns with the MCP specification's capability negotiation system
- No breaking changes to existing functionality
- Enables more flexible and dynamic MCP server implementations

## Related Issues

This implements part of the MCP specification that was already defined
in the type system but not wired up to actually handle the
notifications.

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Improvement related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

Development

Successfully merging this pull request may close these issues.

4 participants