OpenAPI AI agent tools: turn any HTTP API into tools
Updated Fact-checked
To give an AI agent tools from an HTTP API, point it at the API’s OpenAPI document: each operation in it (GET /alerts/active, POST /orders) becomes one tool the agent can call. Contenox does this directly: add the API as an OpenAPI service on its Connectors page. Claude Code, Codex and OpenCode don’t read OpenAPI documents themselves; they need the API wrapped in an MCP server first.
How each agent does it#
| Agent | OpenAPI service as tools | What to do instead |
|---|---|---|
| Claude Code | Not built in | Run an MCP server for the API, or one that converts an OpenAPI document, and add it as an MCP server |
| Codex | Not built in | The same: an MCP server in front of the API |
| OpenCode | Not built in | An MCP server, or a custom tool in its config |
| Contenox | Connectors → Add connector → OpenAPI service | Nothing; every operation becomes a tool |
If the vendor ships an MCP server, use that: it’s usually tuned for agents, with fewer and clearer tools. The OpenAPI route is for everything else: internal services, admin APIs, and any API that publishes an OpenAPI v3 document.
Add an OpenAPI service in Contenox#
Open Connectors, choose Add connector, and set Kind of connector to OpenAPI service. The weather.gov API, which needs no account, is a good first test:
| Field | Value |
|---|---|
| Name | nws |
| Where it works | Every chat |
| Service URL | https://api.weather.gov |
| OpenAPI document | Leave empty |
| Timeout (milliseconds) | 15000 |
Add and check fetches the document and shows how many tools it found. Without an OpenAPI document, Contenox reads it from the service URL plus /openapi.json. If the document lives somewhere else, enter its URL, or a file:// path to a copy on your computer.
Then ask in a chat: “Are there any weather alerts in Florida right now?” (the API covers the US only). The agent calls nws.alerts_active and asks you first.
Tokens and fixed values#
For an API key or token, add a header under Headers, one Name: value per line:
Authorization: Bearer your-token
Under Advanced:
- Fixed values: one
name=valueper line. Sent with every call and hidden from the agent, for example a tenant or account ID the agent must never change. - Injected value: one more value with a name, a value, and Where it goes: Body, Query, Path or Header. The agent never sees it.
Both are removed from the tool description the agent receives and written over any argument of the same name the agent sends, so a confused or manipulated model cannot swap the tenant ID for another one.
APIs that need a login first#
Some APIs want a login call that returns a session, then that session on every request. Turn on Log in before calling, and again when the service says no:
| Field | Example |
|---|---|
| Login URL | https://api.example.com/auth/token |
| Login body | {"username": "${API_USER}", "password": "${API_PASS}"} |
| Take the session from | JSON path $.data.token, or a Cookie name |
| Send it as | Header Authorization, Format Bearer %s |
${NAME} in the body is replaced with the environment variable NAME where Contenox runs, so the password never sits in the app’s settings. Without Send it as, Contenox sends the session cookie. Contenox logs in before the first call, and again whenever the API answers that the session is no longer valid.
The certificate trap: Accept certificates that cannot be verified makes a self-signed internal service work, and also lets anyone between you and the service read and change the traffic. Use it only on your own network.
How operations become tools#
Each tool is named after its connector and operation, such as nws.alerts_active. The operation part comes from the document:
- The operation’s
operationId. weather.gov givesGET /alerts/activethe operationIdalerts_active. - Without one, an
x-tool-nameextension on the operation. - Otherwise, the last part of the path and the method:
GET /orders/recentbecomesrecent_get.
Only GET, POST, PUT, PATCH and DELETE operations become tools. Health and metrics paths (/health, /healthz, /ready, /readyz, /metrics) are skipped.
A large API turns into hundreds of tools, and every tool’s description goes to the model with every request, so the context fills before the agent starts. Open the connector on the Connectors page and switch off the operations the agent doesn’t need, or limit the connector to one project with Where it works.
An operation switched off is not a tool the model is told to avoid; it is missing from what the model receives. The design note in The Soul of Contenox: when the schema exposes only GET /contacts, DELETE /contacts does not exist to the model, “Not hidden. Not discouraged. Absent.” The token works the same way: an injected value never reaches the model, and the model cannot leak what it cannot read.
Permissions#
Like every connector, an OpenAPI service asks before each call by default: the chat shows a Permission required card with the operation and its input. To change that, open Permissions, choose a set, and set the service under Tools to Allow, Ask me first, Block or Follow the rules above.
A sensible split for most APIs: let the agent read freely, keep writes asking. Since one service is one entry under Tools, switch the POST, PUT, PATCH and DELETE operations you don’t want off on the Connectors page, and allow the service.
From the command line#
For scripts and CI:
contenox-runtime tools add nws --url https://api.weather.gov --timeout 15000
Headers, fixed values and the login options have flags too; see the command reference.
Related#
Add an MCP server: when the vendor ships an MCP serverAdd an MCP server: Claude Code, Codex, OpenCode, ContenoxHow to add an MCP server in Claude Code, Codex, OpenCode and Contenox: local and remote servers, sign-in, per-chat switches, hiding single tools, and permissions.
What is MCP?: why tool count costs contextWhat is MCP? The Model Context Protocol, explained simplyWhat is MCP? The Model Context Protocol in plain words: what it does, how it differs from an API, how to add a server to your coding agent, and when to skip it.
Built-in tools and permissions: the rules every call goes throughContenox permissions and built-in tools: files, shell, gitContenox permissions explained: what agents may read, change and run without asking, what asks first, what is blocked, and how to change the rules.
AI agent permissions: what to allow, ask and blockAI agent permissions for coding agents: a safe starting rule set, real config for Claude Code and Codex, the gaps in command rules, and when to skip prompts.