Skip to content

vMCP returns -32602 (HTTP 200) instead of 403 for authz-denied tool calls #5827

Closed

Description

@JAORMX

Summary

On the vMCP Serve path, a direct tools/call to a tool that authorization (Cedar) denies returns:

HTTP 200
{"jsonrpc":"2.0","id":3,"error":{"code":-32602,"message":"tool 'yardstick_echo' not found: tool not found"}}

instead of an explicit authorization-denied response (HTTP 403, or at minimum a distinct "denied by policy" error). The request is safely blocked — no backend call, no mutation — but the client cannot tell "you are not authorized" apart from "this tool does not exist", and there is no explicit authorization-denied signal for audit / acceptance evidence.

The single-server proxy path (thv run --authz-config) does not have this problem: it returns HTTP 403 for the same denied call.

Expected vs actual

Path Denied direct tools/call
thv run --authz-config (pkg/authz HTTP middleware) HTTP 403 {"code":403,"message":"Unauthorized"}
vMCP Serve path (core admission seam) HTTP 200 {"error":{"code":-32602,"message":"tool '<name>' not found: tool not found"}}

Both block the call. Only the first produces an authorization-denied signal a client/auditor can act on.

Reproduction

Reproduced on main (v0.38.0-1-g2894cace6) using the vmcp CLI and the yardstick test server (single echo tool).

# 1. Backend in a dedicated group
thv group create vmcptest
thv run --transport streamable-http --target-port 8080 --isolate-network=false \
  --group vmcptest --name yardstick ghcr.io/stackloklabs/yardstick/yardstick-server:1.1.1

# 2. vMCP config that denies echo (permits only a non-existent tool -> default deny)
cat > vmcp-config.yaml <<'YAML'
name: "repro-vmcp"
groupRef: "vmcptest"
incomingAuth:
  type: anonymous
  authz:
    type: cedar
    policies:
      - 'permit(principal, action == Action::"call_tool", resource == Tool::"some_other_tool");'
outgoingAuth:
  source: inline
  default:
    type: unauthenticated
aggregation:
  conflictResolution: prefix
  conflictResolutionConfig:
    prefixFormat: "{workload}_"
YAML

vmcp serve --config vmcp-config.yaml --host 127.0.0.1 --port 4483

Then drive the MCP handshake and a direct call to the denied tool (yardstick_echo):

  • tools/list → {"result":{"tools":[]}} (tool correctly filtered from advertisement)
  • tools/call yardstick_echo → HTTP 200, {"error":{"code":-32602,"message":"tool 'yardstick_echo' not found: tool not found"}}

Root cause

On the Serve path, authorization was moved from the HTTP middleware to the core admission seam (#5438). The HTTP AuthzMiddleware — which is what returns 403 on the single-server path — is intentionally left nil on the Serve path:

The admission seam enforces policy by filtering denied tools out of the per-session tool set that gets registered with the MCP SDK:

  • serveSessionTools → coreSessionTools → core.ListTools (admission-filtered) — only allowed tools are registered as SDK session tools (pkg/vmcp/server/serve_handlers.go).

Because a denied tool is never registered as an SDK tool for that session, a direct tools/call for it is handled by the mcp-go SDK as an unknown tool and returns -32602 tool not found (HTTP 200) before reaching the core.

The core already has a proper denied path that never runs for filtered tools:

  • pkg/vmcp/core/core_calls.go:63-67 — CallTool returns vmcp.ErrAuthorizationFailed on admission deny.
  • pkg/vmcp/server/serve_handlers.go:196-198 — coreToolHandler maps that via conversion.ErrorToToolResult.
  • pkg/vmcp/conversion/errors.go — ErrorToToolResult produces "call denied by authorization policy" (a tool-result error, HTTP 200).

But that handler is only invoked for registered tools. For a denied (and therefore unregistered) tool, the SDK short-circuits with -32602.

Impact

  • No authorization-denied signal. Clients and auditors cannot distinguish "denied by policy" from "tool does not exist". For customers who need explicit authz-denied evidence (audit trails, acceptance testing), there is currently no supported response that says "denied".
  • Inconsistent behavior between the single-server proxy (403) and vMCP (200 / -32602).
  • Note: even for a registered-but-denied tool the current core path returns HTTP 200 with a tool-result error rather than 403, so "return 403 on Cedar deny" is not fully satisfied anywhere on the vMCP path.

Questions to resolve in design

  1. Should a denied direct tools/call on vMCP return HTTP 403 (matching the single-server path), or a distinct JSON-RPC error that is clearly "authorization denied" rather than -32602 not found?
  2. If tools stay filtered from advertisement (so listing does not leak their existence), how do we still return an authorization-denied signal on a direct call without re-leaking which tools exist? (i.e. reconcile "don't advertise unauthorized tools" with "return an explicit denial".)
  3. Consistency target between thv run and vMCP.

Environment

  • toolhive main @ v0.38.0-1-g2894cace6
  • Backend: ghcr.io/stackloklabs/yardstick/yardstick-server:1.1.1
  • Transport: streamable-http

Activity

  1. added
    needs-triage
    on Jul 16, 2026
  2. self-assigned this
    on Jul 16, 2026
  3. added
    bug
    and removed
    needs-triage
    on Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions