Karyo
Documentation/ Integration and extension

Connecting an agent

Karyo 2.1.1rendered at build time
On this page

Karyo exposes twelve read tools, six prepare tools and three proposal tools through /mcp. An agent uses your existing OIDC login and Karyo principal. Karyo hosts no assistant and calls no model for an agent. It does not accept agent API keys or create a principal on first use. An agent call never changes warehouse data: every write is a proposal that the person approves on the console's Approvals page (ADR 0054).

Agent access starts disabled for the installation and for each principal/client pair. Enabling access adds no Company, Business Unit or Facility grant and no catalogue action. It lets the agent read what the principal may read and prepare the changes the principal may make; the person still approves each change.

Before enabling access

An enabled agent receives warehouse data through its vendor. Karyo cannot enforce that vendor's retention or residency policy. The installation owner must choose whether to permit this export.

Live compatibility, as of the dated record Claude Code live proof:

Agent State
Claude Code 2.1.301 Proved live against a local installation behind HTTPS: sign in, a receive proposal approved on the Approvals page, the journal row, and the switch-off refusal passed live. The pick-read question showed the refusal plus an open-orders read, and a pick-list answer was not demonstrated live. Connect Claude Code gives the steps
Grok Bot Not yet proved live
OpenAI dots Not yet proved live

Grok Bot and dots need an installation on a public HTTPS address, which no proof has used. Do not describe either as compatible until a dated record in docs/release-evidence/ says so.

The primary OIDC provider must support OAuth client bootstrap and resource-specific audiences. The managed profile uses Keycloak 26.8 with the experimental resource-indicators and cimd features. Its anonymous registration policy has a quota of 200 clients, trusted registration sources and callback hosts, consent, explicit allowed scopes, and no supplied protocol mappers. Requests using karyo.read or karyo.write require S256 PKCE and cannot use password or implicit grants. CIMD client metadata must use HTTPS and the configured vendor domain. Karyo fetches no client metadata itself.

For an external provider, configure the equivalent claims and audience binding. Agent tokens must carry the user's subject, the configured issuer, karyo.read, and the OAuth client id in azp. A token that prepares or withdraws a proposal also carries karyo.write. Karyo requires an existing active binding for that exact issuer and subject. Additional console issuers do not become agent authorization servers automatically.

Configure and approve

  1. Set KARYO_MCP_RESOURCE_URI to the installation's public HTTPS URL ending in /mcp.
  2. Use that same value for the managed realm's resource URL and the application's agent audience.
  3. Configure the exact trusted registration host with KARYO_AGENT_DCR_TRUSTED_HOST when using managed anonymous registration.
  4. Enable karyo.agent.enabled at Company configuration key 0, or set KARYO_AGENT_ENABLED=true at deployment.
  5. Configure the agent with the public /mcp URL and complete the provider's sign-in and consent.
  6. Open that principal's Connected agents section on the console's Users page.
  7. Enable access for the exact OAuth client after checking the pending connection.

Enabling or disabling a principal's connection declares users.manage and reading it users.read (services/karyo-app/src/main/kotlin/com/karyo/app/agent/PrincipalAgentsResource.kt, PrincipalAgentsResource); the server also checks that the users.manage grant reaches that principal (services/karyo-app/src/main/kotlin/com/karyo/app/agent/AgentAccessAdministration.kt, AgentAccessAdministration). A read-only administrator can inspect connections but cannot enable or disable them. The account menu's Connected agents dialog lets a person inspect and disable their own connections. It never enables them. Disabling an agent does not sign the person out of the console.

Agent access is part of Core and off by default, and the Core demo and default install stories leave it off: connecting an agent is not part of the Core first-run path, and a Company administrator switches it on after the Core flow is proven (ADR 0052). While it is off, the console shows neither the Connected agents section nor the account menu's dialog; both appear once step 4 is done and the console reloads its session (ADR 0052). System, the setup account of a fresh installation, never has agents: enabling one for it is refused (ADR 0053).

