Skip to content

feat: Add first-class resource template support #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

arcaputo3
Copy link
Collaborator

This commit implements comprehensive resource template support in fast-mcp-scala, enabling URI templates with parameters like "users://{userId}" to work seamlessly.

Key changes:

  • Add ResourceArgument and template validation to ResourceManager
  • Implement getTemplateHandler() and listTemplateDefinitions() methods
  • Add javaTemplateResourceReadHandler using Java SDK's DefaultMcpUriTemplateManager
  • Update ResourceDefinition with isTemplate flag and toJava union type
  • Enhance ResourceProcessor macro to detect and handle URI placeholders
  • Add @ResourceParam annotation support for template parameters
  • Update examples to demonstrate template usage (user://{userId})
  • Fix resource/template separation in listResources() vs listResourceTemplates()
  • Register templates as resources for handler routing while maintaining separate discovery

Technical improvements:

  • Leverage Java SDK's built-in URI template matching instead of reimplementing
  • Avoid duplicate template registration in discovery endpoints
  • Properly validate template placeholders match method parameters
  • Update to mcp-sdk 0.10.0 for enhanced template support

This enables MCP clients to discover and use templated resources with proper parameter extraction and validation.

🤖 Generated with Claude Code

arcaputo3 and others added 2 commits June 16, 2025 17:01
This commit implements comprehensive resource template support in fast-mcp-scala,
enabling URI templates with parameters like "users://{userId}" to work seamlessly.

Key changes:
- Add ResourceArgument and template validation to ResourceManager
- Implement getTemplateHandler() and listTemplateDefinitions() methods
- Add javaTemplateResourceReadHandler using Java SDK's DefaultMcpUriTemplateManager
- Update ResourceDefinition with isTemplate flag and toJava union type
- Enhance ResourceProcessor macro to detect and handle URI placeholders
- Add @ResourceParam annotation support for template parameters
- Update examples to demonstrate template usage (user://{userId})
- Fix resource/template separation in listResources() vs listResourceTemplates()
- Register templates as resources for handler routing while maintaining separate discovery

Technical improvements:
- Leverage Java SDK's built-in URI template matching instead of reimplementing
- Avoid duplicate template registration in discovery endpoints
- Properly validate template placeholders match method parameters
- Update to mcp-sdk 0.10.0 for enhanced template support

This enables MCP clients to discover and use templated resources with proper
parameter extraction and validation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
The MCP SDK 0.10.0 changed the JsonSchema constructor to require 6 parameters
instead of 4. Updated test expectations to match the SDK's behavior when
parsing JSON schema strings (sets additionalProperties to null rather than false).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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