Skip to content

Raise the MCP bridge's input limit to fit the server's tool schemas - #145

Open
ammartahamohamedy wants to merge 1 commit into
prooflinedev:mainfrom
ammar-taha-dev:fix/mcp-frame-limit
Open

ammartahamohamedy wants to merge 1 commit into
prooflinedev:mainfrom
ammar-taha-dev:fix/mcp-frame-limit

Conversation

@ammartahamohamedy

Copy link
Copy Markdown

Fixes #144

Problem

The bridge caps an input line at 8,192 bytes. A longer one gets a null-id error, and the bridge exits, taking every Proofline tool away from the agent. A full-length ask_codebase question in a CJK script is about 12 KB, and review_rule.create accepts 65,536 characters. The native commands share the cap, so proofline ask fails on the same question.

Fix

  • FRAME_LIMIT is 1 MiB. The largest bounded schema string is 65,536 characters. Escaped in full, that's 384 KiB at six bytes per \uXXXX, or 768 KiB at worst, when every character is outside the BMP and takes a twelve-byte surrogate pair. Either way 1 MiB leaves room for the envelope. Fields with no schema limit (finishing_recipe.create's instructions) still stop at the limit. The bridge stays bounded and serial.
  • Nothing is reserved up front. read_frame grows its buffer as the line arrives, and stdin uses the default BufReader capacity. Otherwise the new limit would cost 1 MiB per bridge and per message.
  • The error text comes from the constant (MCP input exceeds {FRAME_LIMIT} bytes).
  • Past the limit nothing changes: the null-id error and the exit stay as designed, and the existing tests check them at the new limit.

Tests (written first; the new and updated tests failed before the change)

Test What it checks
a_full_length_question_in_a_cjk_script_is_relayed_and_the_session_continues (new, tests/mcp.rs) After the handshake, a 4,000-character ask_codebase question (more than 12,000 bytes) is relayed under its own id, and a ping after it still works. Before: the bridge exited
a_native_call_carries_a_full_length_question_in_a_cjk_script (new, src/mcp.rs unit) mcp::call, which proofline ask uses, sends the same question through. Before: TooLarge. The existing native test's stand-in server moved into a shared helper
bounded_frames_serial_backpressure_and_broken_stdout_release_the_actual_process (updated) The same checks at 1 MiB: a line of exactly FRAME_LIMIT bytes is relayed, and one byte more is refused with the null-id error and an exit
config_input_and_credential_failures_make_no_tool_call (updated, tests/http.rs) An oversized config propose input is still refused before any tool call, now at 1 MiB (MCP input exceeds 1048576 bytes)

Mutation checks: a limit of 16 KiB fails the bounded-frames test, and restoring 8,192 fails all four.

End to end, offline, with the built binary: the issue's 3,600-character case now gets an answer under id 7, the ping is answered, and the exit code is 0.

Checks

  • cargo fmt --check: ✅
  • cargo clippy --locked -- -D warnings: clean on the lib, the bins and every integration test. --all-targets stops at the 2 errors main already has on Windows (src/agent/tests.rs).
  • cargo test --locked: the changed tests pass. tests/mcp.rs can't run on Windows: the harness starts the bridge with env_clear(), which drops SystemRoot, so every test in it times out, on main too. With a temporary, uncommitted SystemRoot pass-through (what fix(windows): unblock cargo clippy and Windows integration tests #103 proposes), all 8 pass on Windows. Apart from that file, the same Windows failures as on main.
  • cargo deny check: no dependency changes.
  • Fork CI: check and windows green on ammar-taha-dev/proofline-cli#4 (commit e20bb99; rebased onto 22c86ca as 8e7da22, which touches none of these files). The Linux check job runs tests/mcp.rs, including the new test.

Proofline review log

Fork review PR: ammar-taha-dev/proofline-cli#4. Rounds capped at 2.

Round Finding What I made of it Outcome
1 None ("Proofline review finished: no new findings", a quick diff review) Nothing to act on No changes; one round was enough

The prompt below is the one that drove this implementation; the investigation, reproduction and fix scope were done before it and aren't included.

This branch has not been deployed

No deployments
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.

The MCP bridge drops a schema-valid tool call over 8 KiB and exits

1 participant