Skip to content
GatewayMarkdown

MCP tool calls

Allow or refuse each MCP tool, resource and prompt by name, for each agent or user, on a server that knows nothing about your policies.

AvailableAPIModel Context Protocol (Streamable HTTP), RFC 9728, OpenID AuthZEN Authorization API 1.0

An MCP (Model Context Protocol) server offers many tools behind one address, and they’re rarely equally safe: get_weather is not delete_records. Deciding by address alone would open or close the whole server. With the gateway in front of it, each MCP call is decided as what it does, the tool, resource or prompt it names, so you allow one tool and refuse another on the same server, for each agent or user, with policies in the realm.

A refusal comes back as a JSON-RPC error that MCP clients read natively, and an MCP client that has never met your server finds where to sign in from the gateway’s resource metadata.

  • The gateway running in front of the MCP server: see Run the gateway. Its image isn’t published yet: ask your Cvyūh contact for it.
  • A realm administrator in a group holding RealmOwner, to create the resource types, the policy set and the policies, with the API.
  • An MCP server that speaks Streamable HTTP, at a path such as /mcp, and clients on protocol version 2026-07-28 or later.

A client calls the server through the gateway, repeating the method and the name it acts on in headers:

POST /mcp HTTP/1.1
Host: gw.example.com
Authorization: DPoP eyJ…
DPoP: eyJ…
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: get_weather
Content-Type: application/json
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
"params": { "name": "get_weather", "arguments": {} } }

On a path you’ve named as an MCP server, the gateway reads the call, checks the headers against the body, and decides it as a resource of one of five types, named under the server’s audience, with the MCP method as the action. This call is decided as the action tools/call on https://gw.example.com/mcp/tool/get_weather.