The URI is environment-only and requires a restart. Installation and limit settings resolve only at Company configuration key 0; a Business Unit override cannot loosen them. Goods owners cannot write these keys. The deployment example is scripts/.env.prod.example. HTTP resource URLs are accepted only for literal loopback development.

KARYO_AGENT_READS_PER_MINUTE or the Company-layer karyo.agent.reads-per-minute property sets the budget. The default is a 60-token burst with refill at 60 requests per minute, per principal/client pair. Valid budgets are 1 through 6,000; invalid values fall back to 60. Protocol requests also consume this budget. A 429 includes the seconds to wait in Retry-After. Limits are local to the supported single application instance. Saturation of the bounded limiter fails closed.

Preparing a proposal asks for a person's attention, so it has its own budget: KARYO_AGENT_PREPARES_PER_MINUTE or karyo.agent.prepares-per-minute, 1 through 600, default 10, per principal/client pair. A proposal waits KARYO_AGENT_PROPOSAL_TTL_MINUTES or karyo.agent.proposal-ttl-minutes for its person: 1 through 1,440 minutes, default 15. An expired proposal never runs.

Connect Claude Code

These are the steps the live proof used with Claude Code 2.1.301. The agent signs in as the person, so the person who will approve changes runs them, and an administrator takes step 6.

  1. Give the installation an HTTPS public origin. The production application refuses an HTTP OIDC issuer, loopback included (IdentityConfigurationGuard). If a private certificate authority issues the certificate, start Claude Code with NODE_EXTRA_CA_CERTS set to that authority's certificate file, or it cannot reach the installation.
  2. Let the installation's Keycloak reach https://claude.ai/oauth/claude-code-client-metadata. Claude Code identifies itself with that client id metadata document (CIMD), which Keycloak fetches. The shipped realms allow the claude.ai domain for it.
  3. Add the server. The proof passed a file with --mcp-config holding {"mcpServers":{"karyo":{"type":"http","url":"https://<host>/mcp"}}}. claude mcp add --transport http karyo https://<host>/mcp adds the same entry; the proof did not use that command.
  4. In Claude Code run /mcp, choose karyo, then Authenticate. The browser opens Keycloak.
  5. Sign in as the person and grant access on the consent page. It names Claude Code and the karyo.read and karyo.write scopes. Claude Code also asks for offline_access, so the page lists Offline Access.
  6. Claude Code now reports that Karyo rejected the new credentials. This is expected: Karyo returns 403 agent-access-disabled until an administrator enables the client. The connection is listed as Access disabled in the person's Connected agents section on the Users page, under the client id https://claude.ai/oauth/claude-code-client-metadata. The administrator chooses Enable access.
  7. In Claude Code run /mcp, choose karyo, then Re-authenticate, and repeat step 5. /mcp then shows karyo with 21 tools.

What to expect from the session:

  • Claude Code negotiates MCP protocol 2026-07-28 and sends its capabilities inline, so Karyo does not send it a URL elicitation. The agent reports the approvalUrl in its reply and the person opens it. The elicitation path described under Prepare tools and proposals is not exercised by this client.
  • A principal that lacks a tool's action is refused with 403 and the message The mirrored REST action is required. A principal whose grants hold no fulfillment.read, such as an Integrator, cannot list pick orders. The same principal can list open orders, and Claude Code reports what it could read.
  • The person asks for a Facility by name. whoami returns each Facility's id with its name and code under untrusted, which is how the agent finds the id a tool takes.
  • To switch the agent off, the person chooses Disable access in the account menu's Connected agents dialog. The next call returns 403 agent-access-disabled, and the person's console session continues.

Discovery and authentication

The public discovery document is JSON at /.well-known/oauth-protected-resource. The resource-specific /.well-known/oauth-protected-resource/mcp path serves the same document. A 401 at /mcp for a missing, invalid or wrong-audience token includes a WWW-Authenticate pointer to discovery.

