Skip to content

Conversation

@halter73
Copy link
Contributor

@halter73 halter73 commented Jan 13, 2026

  • Fix label expansion
  • Fix path-style parameter parsing
  • Add more resource matching test cases

@heaths

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes URI template parsing for reserved expansion ({+var}), label expansion ({.var}), and path-style parameters ({;var}). The bug was causing templates like samples://{dependency}/{+path} to fail when matching URIs with nested paths.

Changes:

  • Fixed reserved expansion to properly match slashes and other reserved characters per RFC 6570
  • Fixed label expansion to handle dot-prefixed values with correct separator logic
  • Added support for path-style parameter expansion with semicolon-prefixed name=value pairs
  • Added 757 lines of comprehensive tests covering all URI template operators and edge cases

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/ModelContextProtocol.Core/UriTemplate.cs Fixed operator handling in CreateParser switch statement, added AppendPathParameterExpression method, updated separator logic for multi-value expansions, and made UriTemplate class public
tests/ModelContextProtocol.Tests/UriTemplateCreateParserTests.cs Added comprehensive test suite with 757 lines covering all RFC 6570 operators, edge cases, and regression tests for the fixed bugs
tests/ModelContextProtocol.Tests/Configuration/McpServerResourceRoutingTests.cs Added integration test for the reserved expansion bug fix with nested path matching

@halter73 halter73 changed the title Fix reserved expansion (e.g. "{+var}") Fix reserved expansion (e.g. "{+var}") when matching resources Jan 13, 2026
Comment on lines 209 to 213
pattern.AppendFormatted("(?:;");
pattern.AppendFormatted(paramName);
pattern.AppendFormatted("(?:=(?<");
pattern.AppendFormatted(paramName);
pattern.AppendFormatted(">[^;/?&]+))?)?");
Copy link
Contributor

Choose a reason for hiding this comment

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

These can all be AppendLiteral

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Should I make the same change to the AppendParameter inside of AppendQueryExpression?

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.

5 participants