Skip to content

fix: use the referenced resource template for completion/complete - #1278

Open
prathamgoyal787 wants to merge 1 commit into
modelcontextprotocol:mainfrom
prathamgoyal787:fix/completion-referenced-template
Open

prathamgoyal787 wants to merge 1 commit into
modelcontextprotocol:mainfrom
prathamgoyal787:fix/completion-referenced-template

Conversation

@prathamgoyal787

Copy link
Copy Markdown

A completion/complete request for a resource template looked up the template by matching the reference's URI template against every registered template's pattern. Another template whose pattern happens to match that string could be checked first; for example, test://{category}/{id} matches test://items/{itemId}. The request then failed with "Argument not found" for a valid argument.

This change looks the template up by its exact URI template first, and only falls back to pattern matching after that. It applies to both McpAsyncServer and McpStatelessAsyncServer.

Added testCompletionUsesTheReferencedResourceTemplate to ResourceTemplateManagementTests. It fails on main and passes with this change.

A completion/complete request for a resource template looked the template
up by matching its URI template against every registered template's
pattern. Another template whose pattern happens to match that string, such
as test://{category}/{id} for test://items/{itemId}, could be checked
first, and the request then failed with "Argument not found" for a valid
argument. Look the template up by its URI template first, in both
McpAsyncServer and McpStatelessAsyncServer.

This branch has not been deployed

No deployments
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.

1 participant