Server data from the Official MCP Registry
Authorization for MCP servers: caller, policy and a decision on record before every tool runs
About
Authorization for MCP servers: caller, policy and a decision on record before every tool runs
Security Report
Valid MCP server (1 strong, 3 medium validity signals). 2 known CVEs in dependencies Package registry verified. Imported from the Official MCP Registry.
4 files analyzed · 3 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
Permissions Required
This plugin requests these system permissions. Most are normal for its category.
How to Install
Add this to your MCP configuration file:
{
"mcpServers": {
"mcp-gatehouse": {
"command": "uvx",
"args": [
"mcp-gatehouse==0.6.1"
]
}
}
}Some servers take additional arguments. See the repository for details.
Documentation
View on GitHubFrom the project's GitHub README.
mcp-gatehouse
Project page & docs: nickgeorgeai.com/open-source/mcp-gatehouse · PyPI
Authorization as a runtime invariant for MCP servers. Every tool call needs a verified caller, an explicit policy, and a decision on the record it acts on, made by the server before the tool runs. If any of those is missing, the call doesn't run. Around that: permission tiers, approval gates, and an audit log of every call.

Most MCP servers hand the model every tool at full strength and keep no
record of what it did. That's fine for a demo. It's not fine the day an
agent has write access to your CRM, your books, or your order system.
mcp-gatehouse is the missing gate, enforced inside the server — no
proxy, no external policy service. It depends only on the official
mcp SDK and
opentelemetry-api, which the SDK already requires.
pip install mcp-gatehouse
Upgrading from 0.5? 0.6.0 fails closed. A tool without
authorize=doesn't register, and over stdio a server withoutlocal_caller=denies every call. Pinmcp-gatehouse<0.6until you've migrated; the migration steps are one short list.

