Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
45d3183
fix(checks): mask structuredContent and resource text, deny on a reda…
luanlorenzo Nov 5, 2026
7b61697
fix(gateway): reply to server requests with the session caller's cont…
luanlorenzo Nov 5, 2026
a731dd9
fix(backend): refuse a per-caller token source on an sse backend (ENG…
luanlorenzo Nov 5, 2026
d239024
fix(checks): keep the redact hook error out of the denial (ENG-965)
luanlorenzo Nov 5, 2026
967437c
fix(checks): mask structuredContent in one pass, deny past 128 levels…
luanlorenzo Nov 5, 2026
f10d569
fix(checks): mask tasks/result results (ENG-965)
luanlorenzo Nov 5, 2026
49c77d8
docs: state which result strings the redactor masks and what it costs…
luanlorenzo Nov 5, 2026
313b633
Revert "fix(backend): refuse a per-caller token source on an sse back…
luanlorenzo Nov 5, 2026
d5d7e0d
test(gateway): an sse stream keeps the session opener's credential (E…
luanlorenzo Nov 5, 2026
dbdf63a
docs: name which duplicate keys the redactor does not mask (ENG-965)
luanlorenzo Nov 5, 2026
94811bb
fix(checks): withhold a result with an ambiguous key or a hook cancel…
luanlorenzo Nov 6, 2026
861b327
fix(gateway): observe a message refused before the pipeline as a deny…
luanlorenzo Nov 6, 2026
826f2e6
fix(gateway): name no tool for a message refused before the pipeline …
luanlorenzo Nov 6, 2026
7d089fd
fix(checks): withhold a result or a read field of an unexpected type …
luanlorenzo Nov 6, 2026
8048505
docs: a null result field passes the redactor (ENG-965)
luanlorenzo Nov 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,35 @@ embed the gateway and supply their own implementations of:
the host already authenticated the caller)
- `gateway.Observer`: telemetry

`inspect.Hooks.Redact` masks string values, never object keys, in
`tools/call`, `resources/read` and `tasks/result` results: `content[].text`,
`content[].resource.text`, `contents[].text` and every string of
`structuredContent`. A client that matches keys without case could read a
value the hook never saw, so a result is withheld when the response, the
result, a content entry or its resource repeats a key or spells `result`,
`content`, `contents`, `structuredContent`, `text` or `resource` another way.
A result that is not an object, or one of those fields of an unexpected type
(a `content` that is not an array, a `text` that is not a string), is withheld
too. A `null` in any of those places carries no text and passes. Duplicate
keys inside `structuredContent` are masked.

The hook runs once per string, in turn: a `structuredContent` table of 1,000
rows by 10 columns costs 10,000 calls. They share the request's
`RequestTimeout` with the backend call, and a result still unmasked when it
expires is withheld.

A hook error withholds the result: the client gets `-32010`, and the hook's
error is never recorded.

A reply the gateway sends on its own to a server request carries the
context values of the session's latest request, so a `TokenSource`
resolves the same caller as for that request.

An `sse` backend opens its event stream once, at session start, with the
credential of the caller that opened the session. A token the caller
rotates later is not used on that stream; each message POST carries the
credential of its own request.

Import it the way any Go dependency is imported:

```sh
Expand Down
2 changes: 1 addition & 1 deletion audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
EventApprovalPending EventType = "mcp.approval_pending"
EventApprovalResolved EventType = "mcp.approval_resolved"
EventBudgetExceeded EventType = "mcp.budget_exceeded"
EventRedacted EventType = "mcp.redacted"
EventRedacted EventType = "mcp.redacted" // one per masked message; Fields["redactions"] (int) sums the hook counts
EventGuardrailBlock EventType = "mcp.guardrail_block"
EventSessionKilled EventType = "mcp.session_killed"
EventError EventType = "mcp.error"
Expand Down
4 changes: 3 additions & 1 deletion backend/sse.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import (
type SSEBackend struct {
// TokenSource, when non-nil, mints the outbound bearer token for each
// request (stream GET and message POSTs alike). Overrides any
// Authorization in the static headers.
// Authorization in the static headers. The stream GET calls it once,
// with Start's context: in the gateway, the request that opened the
// session. Each POST calls it with the context of its Send.
TokenSource func(ctx context.Context) (string, error)

// Client overrides the per-instance HTTP client. Set before Start.
Expand Down
Loading
Loading