fastmcp/tests/resources
Leogrox 83e4bd3365
fix(resources): percent-encode URI template literals (RFC 6570 §3.1) (#5167)
`build_regex()` escaped literal runs verbatim and `expand_uri_template()`
copied them through unchanged, but the URI on the other side does not stay
verbatim: it reaches the server as an `AnyUrl`, which percent-encodes it.

So a resource template whose literal text carries a non-ASCII character or a
space was listed and then unreadable: the pattern held `café` while the
incoming URI read `caf%C3%A9`. The raw form failed too, since the
normalization happens before matching.

RFC 6570 §3.1 is the rule the expansion side was missing: a literal outside
the reserved/unreserved sets is percent-encoded as UTF-8 when the template is
expanded, which is exactly the form `AnyUrl` produces. Encode literals in both
directions, passing existing `%XX` triplets through so an already-encoded
literal is not encoded twice.

🤖 Generated with Claude Code

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 16:39:41 -05:00
..
__init__.py restore 1.x code 2025-04-09 11:54:42 -04:00
test_file_resources.py Add encoding parameter to FileResource (#3580) 2026-03-22 09:55:16 -04:00
test_function_resources.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_resource_security.py Make the unit suite fast: in-process HTTP tests, no real sleeps, parallel Windows CI (#4554) 2026-07-20 10:51:14 -04:00
test_resource_template.py fix(resources): percent-encode URI template literals (RFC 6570 §3.1) (#5167) 2026-09-21 16:39:41 -05:00
test_resource_template_meta.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00
test_resource_template_query_params.py Raise ValueError for invalid boolean query params in resource templates (#3424) (#3434) 2026-03-07 11:40:29 -05:00
test_resources.py Move to the stable MCP Python SDK 2.0.0 (#4655) 2026-07-28 16:31:49 -04:00
test_standalone_decorator.py Migrate to MCP Python SDK v2 (#4437) 2026-07-06 17:36:45 -04:00