Skip to content

Raise ProoflineError for oversized MCP requests - #113

Open
NicholasDAS wants to merge 2 commits into
prooflinedev:mainfrom
NicholasDAS:fix-mcp-oversized-request-error
Open

NicholasDAS wants to merge 2 commits into
prooflinedev:mainfrom
NicholasDAS:fix-mcp-oversized-request-error

Conversation

@NicholasDAS

Copy link
Copy Markdown

Problem

proofline/_mcp.py::_body refuses MCP request bodies over 8,192 bytes with a bare ValueError. That limit is reachable from the public API: knowledge.ask_codebase() with a long question (for example, one that pastes a stack trace) builds a tools/call frame over the limit, and the ValueError escapes to the caller. The rest of the SDK raises the typed ProoflineError for protocol problems, and the README says protocol and HTTP errors raise ProoflineError, so a caller catching ProoflineError misses this one.

Change

_body now raises ProoflineError(0, "urn:proofline:sdk:mcp", ...) — the same status and type the module already uses for refused MCP responses — with the original message kept.

Verification

New tests/test_mcp.py covers:

  • an oversized tools/call body raises ProoflineError with status 0 and type urn:proofline:sdk:mcp;
  • a normal body stays within the limit;
  • a 9,000-character question raises the typed error from both KnowledgeClient.ask_codebase and AsyncKnowledgeClient.ask_codebase before any request is sent (the client points at an invalid host; the error is raised while building the request).

@NicholasDAS NicholasDAS changed the title Fix mcp oversized request errorRaise ProoflineError for oversized MCP requests Raise ProoflineError for oversized MCP requests Nov 25, 2026

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.

1 participant