You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP resource URI templates incorrectly encode non-ASCII variable values #339843
Reproduced against main at 3d5764c14dea123b0fd50fb61788328c33c076b8 on Linux with Node.js 22.22.1, using the actual UriTemplate source. This is a source-level reproduction, without extensions or a live MCP server session.
UriTemplate percent-encodes UTF-16 code units instead of UTF-8 bytes. This affects non-ASCII values entered for an MCP resource template: mcpResourceQuickAccess.ts collects the variable text and calls resolveURI, and mcpServer.ts resolves it through this helper.
To reproduce in the existing UriTemplate unit suite:
The accented and emoji results fail decodeURIComponent; the Chinese result decodes to different characters. Prefix expansion also counts UTF-16 units: {name:1} should retain the whole first emoji, rather than splitting its surrogate pair.
RFC 6570 specifies UTF-8 percent-encoding and Unicode-character prefix lengths. The previous low-control padding fix in #323012 does not address these non-ASCII values.
A focused correction and regression tests are prepared: UTF-8 encoding while preserving ASCII punctuation escaping, plus code-point prefix slicing. I plan to submit the linked fix. AI assistance was used for the investigation; the reported outputs were reproduced against the actual source.
Activity
fix: encode URI template values as UTF-8
Fix UTF-8 encoding of MCP resource URI template values (#339846)