MCP methodDecided asResource name
tools/calltool<audience>/tool/<name>
resources/read, resources/subscribe, resources/unsubscriberesource<audience>/resource/<uri>
prompts/getprompt<audience>/prompt/<name>
completion/completeprompt or resource, as its reference saysas above
tasks/get, tasks/result, tasks/canceltask<audience>/task/<taskId>
tools/list, resources/list, prompts/list, tasks/list, logging/setLevelmcp_server<audience>
ping, initialize, notifications/*—Pass on a valid token alone

A method nothing maps is refused.

The name is taken whole, as one segment: every character other than letters, digits and -._~ is percent-encoded, so a tool called get_* is never read as a pattern, and a / or .. in a resource URI never places it beneath another.

The gateway publishes the server’s metadata where MCP clients look, naming the realm. Its path is /.well-known/oauth-protected-resource followed by the path of the server’s audience: for https://gw.example.com/mcp, that’s /.well-known/oauth-protected-resource/mcp.

Protect an MCP server walks through it. In short, with the admin API at https://foobar.cvyuh.com/api/v0/am (Call the API):

  1. Create the MCP resource types your server needs, each covering its names and listing the methods that act on it. For a server whose audience is https://gw.example.com/mcp:

    resourceTypepatternsactions
    toolhttps://gw.example.com/mcp/tool/*tools/call
    resourcehttps://gw.example.com/mcp/resource/*resources/read, resources/subscribe, resources/unsubscribe, completion/complete
    prompthttps://gw.example.com/mcp/prompt/*prompts/get, completion/complete
    taskhttps://gw.example.com/mcp/task/*tasks/get, tasks/result, tasks/cancel
    mcp_serverhttps://gw.example.com/mcptools/list, resources/list, prompts/list, tasks/list, logging/setLevel
  2. Create a policy set whose comparator is regex, and link the types to it. A regex set matches the whole name and respects case, as tool names want; start a pattern with (?i) to ignore case.

  3. Write a policy for each thing you allow, linked to the set and to its type. This one lets agents call get_weather:

    {
    "active": true,
    "resources": ["https://gw.example.com/mcp/tool/get_weather"],
    "actionValues": { "tools/call": true },
    "subject": { "type": "JwtClaim", "claimName": "principal_type", "claimValue": "agent" }
    }
  4. Tell the gateway which paths are the MCP server, its audience and the set: see Settings.

  • Header and body must agree. MCP clients repeat the method and name in Mcp-Method and, for tools/call, prompts/get and resources/read, Mcp-Name. A call whose headers disagree with its body, or that lacks a header its method needs, is refused, so a call can’t be decided as one tool and run as another. Mcp-Name may be sent as =?base64?<value>?=, Base64 of the UTF-8 name.
  • Only current protocol versions. A call without MCP-Protocol-Version, or with one older than 2026-07-28, is refused.
  • Bodies up to 1 MiB. A larger body is refused 413, never decided on its headers alone.
  • Letter case follows the policy set. In a regex set, Get_Weather is not get_weather unless the pattern starts with (?i). In a prefix set, the default, case is ignored.
  • Refusals speak MCP. A refusal keeps its HTTP status and its Bearer or DPoP challenge, with its reason in a JSON-RPC error body.
  • Listings aren’t filtered. tools/list, and the other listings, show every tool the server has, including ones the caller will be refused. A listing is decided for the server as a whole.
  • Behind your own proxy. The ext_authz check reads the body your proxy sends with it. A proxy that sends no body can be decided on the MCP headers alone with the headers-only setting, but only for tools/call, resources/read, prompts/get, the listings and the calls that pass on a token alone, and only when that proxy has already held the headers to the body: see Put the gateway behind your proxy.
  • The server gets its own token, if you ask. With token swap on, each allowed call goes on under a token meant for the MCP server; without it, the caller’s token goes through as it came.
Gateway settingWhat it does
JWT_AUDIENCEThe server’s resource name: the audience its tokens must carry, and where its metadata is published. Every MCP name sits under it
MCP_PATHSThe paths an MCP server answers at. A POST to one is decided as the call it makes. None by default
POLICY_SETThe set the calls are decided in
UPSTREAM_AUDIENCEThe MCP server’s own resource name. Set, each allowed call goes on under a token meant for it
SCOPESThe scopes its metadata names
The headers-only settingDecide a bodiless ext_authz check on its MCP headers alone (default off, which refuses such a check)

The rest are in Gateway configuration.

Each refusal’s body is a JSON-RPC error with a null id:

HTTP statusJSON-RPC codeWhen
400-32020A header is missing, malformed or disagrees with the body; the protocol version is older than 2026-07-28; the body isn’t a JSON-RPC message
400-32602The call lacks what it’s decided on, such as a tools/call with no name
403-32001A method the gateway doesn’t decide, or a policy refuses the call
413-32001The body is over 1 MiB

The headers and body are checked first. A well-formed call with no valid token is then refused 401 with its challenge, as at any other path the gateway guards.

WhatDefaultCan it change?
A request body on an MCP pathUp to 1 MiBNo
Oldest protocol version2026-07-28No
Resource typestool, resource, prompt, task, mcp_serverNo: create the ones your server needs
Name matchingAs the policy set’s comparator: prefix ignores case, regex respects itPer policy set
ListingsDecided for the server as a wholeNo

A refused call gets the HTTP status and challenge any refusal gets, with a JSON-RPC error body that MCP clients show to the user or the model, under Errors. A client without a token gets 401 and the address of the server’s metadata, and starts its sign-in from there.

The gateway’s MCP decisions aren’t on the audit trail yet. Each refusal is a warning line in the gateway’s own log, with the path and the reason, and with the call it was decided as. A decision the gateway asks the realm for is a POLICY_DECIDED record, naming the tool, resource or prompt. See Logs and tracing.

SymptomCauseFix
Every call is 403 no_policies_loadedThe MCP resource types aren’t linked to the policy set, or no policy is linked to themLink each type to the set, and each policy to its set and type
Get_Weather is refused though get_weather is allowedA regex set matches caseUse the tool’s exact name, or start the pattern with (?i)
Every call is 400 with -32020The client is on an older protocol version, or doesn’t send Mcp-Method and Mcp-NameUpdate the client to 2026-07-28 or later
Every call is 401 invalid_tokenJWT_AUDIENCE isn’t the server’s audience, such as https://gw.example.com/mcpSet it to the audience clients ask tokens for
Calls are decided as plain HTTP, not as toolsThe path isn’t in MCP_PATHSAdd it
A tool the caller can’t call shows up in tools/listListings aren’t filteredExpected: the call itself is refused