Skip to main content

Module tool_auth

Module tool_auth 

Source
Expand description

MCP caller-auth helper types and pure policy decisions.

This module deliberately avoids concrete #[tool] handlers. It keeps the reusable identity snapshot / Bearer parsing / early trade-scope policy out of tools.rs, while tools.rs remains the thin dispatch surface.

Structsยง

CallerSnapshot ๐Ÿ”’
Caller authenticated identity snapshot returned by MCP auth guards. Captured once at auth time; subsequent response filtering / push subscriber registration / visibility uses this snapshot rather than re-resolving from Bearer/startup (้˜ฒ SIGHUP reload race / drift between auth decision and side effect).

Enumsยง

EarlyTradeScopeDecision ๐Ÿ”’
Pure decision logic for early trade-scope check.

Functionsยง

decide_early_trade_scope ๐Ÿ”’
http_bearer_token ๐Ÿ”’
Extract HTTP Authorization: Bearer <token> from rmcp RequestContext.
outcome_key_id_from_snapshot ๐Ÿ”’
Compute the audit key id from the same snapshot used by the write precheck. This prevents SIGHUP reload between daemon dispatch and audit emission from re-attributing an outcome to the startup key or <none>.
scope_label ๐Ÿ”’
Scope enum -> human-readable label for early-reject error messages.