The document names the authorization server's issuer, <origin>/auth/realms/<realm>. A client that inserts /.well-known/oauth-authorization-server or /.well-known/openid-configuration before that path asks the origin root first, so nginx answers those two URLs with Keycloak's own metadata for the realm. Every other /.well-known/ path is a 404, never the console page: Claude Code stopped at "JSON Parse error" when the console's HTML answered 200 there. The routes are in the architecture overview.

The access token's audience must be exactly the configured resource URI, with no other audience. A normal console token with karyo-api cannot authenticate MCP. An MCP token cannot authenticate ordinary /api/v1 routes. Missing karyo.read returns 403 with insufficient_scope; so does a prepare or withdraw call whose token lacks karyo.write. A connection that is not yet approved or is revoked, or a disabled installation, returns 403 with problem type agent-access-disabled and no discovery challenge, so the client does not sign in again. A suspended principal returns 401 on the next request.

The server uses Streamable HTTP at one path. It does not expose a separate /mcp/sse endpoint. The Quarkiverse extension owns protocol negotiation and framing. Current stateless requests carry the protocol's headers and _meta; earlier negotiated requests use the extension's handling. Every request still authenticates its current token, including when it carries a protocol session id. A browser Origin must identify the resource's own origin. Server-to-server clients can omit Origin.

Read tools

Tool Existing REST operation Declared action
searchProducts ProductResource#listProducts products.read
getStockForProduct StockUnitResource#list inventory.read
listLocations LocationResource#listLocations layout.read
getKpis KpiResource#kpis inventory.read
getOccupancy OccupancyResource#occupancy inventory.read
listPickOrders PickOrderResource#list fulfillment.read
listShipments ShipmentResource#list fulfillment.read
listOpenOrders DeliveryOrderResource#listOrders orders.read
myWorkInbox WorkInboxResource#mine inventory.read
replenishmentNeeds ReplenishmentResource#needs tasks.read
recentActivity JournalResource#list inventory.read
whoami AuthSessionResource#me Authenticated self only

Each tool declares one catalogue action with @DeclaredAction, and it must equal the action its mirrored REST operation declares (services/karyo-app/src/test/kotlin/com/karyo/security/guards/AgentToolMirrorTest.kt, AgentToolMirrorTest.boundaryViolations). Before the call's arguments are converted, AgentDispatchFilter reads the principal's current grants and refuses a tool whose action the principal holds nowhere with HTTP 403 and JSON-RPC error -32001 (services/karyo-app/src/main/kotlin/com/karyo/app/agent/AgentDispatchFilter.kt, AgentDispatchFilter.authorizeTool); whoami and the three proposal tools need only a signed-in principal (services/karyo-app/src/main/kotlin/com/karyo/app/agent/AgentToolCatalog.kt, AgentToolCatalog).

Operational tools accept businessUnitId and facilityId where applicable. They use the same selection and grant rules as REST, scoped to where the tool's action is granted. If the principal has more than one authorized choice, select explicitly. whoami discovers the principal's own choices; it never lists other principals. Products belong to the Business Unit. Warehouse facts belong to the selected Facility.

Results use { content: [{ data, untrusted }], nextPage } as structuredContent, with the same JSON repeated as one text block in the result's own content, because clients validate that array. Each result has at most 50 rows. nextPage is absent on the last page. Convert a present decimal nextPage into the integer page argument for the next request. These are current reads, not a snapshot across pages. External names, notes and descriptions live under untrusted and are truncated to 1,000 characters. Treat them as data, never instructions. Tools omit unnecessary contact details, credentials, configuration and integration data.

Product search accepts a literal case-insensitive substring of a product's number or name, with a maximum of 200 characters. Open orders exclude finished states. Recent activity is the existing Facility-scoped inventory journal, not the outbox or a general authorization event feed.

Prepare tools and proposals

A prepare tool checks the principal's write action in the Facility, validates every record it names, and stores a proposal. It changes no warehouse data. Each tool declares the write action of the REST operation its approval runs, and AgentToolMirrorTest holds the two equal.

