Repository navigation
Releases
v0.6.1
A changed record says what changed
An approval that no longer applies because its record changed was refused
with "the record changed", and asking again showed the new record with
nothing marking what was different, so a person would approve the second
question as they had the first. Now:
- The refusal names each field with its old and new value:
What changed: order.total: 812.00 → 812.01. - The next question about the same call (same tool, caller and arguments)
starts withChanged since you were last asked: …, in the client's form
and on the terminal. Over the 2026-07-28 round trip, where a stale answer
is asked again rather than refused, the question asked again does too. - That stale answer is now on the record: the round trip's
pendingline
readsapproval asked again: resource changed while awaiting approval,
withchangedandcontinues. Before, the log showed two ordinary
pendinglines. ApprovalRequest.changescarries the lines for custom approvers.- The audit line of the refusal lists the field names in
changed. Names
only, never values. Load(changed_values=True)lets a record withdescribe=show values in
its change lines. The demo uses it.
A masked field is named without its values, and so is every field of a
record whose Load has describe=, unless it passes
changed_values=True. What changed is only shown: the approval still
binds to the record's state exactly as before, and the question's digest
leaves the change lines out, so the answer to a question that showed them
still matches. The memory is per process and lasts an hour.
v0.6.0
Breaking: authorization is a runtime invariant
Every tool call now needs a verified caller, an explicit policy, and a
decision on the record it acts on. Anything missing fails closed. To
migrate a server:
- Give every tool
authorize=: your policy, orany_callerwhere any
verified caller may use it. A tool without one raises at registration. - Over stdio, and for in-memory clients, declare who calls are for:
Gatehouse(..., local_caller=Caller(...)). Without a token or a local
caller, calls are denied.local_callernever applies to an HTTP
request: an HTTP request without a verified token is denied even on a
server that declares one. - Create the
Gatehousebefore registering any tool, and register every
tool through it. A server that already has tools is refused, and
@mcp.tool(),add_tool,MCPServer(tools=...)and extension tools
are refused on a gated server. - Resources, prompts and completions are refused on a gated server, like
tools registered around the gate: they reached the same data with no
policy and no caller check. Register content that is the same for every
caller with@gatehouse.open_resource(uri)or@gatehouse.open_prompt()
(a verified caller is required to read it). Move anything per caller,
including a resource template that picks a record, to a READ tool with a
policy. A server that already has any of them when theGatehouseis
created is refused. - A server with an SDK
Extensionthat serves request methods of its own
(Extension.methods()) or overridesintercept_tool_callis refused
when theGatehouseis created: both answered with no policy and no
audit line, and an interceptor ran before the gate. - A WRITE or DESTRUCTIVE tool that loads a record needs
consistency=:Transaction(...),ConditionalWrite()or
AcceptRace("why"), per tool or as theGatehousedefault. - A tool that returns a list of records (
list[T],tuple[T, ...]or
Sequence[T]of Pydantic models, dataclasses, TypedDicts or mappings)
needsauthorize_items=(orany_item). That includes one arm of a
union (list[Order] | None), items that may be records
(list[Order | None]) andtypealiases.authorize_itemson a tool
that returns anything else is refused. - A
Loadparameter on a tier that requires approval must be a Pydantic
model, a dataclass, a TypedDict or a mapping, or give
Load(..., fingerprint=...), so the approval can bind to the record's
state. Anything else is refused at registration. - A
LoadorScopeparameter can't have a default, can't be
positional-only or variadic, and must carry the marker as its own
Annotated[...]metadata, not nested in another type. A loader's
parameters must name the tool's own arguments. - Tool annotations must evaluate at registration. The gate reads them
with the defining scope's locals, so local classes and loaders work. - SDK
Resolve(...)parameters are refused on gated tools: the SDK runs
them before the gate. - A custom audit class whose
recordlists fixed keywords needs
**kwargs: the gate now passescaller,authz,resources,
items,consistency,withheldand more. - Authorization has a deadline: a loader, policy or
Scopethat takes
longer than five seconds in total is denied. Set
authorization_timeouton the tool or the Policy, orNoneto turn
the deadline off, which the audit log then shows. - Requires
mcp>=2.3.
Added
-
An authorization deadline. Loaders, the policy and any
Scopeshare
Policy.authorization_timeoutseconds, 5 by default. Past it the call
is denied asauthorization timed out: policy(orloading <name>, or
scope <name>), the tool doesn't run, and the model is told the call
can be retried.@gatehouse.tool(authorization_timeout=...)overrides it for
one tool.Noneturns it off, and every audit line for that tool then
carries"authorization_deadline": "off". -
on_authorization_timeout=Ask, on the Policy or one tool: a policy that
runs out of time puts the call to the approver with the reason
authorization timed outinstead of denying. A loader orScopethat
runs out still denies. -
Sync loaders, policies and scopes run on the gate's own worker threads,
not anyio's default pool, so hung ones can't leave sync tools without a
thread. Each tool has its own 40, so a policy hung on one tool doesn't
slow another tool's authorization. A sync step past the deadline is
abandoned and finishes in the background, keeping its place until it
does, with a warning on stderr: a policy that never returns ties up at
most its own tool's 40 threads, and that tool's later calls are denied
at the deadline without starting more. Inside a syncTransactionthe deadline is checked between
steps, and a late answer rolls the transaction back. The transaction's
one thread is also the tool's own (40 per tool), not the default pool,
so a policy hung inside it can't leave sync tools elsewhere without a
thread. -
A call cancelled while the gate is authorizing doesn't start its tool,
sync or async, inside aTransactionor not: the transaction rolls
back and the line sayscancelledwith reasonauthorizing. A call
cancelled after its tool started saystool running, with the tool's
duration_ms. -
Audit sinks.
AuditLog(sink=...)hands each record, as a dict, to
anything with awrite(record)method (theAuditSinkprotocol), as
an alternative topath=andstream=. Two sinks ship with the
library:JsonlSink, the JSON-lines file or stream thatpath=and
stream=use, andCallableSink(fn). A fileJsonlSinkopens gets
each record as one unbuffered write of the whole line; a write that
fails part way (a full disk) is cut back off, so the file holds only
whole lines and a record sent to stderr never lands in it later. A sink that raises doesn't lose
the record: it is written to stderr as one JSON line with a
sink_errorfield naming the exception type, and the call goes on.
The record's fields are documented in the README, field by field, and
indocs/audit-line.schema.json, a JSON Schema the test suite checks
every audit line against.examples/audit_otel.pyforwards records to
OpenTelemetry logs. -
ApprovalStore: where the round-trip approver remembers used
approvals, asspend(nonce, expires) -> bool.MemoryApprovalStoreis
the default and remembers per process;ElicitationApprover(store=...)
takes another.examples/approval_store_sqlite.pyis one on SQLite,
standard library only, for servers that share the SDK's request-state
key across replicas or restarts; its single-use guarantee is tested
across two processes. A store that raises denies the call, logged as
approval store error: <ExceptionType>. -
examples/approval_store_postgres.py: theApprovalStorecontract on
Postgres, for replicas on several hosts. Single use under concurrent
spenders (primary key andON CONFLICT DO NOTHING), expired rows swept
with a grace for clock drift between replicas, and Postgres unreachable
raises, so the gate denies. Needspsycopg; the library doesn't import
it. Its tests run whenGATEHOUSE_TEST_POSTGRES_DSNnames a database,
and skip otherwise. -
BufferedSink(inner, *, maxsize=10_000): audit writes off the request
path.writeputs the record on a bounded queue and returns; one
background thread writes the queue toinnerin order. Standard
library only. Drop policy: when the queue is full the call never
waits; the record goes to stderr as one JSON line with
sink_error: "queue full"and is not queued, so stderr is its only
copy.close()drains everything written before it, then closes
inner; buffers nobody closed are drained at interpreter exit. A
record written afterclose()goes to stderr with
sink_error: "sink closed". SIGTERM skips exit hooks, so a buffer
created on the main thread installs a SIGTERM handler when none is set
(one already there is never replaced): records still queued go to
stderr withsink_error: "terminated", then the default SIGTERM ends
the process. An inner sink that raises anything, even a
CancelledError, loses only that record to stderr, and the buffer
goes on. -
External policy engines as the policy behind the gate:
examples/policy_opa.pyandexamples/policy_cerbos.py. Each sends
the caller, the tool, the action and the loaded record's attributes to
the engine over HTTP, standard library only, and maps the answer to
Allow,DenyorAsk. An engine that can't be reached is
Deny("policy engine unavailable"), and the model is told the
authorization service didn't answer and the call can be retried;
on_unavailable=Askputs those calls to the approver instead. An
engine that answers with an error or garbage, or leaves out an action
it was asked about, is a denial either way.
Each file carries the engine-side policy for the order-desk demo. The
library imports neither. -
Who each call was for. On servers that sign callers in with the MCP
SDK's auth (atoken_verifier, over streamable HTTP or SSE), every
audit line has acallerfield: the verified token'sclient_id,
subject,issuerandscopes, never the token itself. It is read
per request, so a token refreshed mid-session is logged as the new
one. Approvers get the same asApprovalRequest.caller, a new
Callertype, andterminal_approvernames the user and client in
its prompt. Names there are JSON-quoted with everything outside
printable ASCII escaped and cut at 80 characters, so a crafted
subject can't redraw the prompt or pass for someone else. Over stdio
nobody signs in: lines name the declaredlocal_caller, marked
"source": "local"; without one, every call is denied. -
Load(loader): a parameter the gate fills. It loads the record from the
model's arguments, your policy decides o...
v0.5.0
Added
ElicitationApprover: approval asked in the MCP client's own UI (MCP
elicitation), as a one-box form showing the tool, its tier and its
redacted arguments. It works under both protocol eras: mid-call over
the back-channel up to 2025-11-25, and as anInputRequiredResult
round trip from 2026-07-28. The round trip binds the approval to the
call's exact arguments, enforcesapproval_timeout, and lets each
approval run its call only once. A client that can't be asked hands
over tofallback, or the call is denied.- Audit outcome
pending: the approval was asked in the client over the
round trip, and the verdict follows on its own line.
Changed
- The demo asks for
cancel_order's approval in the client when it can,
so it works in Claude Code, Cursor and VS Code, and falls back to the
terminal prompt elsewhere.examples/orders_server.pydoes the same. - Registered tools that take no
Contextget a hiddengatehouse_context
parameter, kept out of the tool's input schema, so the gate can reach
the client. A tool parameter with that name is now refused at
registration.
Fixed
- The README said starting the client from an ordinary terminal lets you
approve the demo's prompt. Not for clients built on the MCP Python SDK:
its stdio client starts servers in a session of their own, with no
controlling terminal, soterminal_approveralways denies there. The
README now says which clients can prompt. terminal_approver's stderr denial says when the server has no
controlling terminal although stderr is one, instead of a bare
"no terminal for approval".
v0.4.0
Fixed
terminal_approvernow prompts. It used to deny every call without
asking, on macOS and Linux.terminal_approverdenies instead of prompting when a full-screen
program, such as an MCP client's terminal UI, is using the terminal.- Pending approvals no longer block sync tools: approvers have their own
thread pool. - Cancelled calls are logged as
outcome: "cancelled". A call cancelled
during approval or while an async tool ran used to leave no record.
Added
Policy(approval_timeout=seconds): an unanswered approval is denied and
logged asapproval timed out. Off by default.ApprovalRequest.deadline, so an approver knows when the gate stops
waiting.
Changed
- Less work per call: the signature is read once and arguments are
redacted once. - The demo denies an approval left unanswered for two minutes.
v0.3.1
No code changes. Metadata only.
- The package Homepage and the MCP Registry
websiteUrlnow point to the
project page, https://nickgeorgeai.com/open-source/mcp-gatehouse, instead
of the general MCP guide. The README links it too.
v0.3.0
Fixed
- Sync tools no longer freeze the server. The SDK runs sync tools in a
worker thread, but it only ever saw the gatehouse's async guard, so a
gated sync tool ran on the event loop and stalled every other request
until it returned. The guard now does the thread offload itself. - Sync approvers no longer freeze the server either. While a human
considered aterminal_approverprompt, nothing else (reads, pings) was
served. Approvers now run in a worker thread too;terminal_approver
serializes its prompts so concurrent requests don't interleave. - An approver that raises is an audited denial, not a crash. Previously
the failure left no audit record, logged an ERROR traceback, and gave the
model only "Error executing tool". Now it is recorded as
outcome: "denied",reason: "approver error: <ExceptionType>", and the
model is told the approver failed. Still fails closed; the exception
message stays out of the log, as with tool errors. - The demo starts from any directory. It wrote
audit.jsonlrelative to
the working directory, so a client that launched it from/(desktop
clients do) crashed withRead-only file system. See the new audit path
options below. - Importing
mcp_gatehouse.demono longer createsaudit.jsonlas a
side effect.
Added
terminal_approveris public:from mcp_gatehouse import terminal_approver.
(mcp_gatehouse.demo.terminal_approverstill works.)DEFAULT_REDACTis exported, so you can extend rather than replace it:
Policy(redact=DEFAULT_REDACT | {"card_pin"}).AuditLog.path: the absolute path being written (Nonefor streams).
AuditLog(path=...)now expands~.- Demo CLI:
--audit-log PATH,$MCP_GATEHOUSE_AUDIT_LOG,--version, and
the chosen log path printed to stderr. Without either, it falls back to
~/.mcp-gatehouse/audit.jsonlwhen./audit.jsonlisn't writable. - Demo: a
list_orderstool (so the model can find an order ID), parameter
descriptions on every tool, fuller tool descriptions, and server
instructions/version. py.typed, so type checkers use the package's annotations.- Python 3.14 support, tested in CI.
Changed
- Redaction ignores
_and-as well as case when matching keys, so
apiKey,API-Keyandapi_keyare all caught byapi_key. Matching
is still whole-key (token_countis not redacted). - More keys redacted by default:
passwd,passphrase,
access_token,refresh_token,id_token,client_secret,
x_api_key,private_key,cookie,set_cookie. Both changes only
ever mask more, never less. If you relied on one of these values
appearing in the log, pass an explicitPolicy(redact=...). __version__is read from the installed package metadata instead of a
hand-kept copy.- Quickstart uses
terminal_approverinstead of aninput()approver,
which reads stdin and so corrupts the stdio transport.