fix(tool-call): convert INVALID_PARAMS to soft error for Devin/Windsu… - #1410
Conversation
…rf compatibility Some MCP clients (Devin/Windsurf) treat hard JSON-RPC -32602 errors as transport failures, disconnect and respawn the server, hiding the actual parameter validation message from the agent. Convert INVALID_PARAMS to CallToolResult with isError=true so agents see validation messages and can fix parameter names.
|
All contributors have signed the CLA. ✅ |
|
Relates to and resolves #1409 also, reduces mcp connection restarts and contention. |
|
I have read the CLA Document and I hereby sign the CLA |
lean-ctx MCP: Validation Errors Misreported as Connection FailuresSummaryDevin/Windsurf's MCP client misreports JSON-RPC This causes agents to retry, respawn MCP processes, and waste turns debugging Encountered Errors Examplectx_patch with wrong params (
|
|
real life test: now after error: Model corrects it self: |
|
Merged to main — thanks @altasol! 🎉 The fix is clean and the real-world Devin testing confirms the improvement. I trimmed the comment block slightly for consistency with our code style, but the logic is unchanged. This will ship in the next release. |
fix(tool-call): convert INVALID_PARAMS to soft error for Devin/Windsurf compatibility
Summary
Some MCP clients (Devin/Windsurf) treat hard JSON-RPC -32602 errors as transport failures, disconnect and respawn the server, hiding the actual parameter validation message from the agent. Convert INVALID_PARAMS to CallToolResult with isError=true so agents see validation messages and can fix parameter names.
Test plan
cd rust && cargo test -- --test-threads=1(the suite shares process-global state; CI serializes it too)cd rust && cargo clippy --all-targets --all-features -- -D warningscd rust && cargo fmt --checknpm test/ build stepsNotes for reviewers
Fixes Devin MCP connection reset issue on Devin local mode.
thus model stops using ctx_* because of continues failures and not reliable tools.
Resulting soft error, allows model to get response and understand issue, and MCP connection stays in tact.
Contributor License Agreement
First-time contributors: a bot will ask you to sign our one-time
CLA (it keeps lean-ctx
Apache-2.0 and free for individual developers — see §8). You sign once by
replying to this PR with:
I have read the CLA Document and I hereby sign the CLAI have read the CLA Document and I hereby sign the CLA