The Chenile story · Runtime and integration · 6 of 6

AI tools: Chenile services for agents, through the same front door

An AI agent is one more caller. Chenile publishes chosen operations as Model Context Protocol tools, named, described and typed from the contract it already has, and runs every tool call through the same interception pipeline as an HTTP request, so security, tenancy, trajectories and every other policy apply to agents unchanged. Polymorphic operations become one precise tool per variant: one per workflow event, one per named query.

An agent is one more caller

AI agents call software through tools: a name, a description of what it does and a schema for its input. The Model Context Protocol (MCP) is the standard way for a service to offer such tools. The tempting way to support agents is to write a separate set of tool handlers next to the service. That builds a second front door: one that has to repeat the authorization, tenancy, validation and auditing of the first, and that drifts from it the first time someone forgets.

Chenile treats an agent as one more caller, like HTTP, a proxy or an event. An operation marked for MCP becomes a tool, and a tool call becomes a ChenileExchange that runs through the same interception pipeline as every other request: header validation, the deployable’s pre- and post-processors, transformation and typing, service selection, the operation’s own interceptors and finally the service. Whatever policies guard the service guard the agent, because there is no other way in.

Describe the operation once

A tool needs a name, a description and an input schema. Chenile already has all three in the operation’s contract, resolved once at startup and shared by MCP, OpenAPI and the service registry:

  • Name and description come from @ChenileOperation(contractName = …, description = …) (or the JSON definition), falling back to the service’s description.
  • Input schema is generated from the operation’s parameter types, as JSON Schema.
  • Exposure is opt-in. @ChenileMCP on a controller exposes all of its operations; on a method, just that one. Everything else stays invisible to agents.
@PatchMapping("/issue/{id}/{eventID}")
@BodyTypeSelector("issueBodyTypeSelector")
@ChenileOperation(contractName = "issueProcessById", description = "Process issue workflow event by id")
@ChenileMCP
public ResponseEntity<GenericResponse<StateEntityServiceResponse<Issue>>> processById(…)

A model reads the description to decide when to use a tool, so write descriptions for a reader who knows nothing about your code: what the operation does, and when to use it.

One precise tool per variant

Many Chenile operations are polymorphic: one operation, several shapes of input. A single tool with a catch-all Object payload would leave a model guessing. So a polymorphic operation becomes one tool per variant, each with its own name, description, typed schema and authorities, from the same variants the pipeline uses to type requests:

  • Workflows. PATCH /issue/{id}/{eventID} serves every event. StmBodyTypeSelector lists one variant per event, so the agent sees issueProcessById_assign, issueProcessById_resolve and so on. Each has the event fixed, the event’s own payload schema, the transition’s description and the event’s acls. The agent cannot send close with assign’s payload, because no such tool exists.
  • Queries. /mcp/q/{name} serves every named query. Each query becomes a tool, mcpQuerySearch_accounts, whose schema says which filters it accepts, which columns it can sort on and whether it pages.
  • Subclass payloads. An operation whose body is one of several subclasses gets a tool per subclass.

Workflows are especially good tools. Every workflow response carries allowedActionsAndMetadata, the events allowed from the new state, so after each call the agent knows exactly which tool it may call next.

The caller’s context comes along

A tool call must run as the caller, not as the server. With the Streamable HTTP transport, Chenile captures the HTTP request that carried each MCP message and copies its x- headers and its Authorization header into the exchange. They are copied first; the entry-point marker and the tool’s own arguments are set after them, so a caller’s headers cannot impersonate those:

  • The user and their authorities, from the token, so security policies and per-variant authorities apply.
  • The tenant, so the call reads and writes that tenant’s data, configuration and query definitions.
  • The trajectory, so an experiment that covers a slice of traffic covers that slice’s agents too.

The exchange is also marked with its entry point, MCP, and the tool’s name, so logs, metrics and policies can tell agent traffic apart.

What comes back

A tool returns the operation’s payload, the data inside Chenile’s response envelope, as JSON. A failure becomes a tool error carrying Chenile’s error response, with its code and localised description, so the agent can see that resolve was refused with a 403, or that close is not allowed in the current state, and choose what to do next.

Every caller sees every tool

Tool listings are not filtered by caller: an agent sees every tool the deployable exposes. Authorization happens when a tool is called, by the same policies as any other call. Expose a tool because it is safe to show, and rely on the policies for who may use it.

Generated for you

The JGen service and workflow blueprints take an enableMCP option that adds @ChenileMCP and the MCP dependencies to the generated controller. workflow-mcp and query-mcp add MCP to workflow and query services. Agent support then costs no tool code at all: the tools are the operations you already have.

Where to go next