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
{{ message }}
Repository navigation
Any method to match and handle the resource by dynamic uri path? #100
For example,I have 1000000 resource item stored in my database,and I'd like to match them by the uri like "document://index-A/index-B/index-C",it will be convenient to match them like "document://{index-A}/{index-B}/{index-C}" in a handler,and then use a select query to return the matched data item
I saw the ResourceTemplate class in sdk,but I couldn't see any method to match a template and handle them - McpServer have a method named "addResource" but doesn't have a method named "addResourceTemplate",ResourceTemplate seems just an "instruction" to client,and not used to handle parameterized uri
Maybe try to run a loop of 1000000 times calling addResource method to register them is not acceptable,and surely that will lose the significance of database,or I did not find the correct way to handle the ResourceTemplate?
As other sdk implement,Python and TypeScript SDKs seem support this feature:
# Add a dynamic greeting resource@mcp.resource("greeting://{name}")defget_greeting(name: str) ->str:
"""Get a personalized greeting"""returnf"Hello, {name}!"
// Dynamic resource with parametersserver.resource("user-profile",newResourceTemplate("users://{userId}/profile",{list: undefined}),async(uri,{ userId })=>({contents: [{uri: uri.href,text: `Profile data for user ${userId}`}]}));
Using the solution from #208, registering resource templates enables the server to return that list back to clients who query "resources/templates/list". In terms of handling dynamic resources, I see that I can register a resource with the same parameterized URI. I can then add whatever code I want in my "readHandler" method for returning the dynamic content.
I suspect #25 may not be merged as it seems to take a contradictory approach but who knows?
Using the solution from #208, registering resource templates enables the server to return that list back to clients who query "resources/templates/list". In terms of handling dynamic resources, I see that I can register a resource with the same parameterized URI. I can then add whatever code I want in my "readHandler" method for returning the dynamic content.
I suspect #25 may not be merged as it seems to take a contradictory approach but who knows?
#208 seems resolved the problem,but now I use mcp's tool_call to implement the api of resource query,as it is compatible to general tool_call,and I needn't to do any works to let the agent know the format difference between tool_call and resource_query
Activity
Smileslime47 commentedon Apr 2, 2025
okay,I saw the PR about this feature which hasn't been merged
seems I couldn't develop my mcp server in a short time :(
arcaputo3 commentedon Apr 11, 2025
This seems like a critical feature and it isn't well-documented that this isn't supported yet...
benken-parasoft commentedon Jul 9, 2025
Using the solution from #208, registering resource templates enables the server to return that list back to clients who query "resources/templates/list". In terms of handling dynamic resources, I see that I can register a resource with the same parameterized URI. I can then add whatever code I want in my "readHandler" method for returning the dynamic content.
I suspect #25 may not be merged as it seems to take a contradictory approach but who knows?
Smileslime47 commentedon Jul 10, 2025
#208 seems resolved the problem,but now I use mcp's tool_call to implement the api of resource query,as it is compatible to general tool_call,and I needn't to do any works to let the agent know the format difference between tool_call and resource_query