Multi-tenant approvals let your application decide, per tenant, whether a tool call is allowed, denied, or needs human confirmation. eve's approval field takes an async function that receives the session, the full tool name, and the tool input. One adapter turns those into a request to your policy store. Tools, OpenAPI connections, and MCP connections all use the same adapter.
Use this with multi-tenant outbound auth when your own
API key, JWT, or app session establishes the tenant. In that pattern, your
credential store supplies the connection credential instead of OAuth.
You store tenant policy. It can be a few columns in PostgreSQL, a policy service, an authorization engine, or configuration in a KV store.
This adapter checks that the current caller and the caller who started the session belong to the same tenant. Then it asks your policy store:
agent/lib/tenant-approval.ts
import type { ApprovalContext, ApprovalStatus } from "eve/tools/approval";import { approvalPolicies } from "./approval-policies";type Surface = "connection" | "tool";function tenantIdOf(auth: ApprovalContext["session"]["auth"]["current"]): string | null { const tenantId = auth?.attributes.tenantId; return typeof tenantId === "string" ? tenantId : null;}export async function decideTenantApproval( surface: Surface, ctx: ApprovalContext,): Promise<ApprovalStatus> { const current = ctx.session.auth.current; const tenantId = tenantIdOf(current); const initiatorTenantId = tenantIdOf(ctx.session.auth.initiator); if (current?.principalType !== "user" || !tenantId || tenantId !== initiatorTenantId) { return { type: "denied", reason: "The session is not pinned to one tenant user." }; } const input = ctx.toolInput as Record<string, unknown> | undefined; if (typeof input?.tenantId === "string" && input.tenantId !== tenantId) { return { type: "denied", reason: "Tool input cannot select another tenant." }; } const policy = await approvalPolicies.decide({ tenantId, userId: current.principalId, resource: `${surface}:${ctx.toolName}`, input, }); switch (policy.decision) { case "allow": return { type: "approved", reason: policy.reason }; case "require-approval": return "user-approval"; case "deny": return { type: "denied", reason: policy.reason }; }}
For authored tools, ctx.toolName is the path-derived name such as transfer_funds. For connection tools, it includes the connection name, such as billing__updateSubscription or support__add_internal_note. Your policy service can match exact names, patterns for a whole connection, roles, amounts, environments, or any other rule the tenant sets.
The function runs for every call, so "user-approval" asks for a separate decision on each action. once() remembers approval for the tool across all inputs in the session. It does not create grants for a tenant.
Your provider decides the policy model. A common implementation checks tenant membership and looks for an exact resource rule, then a rule for the whole connection. It checks role and input thresholds, and it denies by default.
When a policy lookup fails, throw or deny. Never allow silently. Check authorization again inside execute for tools with side effects, because membership or policy can change while the session waits for approval.
An approval pauses the session, and the pause survives restarts and redeploys. A later request resumes the session. Your HTTP boundary must stop a caller from continuing or streaming another tenant's session. Save which tenant and user each session belongs to, and check it before you forward these requests:
POST /eve/v1/session/:sessionId, including answers;
GET /eve/v1/session/:sessionId/stream.
By default, only the caller whose turn requested the call can approve or cancel it. To change who may respond, add an approval response policy. The policy receives the responder as response.principal and the requester as request.principal. It runs for both Approve and Cancel.
For a four-eyes workflow, where a different person or role must approve, branch on response.decision. Allow deny so the requester can still cancel the call. For approve, reject a response.principal that matches request.principal, and check the responder's role.