Skip to content

Commit d3a0936

Browse files
committed
docs: trim migration guide to actual v1.x breaking changes
The previous matcher was a naive replace('{', '(?P<').replace('}', '>[^/]+)') that threw re.error on any operator character. Removed items describing constraints on features that did not exist in v1.x: - 'At most one multi-segment variable': {+var}/{#var}/explode all threw re.error in v1.x, so nobody had a working template with one let alone two. Covered in resources.md. - 'Query parameters match leniently': {?q} also threw re.error. The lenient-query feature is new, not a behavior change. Also folded the structural-delimiter change into the literals item and softened 'malformed templates' to note it's an error-timing change (re.error at match time -> InvalidUriTemplate at decoration).
1 parent cd19eaa commit d3a0936

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

docs/migration.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -573,27 +573,17 @@ from mcp.server.mcpserver import ResourceSecurity
573573
def inspect_file(target: str) -> str: ...
574574
```
575575

576-
**Template literals match exactly.** Previously a `.` in your
577-
template matched any character; now it matches only a literal dot.
578-
`data://v1.0/{id}` no longer matches `data://v1X0/42`.
579-
580-
**At most one multi-segment variable.** Templates may contain a single
581-
`{+var}`, `{#var}`, or explode-modified variable (`{/var*}`, etc.).
582-
Two such variables make matching inherently ambiguous and now raise
583-
`InvalidUriTemplate` at decoration time. This is unlikely to affect
584-
existing templates since the previous Level 1 matcher did not support
585-
these operators at all.
586-
587-
**Query parameters match leniently.** A template like
588-
`search://{q}{?limit}` now matches `search://foo` (with `limit` absent
589-
from the extracted params so your function default applies). Previously
590-
this returned no match. If you relied on all query parameters being
591-
required, add explicit checks in your handler.
592-
593-
**Malformed templates fail at decoration time.** Unclosed braces,
594-
duplicate variable names, and unsupported syntax now raise
595-
`InvalidUriTemplate` when the decorator runs, rather than silently
596-
misbehaving at match time.
576+
**Template literals and structural delimiters match exactly.** The
577+
previous matcher built a regex without escaping, so `.` matched any
578+
character and simple `{var}` swallowed `?`, `#`, `&`, and `,`. Now
579+
`data://v1.0/{id}` no longer matches `data://v1X0/42`, and
580+
`api://{id}` no longer matches `api://foo?x=1` — use `api://{id}{?x}`
581+
or `api://{+id}` if you need to capture a query tail.
582+
583+
**Template syntax errors surface at decoration time.** Unclosed
584+
braces, duplicate variable names, and unsupported syntax raise
585+
`InvalidUriTemplate` when the decorator runs rather than `re.error`
586+
on first match.
597587

598588
**Static URIs with Context-only handlers now error.** A non-template
599589
URI paired with a handler that takes only a `Context` parameter

0 commit comments

Comments
 (0)