Skip to content

Conversation

@CodeWithKyrian
Copy link
Contributor

This PR fixes resource template functionality by properly extracting URI template variables and passing them to resource handler methods.

Motivation & Context

Resource templates have never worked correctly since their implementation. While the URI matching logic was functional, the extracted variables from URI patterns (like userId from user://{userId}/profile) were not being passed to handler methods, making it impossible for handlers to receive the expected parameters and rendering resource templates completely non-functional.

What's Changed

  • Added method to ResourceTemplateReference to extract variables from URIs using regex matches
  • Modified ReadResourceHandler to detect template references and merge extracted variables into handler arguments

Breaking Changes

None

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looooks goood 🙌 Thanks @CodeWithKyrian!

image

@chr-hertel chr-hertel merged commit 55f8608 into modelcontextprotocol:main Oct 27, 2025
10 checks passed
@CodeWithKyrian CodeWithKyrian deleted the fix/resource-template-variable-extraction branch October 27, 2025 21:20
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.

2 participants