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(mcpserver): add add_resource_template() for programmatic template registration
Add add_resource_template() to both ResourceManager and MCPServer so
ResourceTemplate instances can be registered directly, without the
@resource decorator. Duplicate uri_template registrations warn and
return the existing template, mirroring add_resource() semantics.
add_template() now delegates to the new method.
Copy file name to clipboardExpand all lines: docs/servers/resources.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,10 @@ The same rule applies to anything else JSON-serialisable: a list, a Pydantic mod
127
127
`BinaryResource`, `FileResource`, `HttpResource`, `DirectoryResource`) that you register
128
128
with `mcp.add_resource(...)`.
129
129
130
+
Template resources can be registered programmatically too: build a `ResourceTemplate`
131
+
with `ResourceTemplate.from_function(...)` and call `mcp.add_resource_template(...)`
132
+
instead of decorating a function.
133
+
130
134
A client can also **subscribe** to a resource and be notified when it changes; that's the client's half of the story and it lives in **[The Client](../client/index.md)**.
0 commit comments