The demo server in Claude Code: the model asks to cancel an order, the gate asks you in Claude Code's own UI, and the call runs. Then it tries an order that isn't yours, and the policy refuses it before anyone is asked. The audit log has a line for every call, with who it was for and why it was refused.
The 1:21 demo runs the package's demo server in a terminal: the install, the one-decorator change, a cancel refused and one approved, and the audit log they left. No sound.
What you get
| Authorization on the record | Every tool names a policy. The gate loads the record the call is about from the model's arguments, your policy decides on it, and the tool gets that same object. The model can't describe a record into existence or reach one that isn't the caller's. |
| No way around the gate | A tool without a policy doesn't register, the server refuses tools, resources, prompts, completions and SDK extension methods or interceptors registered around the gate, and a call with no verified caller is denied. Each opt-out is explicit and marked in the audit log. |
| Check and write together | The policy's decision and the tool's write share one transaction you supply, or the write carries the checked state in its own condition. A record that changes after the check is never acted on. |
| Lists filtered per item | A tool that returns records gets each one checked: what the caller may not see never reaches the model. |
| Permission tiers | Every tool is declared READ, WRITE, or DESTRUCTIVE — and the tier also emits honest spec ToolAnnotations (readOnlyHint / destructiveHint), which the wrapper won't let you override to lie. |
| Approval gates | Tiers you choose require a sign-off before the tool runs, asked right in the MCP client (Claude Code, Cursor, VS Code) or by any callable you write: a terminal prompt, a Slack ping, a ticket. Fails closed: a gated tool with no approver configured is denied, not waved through. |
| Audit log | One record per call — allowed, denied, failed, or cancelled — with UTC timestamps and durations, who each call was for, and the policy's real reason for every refusal, in a documented schema. Append-only JSONL by default, or any sink you give it: a function, OpenTelemetry, your logging pipeline. The answer to "what did the AI actually do, and for whom?" six months later. |
| Redaction | Argument keys you name (api_key, password, token, client_secret, … by default) are masked before they reach the log or the approver — however they're spelled: apiKey, API-Key and api_key are the same key. |
| Denylist | Block a tool outright, whatever its tier. |
Quickstart
from typing import Annotated
from mcp.server.mcpserver import MCPServer
from pydantic import BaseModel
from mcp_gatehouse import (
AccessTier, Allow, AuditLog, AuthorizationRequest, Caller, ConditionalWrite, Deny,
ElicitationApprover, Gatehouse, Load, Policy, terminal_approver,
)
class Order(BaseModel):
"""Your record. Any Pydantic model, dataclass or mapping will do."""
id: str
owner: str
status: str
mcp = MCPServer("order-desk")
gatehouse = Gatehouse(
mcp,
# Ask in the client's own UI; prompt on the terminal if it can't show a form.
policy=Policy(approver=ElicitationApprover(fallback=terminal_approver)),
audit=AuditLog(path="~/order-desk/audit.jsonl"),
# Over stdio nobody signs in, so say who the calls are for.
local_caller=Caller(client_id="local", subject="alice"),
)
def load_order(order_id: str) -> Order | None:
"""Your system of record. None means there's no such order."""
...
def owner_only(request: AuthorizationRequest) -> Allow | Deny:
order = request.resources["order"]
return Allow() if order.owner == request.caller.subject else Deny("not the owner")
@gatehouse.tool(tier=AccessTier.READ, authorize=owner_only)
def lookup_order(order_id: str, order: Annotated[Order, Load(load_order)]) -> str:
"""Look up an order's status."""
return order.status
@gatehouse.tool(
tier=AccessTier.DESTRUCTIVE,
authorize=owner_only,
consistency=ConditionalWrite(), # the cancel's UPDATE checks the order's version
)
def cancel_order(order_id: str, order: Annotated[Order, Load(load_order)]) -> str:
"""Cancel an order. Runs only if it's the caller's and the approver says yes."""
...
mcp.run()
That's the whole integration: build your MCPServer exactly as the SDK
docs show, but create the gatehouse first and register every tool through
it. The model sees order_id and nothing else; the gate loads the order,
your policy decides on it, and the tool gets the order the policy saw.
Schema generation (including Annotated[..., Field(description=...)]
parameter docs), transports, and everything else work unchanged. Sync tools
still run in a worker thread, exactly as they would on a bare MCPServer.
Authorization: a runtime invariant
Most servers leave authorization to each tool, and nothing notices when one forgets. Here the server enforces it. Every call needs three things, checked in the server before the tool runs:
- A verified caller. That's the identity in the access token the SDK
verified for the request. Over stdio, where nobody signs in, it's the
local_calleryou declare. An HTTP request with no verified token is nobody, even on a server that declares a local caller. - An explicit policy.
authorize=is required on every tool. - A decision on the record itself. The gate loads each
Loadparameter from the model's arguments, gives the records to your policy, and hands the tool those same objects.
If any of the three is missing, the call is denied. Gatehouse doesn't know your business rules. What it guarantees is that they run at the right place, and that nothing gets around them:
- A tool without
authorize=raises at registration, so the server doesn't start. - The server refuses tools added around the gate. That covers
@mcp.tool()andadd_toolbefore or after the gate is created,MCPServer(tools=...), extension tools, and a tool slipped into the registry. A refused tool is hidden fromtools/listand denied when called. - Resources, prompts and completions are other ways to the same data, and
they have no policy: a template
orders://{order_id}would read the record a tool checks, for anyone. So the server refuses them too, before or after the gate is created. Content that is the same for every caller (docs, a schema, a price list) goes through@gatehouse.open_resource(uri)or@gatehouse.open_prompt(), and a read without a verified caller is refused. These write no audit line. Anything that depends on who is asking belongs in a READ tool with a policy. Completions are refused outright: the SDK never tells the handler who is asking. - An SDK
Extensiongets the same treatment. Its tools and resources are refused with the rest, and so is a server whose extension serves request methods of its own (Extension.methods()) or overridesintercept_tool_call: both answer with no policy and no audit line. What the gate guards is the SDK's public registration surface. Code that writes into the SDK's private registries (a template put straight into_resource_manager._templates), adds a low-level request handler after the gate, or adds request middleware to the low-level server (server.middleware, provisional in the SDK, which wraps every request,tools/callincluded, and can answer before the gate does), runs with your server's trust, like any other code you install in it. - Nothing the gate fills can come from the model. A
Loadparameter never appears in the input schema, and registration fails if the SDK would put it there.
Each requirement has a way out, but only one you write down, and the audit log shows it:
| Requirement | Applies to | Declared with | Deliberate opt-out | Audit line shows |
|---|---|---|---|---|
| Verified caller | every call | the SDK's auth (token_verifier) | local_caller= (stdio only) | caller (local ones: "source": "local") |
| Policy | every tool | authorize= | authorize=any_caller | authz: "open" |
| Item filtering | tools returning a list of records | authorize_items= | authorize_items=any_item | items: "open" |
| Check and write in one unit | WRITE/DESTRUCTIVE tools that Load | consistency= (per tool, or on the Gatehouse) | consistency=AcceptRace("why") | consistency: "accept-race" and the reason |
Where it sits
Three layers can say no to a tool call. They see different things, and they don't compete:
- Agent-framework approvals live in the agent process, beside the model. They see the tool's name and the arguments the model proposed, and can ask a person before the call leaves the agent. They don't see the record, and a server reached by another client never meets them.
- Gateways, proxies and policy services sit in front of the server. They see the token, the tool name and the arguments, so they can decide which clients reach which tools, enforce scopes, rate-limit, and route. They don't see the record either, and whether the tool behind them checks it is up to that server.
- The gate is the check inside the server, on the record the call is about, for the caller the transport verified. The layers in front assume someone writes that check. This is the one that makes writing it mandatory: a tool without a policy doesn't register.
Use all three. An identity layer issues the token the SDK verifies and the
gate reads. A gateway narrows what reaches the server. Framework approvals
catch the agent's own mistakes early and cheaply. The gate decides on the
record, and keeps the trail. A team with a central policy engine keeps
its rules there and lets the gate call it:
examples/policy_opa.py and
examples/policy_cerbos.py send the caller,
the tool, the action and the loaded record to the engine. An engine that
can't be reached is a denial, and the model is told the call can be
retried, so "not now" doesn't read like "no". on_unavailable=Ask sends
those calls to your approver instead.
By design, mcp-gatehouse is none of the other layers. It is not a
proxy or a gateway, has no control plane, mints or exchanges no tokens,
and has no policy language: policies are Python, or a call to the engine
you already run.
It guards calls through this server, and only those. A script, a service
or another agent that reaches the database or API behind the tools
directly never meets the gate, and nothing the gate does can stop it. To
make the checks hold on every path, enforce them in the backend too. Give
the server the narrowest credential that does its work, not a shared
admin account. Have the backend check the caller itself, as
examples/orders_postgres.py does: the
Transaction factory sets app.subject from the verified caller, and
Postgres row-level security limits every query to that user's rows,
whoever connects. Don't hand other clients a credential that skips those
checks. Short-lived, narrowly scoped tokens for the services behind the
tools come from your identity provider. The gate checks the ones it
receives (scopes=, request.claims) and passes the caller on, but
doesn't issue them.
It is also not a workflow layer. The gate checks one call at a time and
keeps no workflow state, so a job that another agent picks up after a
dropped call resumes from wherever your workflow stores it, not from the
gate. Nor does it confirm what landed. outcome: "ok" means the tool
returned without raising; under Transaction it also means the commit
succeeded. For a tool that calls a calendar, a CRM or a payment service,
it means the call returned, not that the change is there. Two things
help a retry: Load reads the record again, so the policy decides on its
current state, not the state the last attempt saw, and a policy that
checks status refuses to cancel an order twice. Idempotency keys and
"did it land" checks belong to the tool or the workflow above it.
Policies
A policy is any callable, sync or async, that takes an
AuthorizationRequest and returns one of three decisions:
Allow().Deny(reason).Ask(reason): a person decides. The configured approver is asked, and sees the reason.Askwith no approver is a denial, whateverfail_closedsays.
Only a decision counts. A policy that returns True, None or anything
else, or that raises, has denied the call.
The request carries:
caller: who the call is for;resources: the loaded records;arguments: what the model sent, read-only;claims: the verified token's claims, read-only. They go to the policy only and are never logged.
def can_cancel(request: AuthorizationRequest) -> Decision:
order = request.resources["order"]
if order.owner != request.caller.subject:
return Deny("not the owner")
if order.status == "shipped":
return Deny("already shipped", message=f"Order {order.id} has shipped.")
if order.total > 500:
return Ask("order over $500")
return Allow()
The model gets the same answer for every refusal on authorization: "'X' is
not permitted for this caller." That covers a record that doesn't exist, one
that isn't theirs, and a loader or policy that failed, so it can't probe
which orders exist. The audit log records the real reason (not found: order, policy: not the owner). Deny(..., message=...) tells the model
more, when that's safe to say.
Load(loader, describe=..., fingerprint=..., changed_values=...):
-
The loader's parameters name the tool's arguments it loads from. A loader that returns
Nonemeans not found. -
The approver sees the record, not only the arguments the model chose. By default that is its fields as the audit log shows them, secrets masked (
order: id=4417 · customer=Blue Ridge Cabinets · status=packed · total=812.0);describereplaces it with a line you write ("order 4417 · Blue Ridge Cabinets · $812.00"). -
An approval binds to the record's state, by default a redacted snapshot of it, or what
fingerprintreturns. If the record changes while a person decides, the call is refused rather than run on something they never saw. The snapshot holds masked fields as«redacted», so a change to only a masked field (a rotatedapi_key, say) goes unseen; return it fromfingerprintif it matters. On a tier that requires approval, a record must be a Pydantic model, a dataclass or a mapping, or have afingerprint. -
A refusal for a changed record says what changed, and asking again shows the person the same thing first, so the second question doesn't read like the first:
'cancel_order': the record changed while the approval was pending, so the approval no longer applies. Nothing was done. What changed: order.total: 812.00 → 812.01. Calling again asks the person again, showing them what changed. Changed since you were last asked: order.total: 812.00 → 812.01. The AI wants to run cancel_order …Over the 2026-07-28 round trip there is no refusal: a stale answer is asked again the same way, and its
pendingline says so (approval asked again: resource changed while awaiting approval). A masked field is named without its values (order.api_key changed), and so is every field of a record whoseLoadhasdescribe, since you chose what the person sees; passchanged_values=Truewhen its fields may be shown. A change onlyfingerprintsees readsorder: a field that isn't shown changed. Custom approvers get the lines inApprovalRequest.changes, and the audit line lists the field names inchanged. What was asked is remembered per process for an hour: a question asked on another replica, or longer ago, still binds the same way but shows no changes.
Deadlines
A call gets five seconds to load its records and reach a decision: the
loaders, the policy and any Scope, together. Past that it is denied,
logged as authorization timed out: policy (or loading order, or
scope owner), and the tool doesn't run. The model is told this isn't a
refusal and the call can be retried, so "not now" doesn't read like "no".
Policy(authorization_timeout=2.0) # every tool
@gatehouse.tool(authorize=report_policy, authorization_timeout=30) # one tool
@gatehouse.tool(authorize=refund_policy, on_authorization_timeout=Ask)
on_authorization_timeout=Ask puts a call whose policy ran out of time
to the approver, with the reason authorization timed out, instead of
denying it. A refund then waits for a person rather than being lost. A
loader or Scope that runs out still denies: there is no record yet to
ask about. authorization_timeout=None turns the deadline off, and every
audit line for that tool says "authorization_deadline": "off".
Python can't stop a thread. A sync loader or policy past the deadline is
abandoned: the call ends, and the thread finishes in the background with
its result dropped. Those threads are the gate's own, not the pool sync
tools draw on, so a hung policy never leaves a sync tool without a thread.
Each tool has its own 40 of them, so a policy that hangs on one tool
doesn't make another tool's authorization wait. An abandoned thread keeps
its place until it really returns, and the gate says so on stderr: a
policy that never returns can tie up at most its own tool's 40 threads,
after which that tool's calls are denied at the deadline without starting
another. Give every blocking call in a sync policy its own timeout,
shorter than the deadline.
Inside a sync Transaction every step runs in one thread, so the
deadline is checked between steps: a slow policy runs to the end, then
counts as late, and the transaction rolls back. That thread is the tool's
own too, one of 40 per tool, so a policy hung inside a transaction never
takes a thread from sync tools elsewhere. But it isn't abandoned: it holds
its thread, and its call, until it returns. Set the database's
statement timeout for a query that hangs there. An async policy that
blocks without awaiting, such as a sync HTTP call inside async def,
stalls the whole server, and no deadline can reach it.
The check and the write
Loading once and handing over means the tool acts on the object that was checked. It doesn't stop that record changing in the database between the check and the write. A WRITE or DESTRUCTIVE tool that loads a record must say how that window is closed:
Transaction(factory).factory(caller)returns your context manager, sync or async. The gate runs the load, the policy, the tool and the commit inside it, and a refusal or an error rolls it back.- Lock the row in the loader (
SELECT … FOR UPDATE) and the decision still holds when the tool writes. - Loaders and the tool reach the transaction through
current_transaction(). - A sync transaction runs entirely in one worker thread, so drivers tied to their thread are safe. Everything inside it must then be sync. With an async transaction, the loaders and the tool are async.
- The gate never holds a transaction open while a person decides. It asks first, then opens the transaction, reloads and checks again.
- Lock the row in the loader (
ConditionalWrite(). The write carries the checked state in its own condition:UPDATE … WHERE id = ? AND version = ?. When it matches nothing, the tool raisesConflict. The log recordsoutcome: "conflict"and the model is told the record changed. The gate can't see your query, so this one is your promise.AcceptRace("why"). Accept the window on purpose. The reason goes on every audit line.
The gate guarantees that the check and the write share one unit, in that
order. Isolation (row locks, SERIALIZABLE) is your database's job.
examples/orders_postgres.py shows all of
it on Postgres.
Lists
"May alice update invoice 123?" is a check. "Show alice her invoices" is a filter, and filters belong in the data layer. The gate wires each layer to the verified caller and backstops it:
- Row-level security. The transaction factory gets the caller, so it
can
SET LOCAL app.subjectand let Postgres RLS limit every query the tool runs. Scope(fn). This fills a hidden parameter with a query filter computed from the caller: an owner, a tenant, or the IDs a relationship-based engine lists. Your query uses it.authorize_items=, the gate's backstop. A tool that returns a list of records must declare it. The gate checks each item it returned (action="read",resource=item), and onlyAllowkeeps one.- With layers 1 and 2 working, it withholds nothing.
- The
okline countswithheld, and flagsscope_mismatchwhen aScopewas in force. A nonzero count is an alarm that the query and the policy disagree.
The gate can only filter records it can see as items. A tool that formats rows into a string gets the call-level check alone, so return records. Filtering after the fetch also shrinks pages, so correct paging needs layer 1 or 2.
Allowed isn't the same as wanted
Perfect enforcement still lets a prompt-injected agent do anything the user is allowed to do. Authorization answers "may this happen?", not "did the user ask for this?". The gate holds two levers:
- Task-scoped credentials make "allowed" as small as the task.
scopes={"orders:cancel"}on a tool denies a token without that scope, before anything loads.- A policy can read
request.claims. It can require that the token'sauthorization_details(RFC 9396) name this exact order, so a token minted for "cancel 4417" can't cancel 4418. It can also checkact(RFC 8693) to tell an agent acting for alice from alice herself. - Issue short-lived, down-scoped tokens per task. The gate enforces them; it doesn't mint them.
- Confirmation for high-impact actions. DESTRUCTIVE needs approval by
default, and
Askadds it on your conditions. The approver sees the record (describe) and the reason, not only the model's arguments, which gives a person the chance to spot an action nobody asked for. Elicitation trusts the client to show the form to a person. For the tools that matter most, approve out-of-band (Slack, a ticket), where neither the model nor a compromised client can answer.
What no gate can do is infer intent. It limits the blast radius, puts a person in front of what can't be undone, and keeps a trail that makes misuse visible afterwards.
Approve in the client
ElicitationApprover puts the question in front of the person using the
MCP client, as a form with one box to tick. It shows the tool and its tier,
why the policy asked, who the call is for, the arguments (secrets already
masked) and each record the call acts on, as the server loaded it:
Approval needed (order over $500). The AI wants to run cancel_order (destructive) for "nick" via client "local" with:
{"order_id": "4417"}
on order 4417 · Blue Ridge Cabinets · packed · $812.00
MCP calls this elicitation. Claude Code, Cursor and VS Code support it. The model can't answer the form, and you run nothing beside the server.
It works under both protocol revisions in use:
- Up to 2025-11-25 the form goes to the client mid-call and the gate
waits for it, under
approval_timeoutlike any approver. - From 2026-07-28 there's no channel for that. The call hands the
question back to the client and runs when the client calls again with
the answer. The SDK seals that round's state and binds it to the tool
and its exact arguments. The gate also checks that the answer is to the
question it asked, that it arrived within
approval_timeout(an hour if none is set), and that each approval runs its call only once.
Anything but a ticked box (decline, cancel, closing the form, an unticked
box, a malformed answer) is a refusal. When the client can't be asked, the
fallback decides; with no fallback, the call is denied. A tool that runs
its own multi-round input flow, through Resolve(...) parameters or by
returning InputRequiredResult, gets the fallback too from 2026-07-28,
since one call has one such channel. Up to 2025-11-25 the form goes over
its own request, separate from the tool's rounds, so the client is asked
as usual.
Used approvals are remembered in an ApprovalStore, so each runs its call
once. The default, MemoryApprovalStore, remembers per process. That is
enough while the SDK's request-state key is per process too, which it is
by default. Each process seals its questions with a key of its own, so an
approval minted before a restart, or by another replica, fails the SDK's
seal check before the gate or its store ever sees it.
Replicas behind a load balancer, or a server that should honour approvals across a restart, need two things. First, every replica uses the same request-state key and the same server name, which the SDK binds each question to:
from mcp.server.request_state import RequestStateSecurity
KEY = os.environ["MCP_REQUEST_STATE_KEY"] # 32+ random bytes, the same on every replica
mcp = MCPServer("order-desk", request_state_security=RequestStateSecurity(keys=[KEY]))
Second, they share the store, or one approval runs its call once per
replica, and once more after each restart within approval_timeout. A
store is anything with spend(nonce, expires) -> bool. Two are examples
to copy:
examples/approval_store_sqlite.py,
standard library only, for replicas on one host, and
examples/approval_store_postgres.py,
on psycopg, for replicas on several. Both spend each nonce once under
concurrent spenders and sweep expired ones. A store that raises denies
the call, logged as approval store error.
ElicitationApprover(store=PostgresApprovalStore(os.environ["APPROVALS_DSN"]))
To rotate the key without dropping questions in flight, the SDK takes a
ring: keys=[old, new], then keys=[new, old], then keys=[new].
Elicitation trusts the client to show the form to a person. A client or hook set to accept forms on its own can approve too. When the approval must come from outside the client, use an out-of-band approver instead.
Other approvers
terminal_approver asks on the controlling terminal (/dev/tty), never
stdin — over stdio, stdin is the protocol pipe, so a plain input()
approver would corrupt it. An approver is any callable, sync or async,
that takes an ApprovalRequest and returns True to allow; sync ones run
in a worker thread from a pool of their own, so a human taking their time
doesn't stall other calls, and a pile of pending approvals can't take the
threads your sync tools need. If the approver raises (Slack down, ticket
API timing out), the call is denied and the failure is logged.
Give approvals a deadline so a sign-off nobody gives doesn't hang the call:
Policy(approver=terminal_approver, approval_timeout=120)
Past it, the call is denied and logged as approval timed out. Approvers
see the deadline as request.deadline (a time.monotonic() value), and
terminal_approver withdraws its prompt when it passes. A sync approver
should return by then too. One that doesn't finishes in the background, its
answer dropped, with a warning on stderr. Its thread keeps one of the tool's
40 approver threads until it returns. So an approver that never returns can
tie up at most its own tool's 40, and once they are all taken, that tool's
later approvals time out without starting more. Other tools keep their own
40. With no timeout set, the gate waits as long as the approver takes.
Under the default policy, DESTRUCTIVE requires approval and everything
is audited. Gate writes too with one line:
policy = Policy(require_approval=frozenset({AccessTier.WRITE, AccessTier.DESTRUCTIVE}), approver=terminal_approver)
Add your own secret-bearing keys without losing the defaults:
from mcp_gatehouse import DEFAULT_REDACT
policy = Policy(redact=DEFAULT_REDACT | {"card_pin"}, approver=terminal_approver)
The audit log
One record per call, whatever happened to it:
{"ts": "2026-11-06T14:02:11+00:00", "call_id": "4b1e0c9a6f2d47f1a3c85e0d2b7f9a61", "request_id": "7", "trace_id": "0af7651916cd43dd8448eb211c80319c", "span_id": "b7ad6b7169203331", "tool": "list_orders", "tier": "read", "outcome": "ok", "arguments": {}, "duration_ms": 0.31, "timings_ms": {"authorize": 0.05, "tool": 0.31, "filter": 0.04, "total": 0.42}, "withheld": 1, "caller": {"client_id": "local", "subject": "alice", "issuer": null, "scopes": [], "source": "local"}, "authz": "open"}
{"ts": "2026-11-06T14:02:38+00:00", "call_id": "…", "request_id": "8", "tool": "add_note", "tier": "write", "outcome": "ok", "arguments": {"order_id": "4417", "note": "call back", "api_key": "«redacted»"}, "duration_ms": 1.08, "caller": {…}, "authz": "allow", "resources": {"order": {"order_id": "4417"}}, "consistency": "conditional"}
{"ts": "2026-11-06T14:03:05+00:00", "tool": "cancel_order", "tier": "destructive", "outcome": "denied", "reason": "policy: someone else's order", "arguments": {"order_id": "4420"}, "caller": {…}, "authz": "deny", "resources": {"order": {"order_id": "4420"}}, "consistency": "conditional"}
{"ts": "2026-11-06T14:05:40+00:00", "tool": "cancel_order", "tier": "destructive", "outcome": "denied", "reason": "approver refused", "arguments": {"order_id": "4417"}, "caller": {…}, "authz": "ask", "resources": {"order": {"order_id": "4417"}}, "consistency": "conditional"}
The fields, and when each appears. The same table, as a JSON Schema the
test suite checks every line against, is
docs/audit-line.schema.json. No other
field is ever written.
| Field | Type | When |
|---|---|---|
ts | string, ISO-8601 UTC | always |
call_id | string, 32 hex | always: the gate's id for the call, the same on every line it writes. ApprovalRequest.call_id carries it to the approver |
request_id | string | when a live request is behind the call: its JSON-RPC id, cut to 128 characters. The client's choice, unique only per session |
trace_id, span_id | string, 32 and 16 hex | when the call runs in an OpenTelemetry trace: the client's traceparent, or a trace a configured OpenTelemetry SDK started |
continues | string, 32 hex | on the round that answers a round-trip approval: the call_id of the pending line that asked, whatever the verdict. That includes the pending line of a stale answer, which asks again |
tool | string | always |
tier | "read", "write", "destructive" or null | always; null only for an ungated tool |
outcome | "ok", "denied", "error", "conflict", "pending", "cancelled" | always |
reason | string | every outcome but ok. Denials carry the gate's real reason; errors carry the exception type only, never its message; cancellations say the stage |
arguments | object | always: the model's arguments after redaction. Never what the gate filled |
duration_ms | number | ok, conflict, and error or cancelled lines whose reason says the tool was running |
timings_ms | object: authorize, approval, tool, filter, commit, total | every line written by the tool's gate (all but the ungated tool and no verified caller denials from call_tool): milliseconds for each stage the call reached, and the total. filter only with an item policy, commit only with a Transaction |
caller | object: client_id, subject, issuer, scopes, and source: "local" for a declared local caller | once a caller is known: every line but the ungated tool and no verified caller denials |
authz | "allow", "ask", "deny", "open" | once the policy decided (open for any_caller). Absent on lines written before it ran: denylist, no caller, missing scope, loader error, not found |
resources | object: each Load parameter's name mapped to the redacted arguments it was loaded from | every line of a tool that loads records. Never the record itself |
items | "open" | every line of a tool with authorize_items=any_item |
consistency | "transaction", "conditional", "accept-race" | every line of a tool with consistency=, its own or the Gatehouse default |
consistency_reason | string | with "accept-race" |
authorization_deadline | "off" | every line of a tool with authorization_timeout=None: the deadline is turned off |
withheld | integer | ok lines of a tool with an item policy: items the caller may not see, removed |
filter_errors | integer | with withheld, when the item policy raised on some items |
scope_mismatch | true | with withheld, when a Scope was in force: the query and the policy disagree |
changed | array of strings | denials with reason resource changed while awaiting approval, and the round trip's pending line that asks again: the fields that changed since the person was asked (order.total, or reason), names only |
sink_error | string | only on the stderr copy of a line that didn't reach the sink: the exception type when the sink raised, "queue full", "sink closed" or "terminated" from a BufferedSink |
The outcomes: ok, the tool ran. denied, the gate refused, and reason
says why. error, the tool raised, or the transaction or item filtering
failed. conflict, a conditional write matched nothing because the
record changed. pending, the approval was asked in the client over the
2026-07-28 round trip: the verdict follows on a line of its own when the
client comes back, so a pending line with nothing after it is a question
nobody answered. cancelled, the client gave up or the server shut down
before the call finished: reason says when. authorizing and awaiting approval mean the tool never ran. tool running comes with duration_ms,
and the tool may have done part of its work. A sync tool can't be stopped
partway: its worker thread runs to the end, and the line says ok or
error as usual. A sync policy or loader can't be stopped either, but
the gate takes the cancellation as soon as it returns, before the tool
starts. Inside a Transaction that rolls the transaction back. The gate
only writes the line; the cancellation goes on as it would without it.
Tracing a call
call_id groups one call's lines; continues joins the two rounds of a
round-trip approval. To go further, out to the agent and the model, use
the trace. The MCP SDK opens an OpenTelemetry span for every request,
parented on the traceparent the client sends in the request's _meta,
and the gate writes that trace's trace_id and span_id on the line.
Find the line from a slow or failed span in your tracing backend, or the
span from a line. Nothing to configure: opentelemetry-api comes with
the SDK, and with no OpenTelemetry SDK set up the client's trace still
comes through.
The gate doesn't record model token usage, and has no field a client can
fill with it. It never sees the model, a number the client reports is
unverified, and the trace already joins the two: put token counts on the
client's LLM spans, as the OpenTelemetry GenAI conventions do
(gen_ai.usage.input_tokens), and they sit in the same trace as the
gate's line.
Documentation truncated — see the full README on GitHub.
Reviews
No reviews yet
Be the first to review this server!
More Developer Tools MCP Servers
Rea
Freeby Morluto · Developer Tools
Reverse engineer anything from your terminal or agent with one CLI and MCP server.
Paperclip
Freeby Paperclipai · Developer Tools
Trending hip-hop artist momentum scores across four cultural dimensions.
Scrapling
Freeby D4Vinci · Developer Tools
Web scraping with stealth HTTP, real browsers, and Cloudflare bypass. CSS selectors supported.
Toleno
Freeby Toleno · Developer Tools
Toleno Network MCP Server — Manage your Toleno mining account with Claude AI using natural language.
MCP Marketplace
Freeby mcp-marketplace · Developer Tools
Search and install MCP servers from inside your AI client.
mcp-creator-python
Freeby mcp-marketplace · Developer Tools
Create, build, and publish Python MCP servers to PyPI — conversationally.

