import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject, type McpToolProfile } from "@decionis/agent-safe-pipeline"; import { McpBindingError } from "./McpIntentBinder.js"; import type { McpInvocation, McpToolBinding } from "./McpInvocation.js"; /** * One consequential MCP tool: what an operator declared about it, and what it * actually does. `invoke` runs only behind a claimed single-use grant, with * the arguments the authority evaluated. */ export interface McpTool { readonly binding: McpToolBinding; invoke(args: JsonObject): Promise; } /** * A tool an `agent-safe.profile.mcp/1` profile declares: only its name and * what it does. Its action, target, subject, consequential arguments and the * arguments it accepts are the profile's, read as data. */ export interface McpProfiledTool { readonly tool: string; invoke(args: JsonObject): Promise; } /** What the host knows about the session a call belongs to, never what the model sent. */ export interface McpSession { /** The subject the session is pinned to, verified by the host. */ readonly subject?: string; } export interface McpGuardOptions { /** Tools bound in code (`McpTool`), or declared by `profile` (`McpProfiledTool`). */ readonly tools: readonly (McpTool | McpProfiledTool)[]; /** The tool profile the profiled tools are declared in. */ readonly profile?: McpToolProfile; readonly authority: DecisionAuthority; readonly verifier: AuthorizationVerifier; readonly tenantId: string; readonly actor: IntentActor; readonly audit?: AuditRecorder; readonly capture?: IntentCapture; /** The boundary and workload this process is, bound into every intent. */ readonly signals?: ExecutionSignals; readonly boundaryId?: string; readonly workloadDigest?: string; readonly createIdempotencyKey?: (invocation: McpInvocation) => string; } export type McpRefusal = McpBindingError["code"] | "MCP_ARGUMENTS_MISMATCH" | string; /** * What became of one invocation. `executed` follows the executor's own * vocabulary rather than simplifying it: `null` is a tool that was authorized * and dispatched and whose outcome was lost, which is not the same answer as * "no" and must never be reported as one. Re-invoking on `null` would be a * second attempt at an effect that may already exist; reconcile instead. */ export type McpOutcome = { readonly executed: true; readonly intentHash: string; readonly verdict: "ALLOW"; readonly dossierId: string | null; readonly result: TResult; } | { readonly executed: false; /** Null when the invocation was refused before an intent existed. */ readonly intentHash: string | null; readonly verdict: "ALLOW" | "BLOCK" | "ESCALATE" | null; readonly dossierId: string | null; readonly reason: McpRefusal; } | { readonly executed: null; readonly intentHash: string; readonly verdict: "ALLOW"; readonly dossierId: string | null; readonly reason: "PROVIDER_OUTCOME_UNKNOWN"; }; /** * The authority boundary for MCP tool execution. * * MCP has already decided how the agent calls the tool. This decides whether * this exact invocation may run, and it is the only thing between a selected * tool and its effect: * * tool selected → arguments constructed → **guard** → intent → * enforce-and-bind → authority → atomic claim → the tool runs, once * * It is not an MCP server, an MCP registry, or a replacement for MCP's own * authentication. It holds no opinion about transports and depends on no MCP * SDK; a server hands it an invocation and gets back a verdict and, when the * verdict is ALLOW and the grant was claimed, a result. * * The property worth stating plainly: **arguments that change after the * authority is issued invalidate it.** They are inside the canonical intent * hash, so a changed argument is a different intent whose grant does not * match; and independently, the handler recomputes their canonical digest * immediately before the point of no return and refuses if it is not the one * the intent bound. A tool therefore receives the arguments a policy saw, or * receives nothing. */ export declare class McpGuard { private readonly bindings; private readonly tools; private readonly held; private readonly capture; private readonly executor; private readonly options; constructor(options: McpGuardOptions); /** * A tool as the guard holds it: a code binding as given, or a profiled * tool's binding read from the profile. A profiled tool the profile does * not declare is refused at construction, never governed by a guess. */ private static resolve; /** Every tool this guard governs, for a server publishing its tool list. */ governs(tool: string): boolean; /** * One invocation, through the lifecycle. `session` is the host's: the * subject it verified for this conversation. A tool that names a subject * argument is refused without one, or for another subject, before the * authority is asked; any tool's intent states it as `session.subject`. */ guard(invocation: McpInvocation, session?: McpSession): Promise>; private outcomeOf; } //# sourceMappingURL=McpGuard.d.ts.map