Skip to content

Conversation

@felixweinberger
Copy link
Contributor

Summary

URL-decode parameters extracted from resource template URIs so that percent-encoded characters (like %20 for space, %C3%A9 for é) are properly decoded before being passed to resource handlers.

Motivation and Context

When a client requests a resource using a URI like search://hello%20world, the {query} parameter was being passed to the handler as the literal string "hello%20world" instead of "hello world". This broke handlers that expected decoded strings.

Fixes #973

How Has This Been Tested?

Added tests/issues/test_973_url_decoding.py with 4 test cases:

  • Space decoding (%20 )
  • Accented characters (%C3%A9é)
  • Complex French phrase from the original issue
  • Verification that + remains as + (correct URI behavior vs form encoding)

Breaking Changes

None. This is a bug fix that makes resource templates work as users would expect.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Uses urllib.parse.unquote which handles UTF-8 encoded characters correctly. The + sign is intentionally NOT converted to space because that behavior is specific to application/x-www-form-urlencoded (HTML forms), not URI encoding.

@felixweinberger felixweinberger force-pushed the fweinberger/fix-url-param-decoding branch from 4a9ea40 to 8b53094 Compare January 16, 2026 08:21
@felixweinberger felixweinberger marked this pull request as ready for review January 16, 2026 08:55
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.

URL Parameters Not Decoded in Dynamic Resources

2 participants