Skip to content

Return JSON-RPC errors instead of HTTP 400 for filtered tool calls #5751

Description

@JAORMX

Part of #5743 (Workstream B: 2025-11-25 compliance).

Gap

When the tool-call gating middleware blocks a filtered tool, it returns HTTP 400 instead of a JSON-RPC error response (pkg/mcp/tool_filter.go, acknowledged in a code comment). MCP clients expect protocol-level errors for protocol-level problems; a transport 400 breaks client error handling and shows up as a connection problem rather than "tool not found".

Proposed work

Return a proper JSON-RPC error (method the spec uses for unknown tools — invalid params / tool not found semantics) over the negotiated response mode (JSON or SSE), keeping HTTP 400 only for genuinely malformed HTTP/JSON.

Priority: Low.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue needs initial triage by a maintainer

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions