Draft
Conversation
…ilities Add `UriTemplate`, `UriTemplateMatcher`, and `MatchResult` classes to support [RFC-6570](https://www.rfc-editor.org/rfc/rfc6570.txt) URI template matching and expansion. Implemented unit tests for conformance with all expansion levels and path operators.
Introduce `ResourceTemplate` and `RegisteredResourceTemplate` implementation to register and manage parameterized resource templates. Added support for listing, reading, and removing resource templates. Updated error handling for unmatched URIs with a new `RESOURCE_NOT_FOUND` RPC error. Includes corresponding tests and API updates.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…lidation Replaced `check(options.capabilities.* != null)` with `checkNotNull` for improved clarity and consistency in validating server capabilities.
…ssion Add specific handling for `CancellationException` in `Protocol.kt` to ensure it is rethrown instead of being suppressed by the generic `Throwable` catch block.
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Implements MCP resource templates per the MCP 2025-11-25
specification.
Closing #502. Requires #603
Clients can now:
resources/templates/listresources/readChanges
kotlin-sdk-serverServer.addResourceTemplate(template, handler)— registers aResourceTemplatewith a two-parameter handler(ReadResourceRequest, Map<String, String>) -> ReadResourceResult, where the map contains the extracted URI variables.Server.addResourceTemplate(uriTemplate, name, …, handler)— convenience overload.Server.removeResourceTemplate(uriTemplate)— removes a registered template.Server.resourceTemplates— snapshot of all registered templates.handleReadResourcenow applies a three-tier lookup:MatchResult.scorefrom the RFC 6570 matcher)McpException(RESOURCE_NOT_FOUND)if nothing matcheshandleListResourceTemplatesnow returns the actual registered templates instead of an empty list.resources/list_changedwhen that capability is enabled.kotlin-sdk-coreRPCError.ErrorCode.RESOURCE_NOT_FOUND = -32002— new SDK-defined error code forunknown resource URIs.
Conformance / integration tests
conformance-baseline.yml: removesresources-templates-readfrom expected failures.ConformanceResources.kt: replaces workaround static resource with a realaddResourceTemplateregistration.AbstractResourceIntegrationTest.testInvalidResourceUri: updated to expectRESOURCE_NOT_FOUND(-32002) instead ofINTERNAL_ERROR(-32603).Breaking changes
handleReadResourcenow throwsMcpException(RESOURCE_NOT_FOUND)for unrecognised URIs instead ofIllegalArgumentException. Clients receive error code-32002on the wire instead of-32603. Any integration test assertingINTERNAL_ERRORfor a missing resource must be updated (one such test is updated in this PR).How Has This Been Tested?
resources-templates-readremoved from the baseline.Types of changes
Checklist
Additional context