Repository navigation
Conversation
_body serialized MCP requests with json.dumps' default ensure_ascii=True, which escapes every non-ASCII character as \uXXXX (6 bytes, 12 for astral characters) before the 8,192-byte check. A re-verification note within the documented 2,000-character limit in Arabic, Chinese, accented Latin or emoji was refused locally (12,292 bytes) although its UTF-8 body is 4,292 bytes, the form the MCP bridge sends. Serialize with ensure_ascii=False and encode with backslashreplace, so a lone surrogate, which has no UTF-8 form, keeps its JSON escape. Document the request limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test counted only tools/call requests, so a regression that sent the initialize handshake before refusing an oversized request would still pass. Count every request the server receives across the refused call. Found by a Proofline review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
request_reverificationdocuments a note of 1 to 2,000 characters, but a note within that limit is refused before it is sent when it is not ASCII._mcp._bodyserializes every MCP request withjson.dumps' defaultensure_ascii=True, which escapes each non-ASCII character as\uXXXX(6 bytes, 12 for characters outside the BMP), and only then checks the 8,192-byte request limit. The MCP bridge (prooflinedev/mcp) enforces the same 8,192-byte limit on the UTF-8 JSON thatJSON.stringifyproduces, so the same note works through the bridge and fails in the Python SDK.ValueErrorValueErrorThe same applies to
ask_codebasequestions and every otherknowledgeandfixescall.Change
proofline/_mcp.py: serialize withensure_ascii=Falseand encode withbackslashreplace. Text goes out as UTF-8, the bytes the bridge sends. A lone surrogate has no UTF-8 form, sobackslashreplacewrites it as the JSON escape\udXXX, which is whatJSON.stringifydoes. The 8,192-byte check is unchanged and now measures what is sent.README.md: document the request limit, which was not written down.tests/test_http.py: one sync and async test against the local server.Verification
client.fixes.request_reverificationand checks that the request is at most 8,192 bytes, carries the note as UTF-8, and decodes to the same note on the server. It checks that a lone surrogate keeps its escape and still decodes, and that a request over the limit still raisesValueErrorbefore anything is sent. It fails onmainwithMCP request exceeds 8192 bytes.and passes with the change.python3 scripts/check.pypasses (generation, HTTP contracts, wheel and source installs). The suite is 221 tests.ProoflineClientagainst the local MCP stub intests/http_server.py:To reproduce, run the new test with
pytest tests/test_http.py -k utf8onmainand on this branch.Proofline review
I ran Proofline on this branch in my fork (hamzatlh/sdk-python#1). It raised one warning: the oversized-request case counted only
tools/callrequests, so a regression that sent theinitializehandshake before refusing the request would still pass. I agreed and changed the test to assert that the server receives no request at all across the refused call. To check the stronger test, I moved the size check after the handshake in the sync client: the test then fails withassert 8 == 6, and it passes on this branch.🤖 Generated with Claude Code