feat: Transliterate non-ASCII characters in MCP server headers#11472
Open
kenzaelk98 wants to merge 2 commits intodanny-avila:mainfrom
Open
feat: Transliterate non-ASCII characters in MCP server headers#11472kenzaelk98 wants to merge 2 commits intodanny-avila:mainfrom
kenzaelk98 wants to merge 2 commits intodanny-avila:mainfrom
Conversation
- Use transliteration to convert special/accented characters to ASCII equivalents - Prevents ByteString errors (characters > 255) in HTTP headers - More readable than Base64 encoding (Đorđe → Dorde vs b64:...) - Works with all MCP servers immediately (no decoding needed) - Supports Latin, Cyrillic, Arabic, CJK, and more via 'transliteration' package Changes: - Add sanitizeHeaderValue() function using transliteration library - Apply to user name, username, and email fields in MCP headers - Add 14 comprehensive tests for transliteration edge cases - Install 'transliteration' npm package Tested locally with MCP server integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves upon the fix in (#11432) by replacing Base64 encoding with character transliteration for non-ASCII characters in MCP server headers.
Why this approach is better:
Đorđe→Dorde(vsb64:xJBvcsSRZQ==)transliterationpackageBackground:
The original issue solved in (#11432) was that non-ASCII characters (Unicode > 255) in user names/emails caused ByteString errors when passed as HTTP headers to MCP servers. The initial fix used Base64 encoding, but this required MCP servers to implement custom decoding logic to convert
b64:...strings back to readable text. This added complexity and wasn't practical for third-party MCP servers that shouldn't need special handling for LibreChat headers.This PR:
encodeHeaderValue()(Base64) withsanitizeHeaderValue()(transliteration)transliterationnpm packageTesting
Tested locally with an MCP server that uses
X-User-NameandX-User-Emailheaders containing non-ASCII characters.Test Configuration:
Đorđe Marić(contains Đ=272, đ=273, ć=263 - all > 255)Dorde MaricTest Results: