Skip to content

fix(bot): surface MCP server rejection details - #6440

Draft
ehz0ah wants to merge 1 commit into
volcengine:mainfrom
ehz0ah:fix/vikingbot-mcp-jsonrpc-errors
Draft

ehz0ah wants to merge 1 commit into
volcengine:mainfrom
ehz0ah:fix/vikingbot-mcp-jsonrpc-errors

Conversation

@ehz0ah

@ehz0ah ehz0ah commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Description

VikingBot previously reduced every exception from an outbound MCP tools/call request to the exception class name. When a reachable server returned a JSON-RPC error for invalid arguments, the model saw only McpError and lost the information needed to correct the call.

JSON-RPC error answers now produce a bounded, credential-redacted result that includes the error code and server message. The MCP SDK's connection-closed and request-timeout codes remain on the existing transport-failure path.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

External evidence: NousResearch/hermes-agent#142864

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Recognize JSON-RPC error answers structurally without depending on one MCP SDK exception class.
  • Return the server's code and sanitized message to the model for actionable call rejection errors.
  • Preserve the existing generic result for no-answer codes, malformed error objects, and ordinary exceptions.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Validation completed:

ruff format --check bot/vikingbot/agent/tools/mcp.py bot/tests/test_mcp_tool_errors.py
ruff check bot/vikingbot/agent/tools/mcp.py bot/tests/test_mcp_tool_errors.py
python3 -m py_compile bot/vikingbot/agent/tools/mcp.py bot/tests/test_mcp_tool_errors.py
git diff --check

A source-pinned before/after probe ran twice per revision with byte-identical output. It verified that -32603 becomes actionable, -32000 and -32001 remain generic transport failures, malformed and ordinary exceptions retain their current result, and credential-shaped message content is redacted.

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

Not applicable.

Additional Notes

This change does not add retries, replay failed calls, open a circuit breaker, or alter MCP connection ownership.

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

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant