How it works
When you point agentgateway at an OpenAPI schema, it reads every path and method, derives a tool name from theoperationId (or the path and method), and exposes those tools over MCP. Requests from MCP clients are translated to HTTP calls and forwarded to the backend host you configure.
Configuration
Add anopenapi target to your backend configuration:
Key fields
| Field | Description |
|---|---|
openapi.schema.file | Path to the OpenAPI JSON or YAML specification file |
openapi.host | The backend host (and optional port) to forward requests to |
OpenAPI schema structure
The schema file follows the OpenAPI 3.x format. Agentgateway reads thepaths object and uses operationId as the MCP tool name. Here is a snippet from the Petstore example used in examples/openapi/openapi.json:
operationId becomes the name of an MCP tool. Tool descriptions come from the summary and description fields. Input schemas are derived from the operation’s requestBody and parameters.
Running the Petstore example
Start the Petstore demo backend
The example uses the official Swagger Petstore Docker image:This starts the Petstore application on
localhost:8080.Start agentgateway
examples/openapi/openapi.json and exposes every Petstore operation as an MCP tool on port 3000.Connect with MCP Inspector
http://localhost:3000.Connecting to a remote OpenAPI backend
Replace thehost value with your backend’s address. The schema file can be a local path or fetched separately:
CORS for browser-based clients
When connecting from browser-based MCP clients (such as the MCP Inspector), enable CORS on the route:How REST endpoints become MCP tools
Tool name
Derived from the
operationId field. Falls back to {method}_{path} if operationId is absent.Tool description
Populated from the operation’s
summary and description fields.Input schema
Constructed from the operation’s
parameters (query, path, header) and requestBody JSON schema.HTTP mapping
Agentgateway maps tool call arguments back to the correct HTTP method, path parameters, query strings, and request body.
Testing with MCP Inspector
The MCP Inspector is the recommended tool for verifying your OpenAPI integration:- Connect to
http://localhost:3000(or your listener address). - Navigate to the Tools tab to see all generated tools.
- Select any tool, review its generated input schema, and invoke it.
- Check the Response panel for the result from the upstream API.
The MCP Inspector does not support TLS with self-signed certificates. If your listener uses HTTPS, use a CA-signed certificate or test with
curl directly.