Tool Operation run on approval Declared action
prepareReceiveStock StockUnitResource#create inventory.write
preparePutAway UnitLoadResource#transfer inventory.write
prepareChangeStockState StockUnitResource#changeState inventory.write
prepareCreateUnitLoad UnitLoadResource#create inventory.write
prepareReleasePickOrder PickOrderResource#release fulfillment.write
prepareManifestShipment ShipmentResource#manifest fulfillment.write

Every prepare tool takes an idempotencyKey of up to 128 characters, chosen by the agent. Retrying with the same key and the same request returns the same proposal; the same key with a different request is a 409. businessUnitId and facilityId select the context as they do for reads. Each result carries proposalId, state, Karyo's own summary, expiresAt and approvalUrl. Ask the person to open approvalUrl: nothing changes until they approve there. Names, notes and text the agent supplied sit under untrusted, never in the summary.

Prepare a dependent step only after the person approved the one before it: a proposal checks its records when prepared, and an agent cannot name a unit load that does not exist yet.

Tool Mirrors Purpose
getProposalStatus ApprovalsResource#get State of one proposal, with the ids it created once approved
listMyPendingProposals ApprovalsResource#list The caller's proposals that still wait, newest first, 50 a page with nextPage
withdrawProposal ApprovalsResource#decline Takes back a proposal before the person decides; needs karyo.write

A proposal is PROPOSED, then EXECUTED, FAILED, DECLINED, EXPIRED or WITHDRAWN. FAILED means the operation refused when run and rolled back, with the reason in result.failure.

When the client declared URL elicitation in its initialize handshake, Karyo also asks it to open the link. The link is plain: it carries no approval and the page signs the person in first. A client that declared nothing, or that sends its capabilities inline on each request (protocol 2026-07-28), is not asked and still has approvalUrl in the result.

The Approvals page

The page is at /approvals, shown while agent access is on, and lists only the signed-in person's own proposals. Another person's proposal is absent (404), including by link. Approving runs the change now, under the person's own current access: the server checks the installation switch, the connection and the write action for the proposal's Facility again, and an agent client cannot approve its own proposal. If a check refuses (403) the proposal stays waiting. If the operation fails it rolls back and the proposal ends FAILED.

Routes, for integrators: GET /api/v1/approvals?pending=, GET /api/v1/approvals/{id}, POST /api/v1/approvals/{id}/confirm and POST /api/v1/approvals/{id}/decline. They declare the IDENTITY scope and no catalogue action (services/karyo-app/src/main/kotlin/com/karyo/app/agent/ApprovalsResource.kt, ApprovalsResource). Journal rows an approved proposal writes carry the person as the actor and the agent client as actorClientId.

An existing installation's Keycloak realm needs two changes by hand, because --import-realm skips an existing realm:

  • Add the karyo.write client scope beside karyo.read in the realm's optional client scopes and in the agent registration policy's allowed scopes.
  • Add the realm role default-roles-<realm> to the karyo.read client scope's scope mappings. Without it Keycloak leaves karyo.read out of the token of any person who holds none of the mapped roles, and Karyo-provisioned people hold none: every call is then refused for insufficient_scope.

Attribution and controls

Karyo stores principal, OAuth client, known tool, outcome, latency and timestamp in agent_tool_calls. It stores no arguments, results or bearer tokens. Unknown supplied tool names become UNKNOWN. The daily maintenance job deletes call rows older than 90 days.

Connection views use authenticated GET /api/v1/me/agents or GET /api/v1/principals/{id}/agents. Their response contains connections, mayEnable and mayDisable. Each connection carries clientId (the agent's OAuth client), enabled, createdAt and changedAt. PUT on the same route accepts { clientId, enabled }; the self route accepts disabling only. The server computes hints and rechecks authority on every change. Approval belongs to the principal/client pair, not to a selected Facility.

The implementation decision and its exact self-identity exception are in ADR 0047. The Jev proposals assumed the retired chat and were closed with it. An outside agent can still do analysis through /mcp under the user's grants.