Skip to content

Conversation

blkt
Copy link
Contributor

@blkt blkt commented Aug 28, 2025

This change makes use of the provided filter and override configuration in tool middlewares. Both middlewares now process tools/call and tools/list commands by checking both overrides and filtering, specifically:

  • tools/list responses, which the proxy received from the real MCP server, must be modified to contain tools whose names might be overridden (as well as filtered)
  • tools/call requests, which the proxy received from the Client, must be modified to refer to the original tool name

As a refresher for the reviewer, keep in mind that filtering is expressed in terms of tool names used by the client, so the user-visible (or client-visible) name must be determined before the lookup on the filter. This makes it so that

  • tools/list must first look the override up and only then check the filter, while
  • tools/call must first check the filter and only then look the override up

Fixes #1513

@blkt blkt self-assigned this Aug 28, 2025
JAORMX
JAORMX previously approved these changes Aug 29, 2025
@blkt
Copy link
Contributor Author

blkt commented Aug 29, 2025

As suggested by @JAORMX via chat, I'm adding test coverage for the whole middleware.
I'll open a PR against this one that only adds those tests and fixes, then we'll merge this one.

blkt added 2 commits August 29, 2025 11:02
This change makes use of the provided filter and override
configuration in tool middlewares. Both middlewares now process
`tools/call` and `tools/list` commands by checking both overrides and
filtering, specifically:

* `tools/list` responses, which the proxy received from the real MCP
  server, must be modified to contain tools whose names might be
  overridden (as well as filtered)
* `tools/call` requests, which the proxy received from the Client,
  must be modified to refer to the original tool name

As a refresher for the reviewer, keep in mind that filtering is
expressed in terms of tool names used by the client, so the
user-visible (or client-visible) name must be determined before the
lookup on the filter. This makes it so that

* `tools/list` must first look the override up and only then check the
  filter, while
* `tools/call` must first check the filter and only then look the
  override up

Fixes #1513
@blkt blkt force-pushed the feat/add-tool-override-support-to-middleware branch from 1168cb3 to 735b708 Compare August 29, 2025 09:02
@blkt
Copy link
Contributor Author

blkt commented Aug 29, 2025

OK, I fixed a few bugs and added more tests for tool management middleware, this is ready for final review and can be merged any time.

@blkt blkt merged commit dc1c4ec into main Aug 29, 2025
17 checks passed
@blkt blkt deleted the feat/add-tool-override-support-to-middleware branch August 29, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend filtering middleware to handle overrides
3 participants