Skip to main content
The bridge functions (callToolViaGateway and callToolViaGatewayWithAgent, exported from sec0-sdk/middleware) are the client-side interface for routing tool calls through the gateway. They construct the HTTP request with all required headers (auth, trace context, agent state, idempotency key, and AP2 mandates) then forward to the gateway’s POST /mcp/:server/:toolAtVersion endpoint. The gateway validates, enforces policy, and proxies to the upstream tool server, preserving full custody chain continuity.

callToolViaGateway (BridgeCallOptions)

agentState (AgentStatePayload)

callToolViaGatewayWithAgent (AgentBridgeCallOptions)

AgentBridgeCallOptions is BridgeCallOptions plus an agent block (and without agentState).

agent

buildIdempotencyKey

Returns a composite key built from runId, nodeId, toolAtVersion, and a short digest of args. For deterministic keys, pass stable runId and nodeId values; if runId is omitted, the helper generates one.