Skip to content

Fix MCP frame limits to count UTF-8 bytes - #8

Merged
CL-BAF merged 1 commit into
CL-BAF:mainfrom
fatihcvs:fix/mcp-utf8-byte-limits
Sep 20, 2026
Merged

CL-BAF merged 1 commit into
CL-BAF:mainfrom
fatihcvs:fix/mcp-utf8-byte-limits

Conversation

@fatihcvs

Copy link
Copy Markdown
Contributor

Summary

Closes #7.

Both MCP size guards now use Buffer.byteLength(value, "utf8") instead of JavaScript string length. Emoji/CJK frames can no longer exceed the configured byte limits while passing the character-count checks. Existing error responses and recovery behavior are preserved.

Verification

  • Seven transport regressions exercise ASCII, emoji and CJK frames at the 1 MiB boundary and one byte over it, plus the 2 MiB buffer limit across chunks. The three Unicode rejection/buffer tests fail on the original implementation; all seven pass after the fix.
  • Deterministic decoded chunks are fed to the actual server in isolated child processes. Existing real-stdio tests also pass in the full suite.
  • npm run build, npm run typecheck: pass.
  • npm test: 249 pass, none skipped.
  • npm run test:contract: 2 pass.
  • New test file passes Prettier. The repository-wide npm run format:check reports 73 existing files, including the original src/mcp/server.ts (checked separately from HEAD). This PR keeps the production change to the two guards rather than reformatting unrelated code.

Developed with OpenAI Codex assistance. No dependency changes.

@CL-BAF
CL-BAF merged commit a650873 into CL-BAF:main Sep 20, 2026
1 check passed
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.

MCP frame size guard should measure UTF-8 bytes instead of JavaScript string length

2 participants