Skip to content

Conversation

@nacx
Copy link
Member

@nacx nacx commented Dec 6, 2025

Description

Sends a tool list changed notification when the MCPRoutes change. We were already notifying when the upstream MCP servers changed the notifications, but now we're also notifying when the routes change or the filtered tools change (without upstream MCP server changes).

Related Issues/PRs (if applicable)

Fixes #1619

Special notes for reviewers (if applicable)

N/A

@nacx nacx requested a review from a team as a code owner December 6, 2025 09:26
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Dec 6, 2025
m.baseURL = fmt.Sprintf("http://localhost:%d%s", env.EnvoyListenerPort(), path)

m.client = mcp.NewClient(&mcp.Implementation{Name: "demo-http-client", Version: "0.1.0"}, &mcp.ClientOptions{
ToolListChangedHandler: func(_ context.Context, request *mcp.ToolListChangedRequest) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this point the change is not related to the issue. This adds tests that were missing to verify upstream tool change notification propagation.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2025

Codecov Report

❌ Patch coverage is 88.67925% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.40%. Comparing base (d33eec2) to head (b4d24fc).

Files with missing lines Patch % Lines
internal/mcpproxy/config.go 92.50% 3 Missing and 3 partials ⚠️
internal/mcpproxy/handlers.go 0.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1630      +/-   ##
==========================================
+ Coverage   83.22%   83.40%   +0.17%     
==========================================
  Files         137      138       +1     
  Lines       12373    12433      +60     
==========================================
+ Hits        10298    10370      +72     
+ Misses       1445     1430      -15     
- Partials      630      633       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nacx
Copy link
Member Author

nacx commented Dec 6, 2025

/retest

if heartbeatTicker != nil {
heartbeatTicker.Reset(heartbeatInterval)
}
case <-toolsChanged:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. does this mean that toolsChanged shared across many notification streams/sessions but only one item will be sent by the config change? I think it will not work as expected i think when we have N streams

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think instead of channel, we can use sync.Cond with multiple waiter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes, good catch! I'll fix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. PTAL.
I've opted for a silightly different approach:

  • I've moved the config-related stuff to a config.go (apologies for the noise).
  • I've created a changeSignaler interface, that still uses a channel, but instead of sending to it, it clsoes the channel to wake up all watchers. I think it's a bit cleaner than the sync.Cond in this case, because this allows us to use the existing select loop we're using for upstream events or heartbeats.

@nacx nacx force-pushed the tool-change-notify branch from c5cac7c to 7422f1b Compare December 6, 2025 18:47
@nacx nacx requested a review from mathetake December 6, 2025 18:50
Signed-off-by: Ignasi Barrera <[email protected]>
},
}

// Start watcher goroutines to make sure all of them are notified
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new test added after the review comments to make sure we can notify N watchers

Signed-off-by: Ignasi Barrera <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP proxy should notify clients when there are tools changes

3 participants