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.
Before you begin
Section titled “Before you begin”- 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 version2026-07-28or later.
How it works
Section titled “How it works”A client calls the server through the gateway, repeating the method and the name it acts on in headers:
POST /mcp HTTP/1.1Host: gw.example.comAuthorization: DPoP eyJ…DPoP: eyJ…MCP-Protocol-Version: 2026-07-28Mcp-Method: tools/callMcp-Name: get_weatherContent-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 method | Decided as | Resource name |
|---|---|---|
tools/call | tool | <audience>/tool/<name> |
resources/read, resources/subscribe, resources/unsubscribe | resource | <audience>/resource/<uri> |
prompts/get | prompt | <audience>/prompt/<name> |
completion/complete | prompt or resource, as its reference says | as above |
tasks/get, tasks/result, tasks/cancel | task | <audience>/task/<taskId> |
tools/list, resources/list, prompts/list, tasks/list, logging/setLevel | mcp_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.
Set it up
Section titled “Set it up”Protect an MCP server walks through it. In short, with the admin API at
https://foobar.cvyuh.com/api/v0/am (Call the API):
-
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:resourceTypepatternsactionstoolhttps://gw.example.com/mcp/tool/*tools/callresourcehttps://gw.example.com/mcp/resource/*resources/read,resources/subscribe,resources/unsubscribe,completion/completeprompthttps://gw.example.com/mcp/prompt/*prompts/get,completion/completetaskhttps://gw.example.com/mcp/task/*tasks/get,tasks/result,tasks/cancelmcp_serverhttps://gw.example.com/mcptools/list,resources/list,prompts/list,tasks/list,logging/setLevel -
Create a policy set whose
comparatorisregex, and link the types to it. Aregexset matches the whole name and respects case, as tool names want; start a pattern with(?i)to ignore case. -
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" }} -
Tell the gateway which paths are the MCP server, its audience and the set: see Settings.
Good to know
Section titled “Good to know”- Header and body must agree. MCP clients repeat the method and name in
Mcp-Methodand, fortools/call,prompts/getandresources/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-Namemay 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 than2026-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
regexset,Get_Weatheris notget_weatherunless the pattern starts with(?i). In aprefixset, the default, case is ignored. - Refusals speak MCP. A refusal keeps its HTTP status and its
BearerorDPoPchallenge, 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_authzcheck 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 fortools/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.
Coming next
Section titled “Coming next”- MCP tool federation: one endpoint for many servers’ tools. See What’s next for MCP servers.
Reference
Section titled “Reference”Settings
Section titled “Settings”| Gateway setting | What it does |
|---|---|
JWT_AUDIENCE | The server’s resource name: the audience its tokens must carry, and where its metadata is published. Every MCP name sits under it |
MCP_PATHS | The paths an MCP server answers at. A POST to one is decided as the call it makes. None by default |
POLICY_SET | The set the calls are decided in |
UPSTREAM_AUDIENCE | The MCP server’s own resource name. Set, each allowed call goes on under a token meant for it |
SCOPES | The scopes its metadata names |
| The headers-only setting | Decide a bodiless ext_authz check on its MCP headers alone (default off, which refuses such a check) |
The rest are in Gateway configuration.
Errors
Section titled “Errors”Each refusal’s body is a JSON-RPC error with a null id:
| HTTP status | JSON-RPC code | When |
|---|---|---|
400 | -32020 | A 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 | -32602 | The call lacks what it’s decided on, such as a tools/call with no name |
403 | -32001 | A method the gateway doesn’t decide, or a policy refuses the call |
413 | -32001 | The 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.
Limits and defaults
Section titled “Limits and defaults”| What | Default | Can it change? |
|---|---|---|
| A request body on an MCP path | Up to 1 MiB | No |
| Oldest protocol version | 2026-07-28 | No |
| Resource types | tool, resource, prompt, task, mcp_server | No: create the ones your server needs |
| Name matching | As the policy set’s comparator: prefix ignores case, regex respects it | Per policy set |
| Listings | Decided for the server as a whole | No |
What the client sees
Section titled “What the client sees”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.
Audit record
Section titled “Audit record”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.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
Every call is 403 no_policies_loaded | The MCP resource types aren’t linked to the policy set, or no policy is linked to them | Link each type to the set, and each policy to its set and type |
Get_Weather is refused though get_weather is allowed | A regex set matches case | Use the tool’s exact name, or start the pattern with (?i) |
Every call is 400 with -32020 | The client is on an older protocol version, or doesn’t send Mcp-Method and Mcp-Name | Update the client to 2026-07-28 or later |
Every call is 401 invalid_token | JWT_AUDIENCE isn’t the server’s audience, such as https://gw.example.com/mcp | Set it to the audience clients ask tokens for |
| Calls are decided as plain HTTP, not as tools | The path isn’t in MCP_PATHS | Add it |
A tool the caller can’t call shows up in tools/list | Listings aren’t filtered | Expected: the call itself is refused |
Related
Section titled “Related”- Protect an MCP server: the task, start to finish.
- Token swap: each MCP server gets a token of its own.
- Bound tokens at the gateway: agents’ tokens bound to their key.
- Policies: writing the rules.