How to implement a "tool middleware"? #598
ouvreboite
started this conversation in
General
Replies: 1 comment
-
I've given it a bit more though, I've tried to implement an ActionFilter's like pattern but for tools. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Discussion Topic
As MCP is using a single HTTP connection to perform several tool calls, I struggle to implement custom "middlewares" for my tools the same way I would do for REST controllers (to push custom metrics, ...).
With controllers, I would use an ASPNET.Core middleware, or an ActionFilter.
I tried creating my own middleware-like logic in a custom CallToolHandler, but I think the ConfigureSessionOptions / RunSessionHandler run before the default CallToolHandler is set. So, no luck there.
This does not work ⬇️
Maybe I missed something? Is there a way to run custom logic before/after each tool call?
Beta Was this translation helpful? Give feedback.
All reactions