You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add resource handler middleware capability
This is a fairly direct adaption of the existing tool handler middleware
to also allow support for resource middlewares.
Use case: I'm working on an MCP server that manages an API client that
is used for both tool and resource calls. The tool handler middleware
provides a nice pattern to wrap tool calls that fits some use cases
better than the before/after tool call hooks. It would be helpful to
have first party support for this pattern in the library so I don't need
to work around it with custom closures etc.
Notes:
- There are currently (that I can find) that exercise the existing tool
handler middleware logic, so I did not add tests for the resource
handler middleware logic.
- Existing docs, specifically those for the streamable HTTP transport,
reference some middleware functions (for both tools and resources)
that don't exist (ex: `s.AddToolMiddleware` does not,
`s.AddResourceMiddleware` does not exist, etc). It seems they may be out
of date. Happy to discuss updates to docs in a separate PR.
Signed-off-by: TJ Hoplock <[email protected]>
* feat: add `WithResourceRecovery()` ServerOption
The existing `WithRecovery()` ServerOption is tool oriented, this adds a
corresponding recovery handler for resources. This will be especially
useful if Resource middlewares are used, where things may possibly/need
to panic.
Signed-off-by: TJ Hoplock <[email protected]>
---------
Signed-off-by: TJ Hoplock <[email protected]>
0 commit comments