OpenAPI to MCP Configuration
The openapi-to-mcp plugin exposes OpenAPI services as MCP tools through APISIX or API7 Gateway, with Streamable HTTP, SSE, and upstream headers. Configuration covers static settings and plugin parameters.
Static Configurations
These settings apply only to API7 Gateway. APISIX handles MCP inside the gateway and does not use a separate OpenAPI-to-MCP service.
Choose the configuration format for your API7 Gateway deployment:
- Host or Docker
- Kubernetes (Helm)
The gateway config.yaml supports only the service port for this plugin:
plugin_attr:
openapi-to-mcp:
port: 3000 # Default: 3000. Match the service's SSE_PORT.
Then reload the gateway for static configuration changes to take effect.
For Docker, add or update the OpenAPI-to-MCP service as follows. If the generated gateway service has another name, replace gateway in network_mode with that name.
services:
openapi-to-mcp:
image: api7/openapi-to-mcp:1.0.9
network_mode: "service:gateway"
restart: always
environment:
SSE_HOST: "127.0.0.1" # Default: 127.0.0.1. Keep the listener on loopback.
SSE_PORT: "3000" # Default: 3000. Match plugin_attr.openapi-to-mcp.port.
CACHE_ENABLED: "true" # Default: true.
CACHE_TTL: "3600" # Default: 3600 seconds.
CACHE_MAX_SIZE: "100" # Default: 100 entries.
CACHE_CHECK_INTERVAL: "300" # Default: 300 seconds.
VERIFY_SSL: "true" # Default: true.
TIMEOUT: "30000" # Default: 30000 milliseconds.
For a host installation, set the same environment variables directly on the OpenAPI-to-MCP service process. Restart the service after changing its environment.
For Helm deployments, set the following values in the API7 Gateway Helm chart. Gateway charts 3.9.15 and 3.10.17 support openapiToMcp.extraEnvVars and include service image 1.0.9. Keep the plugin attribute port and the chart-managed sidecar port the same.
openapiToMcp:
enabled: true
port: 3000 # Default: 3000. Sets the sidecar SSE_PORT.
extraEnvVars:
- name: SSE_HOST
value: "0.0.0.0" # Allow the chart's Pod-IP health probes.
- name: CACHE_ENABLED
value: "true" # Default: true.
- name: CACHE_TTL
value: "3600" # Default: 3600 seconds.
- name: CACHE_MAX_SIZE
value: "100" # Default: 100 entries.
- name: CACHE_CHECK_INTERVAL
value: "300" # Default: 300 seconds.
- name: VERIFY_SSL
value: "true" # Default: true.
- name: TIMEOUT
value: "30000" # Default: 30000 milliseconds.
pluginAttrs:
openapi-to-mcp:
port: 3000 # Match openapiToMcp.port.
Then apply the values file to the existing gateway release:
helm upgrade <gateway-release-name> api7/gateway -n <namespace> -f values.yaml
The API7 Gateway integration uses the following OpenAPI-to-MCP service environment variables:
| Variable | Default | Description |
|---|---|---|
SSE_HOST | 127.0.0.1 | Listening address for the service. Keep the default for Host or Docker. For Helm, set 0.0.0.0 so Pod-IP health probes can reach the sidecar. |
SSE_PORT | 3000 | For Host or Docker, set this and plugin_attr.openapi-to-mcp.port to the same value. For Helm, use matching openapiToMcp.port and pluginAttrs.openapi-to-mcp.port values; the chart sets SSE_PORT. |
CACHE_ENABLED | true | Set to false to download and parse the document for every tool-discovery request. |
CACHE_TTL | 3600 | Number of seconds that a cached document and its generated tools remain available. |
CACHE_MAX_SIZE | 100 | Maximum number of cached entries for the service process. This is an entry count, not a byte limit. |
CACHE_CHECK_INTERVAL | 300 | Number of seconds between removal checks for expired cache entries. |
VERIFY_SSL | true | Whether backend API requests verify TLS certificates. |
TIMEOUT | 30000 | Backend inactivity timeout in milliseconds. Accepts 1 to 2147483647; an invalid value uses the default. Requires service image 1.0.9 or later. |
Parameters
See plugin common configurations for configuration options available to all plugins.
transport
valid value:
sseorstreamable_httpAvailable in APISIX and API7 Gateway. Streamable HTTP was introduced in API7 Enterprise 3.8.15 and APISIX 3.19.0.
Transport method for client-server communication. The
streamable_httpmethod is recommended for production because it is stateless. Thessemethod is stateful and requires session affinity across multiple gateway instances.In APISIX 3.20.0, an SSE session can be used only on the route that opened it and by the same authenticated consumer, if any.
openapi_url
Available in APISIX and API7 Gateway.
URL of the OpenAPI specification document that defines the API structure to be exposed through MCP.
Keep the URL operator-controlled. APISIX accepts OpenAPI 3.x documents in JSON or YAML, resolves internal and absolute HTTP or HTTPS references, and caches generated tools for one hour. Swagger 2.0 support is best effort and does not convert body or form-data parameters into tool inputs. In APISIX 3.20.0, tool calls forward only parameters declared by the matching operation.
The API7 Gateway service accepts OpenAPI 3 and Swagger 2.0 documents, but Swagger 2.0 body and form-data parameters are not converted into tool request bodies. It has a known parsing issue with some
oneOfschemas. The service caches by theopenapi_urlstring, so change the URL, for example with a version query parameter, to load an updated document immediately.base_url
Available in APISIX and API7 Gateway. Built-in variable support was introduced in API7 Enterprise 3.8.19 and APISIX 3.19.0.
Base URL of the API service where requests will be forwarded. See the variable references for API7 Gateway and APISIX.
Keep this URL operator-controlled in APISIX, which does not implement the API7 Gateway
allowed_hostsrestriction.allowed_hosts
valid value:
Exact host names or wildcard host names such asapi.example.comand*.example.comAvailable only in API7 Gateway. Introduced in API7 Enterprise 3.9.13.
Optional allow-list of hosts that the resolved
base_urlmay target. When set, requests whose resolved host is not in the list are rejected with HTTP 400.headers
Available in APISIX and API7 Gateway.
Headers to include in requests to the upstream service. Values can use API7 Gateway variables or APISIX variables, such as
$http_x_api_key. APISIX resolves values once per SSE session and for every Streamable HTTP request. Native APISIX does not automatically forward the API7 Gateway sidecar'sx-openapi2mcp-header-*client headers.In APISIX 3.20.0, these configured headers take precedence over header arguments supplied by a tool caller.
max_response_body_size
valid value:
greater than or equal to 1024Available only in APISIX. Introduced in APISIX 3.20.0.
Maximum number of upstream response-body bytes APISIX reads into a tool result. A larger response fails the tool call with
RESPONSE_TOO_LARGEinstead of being buffered.max_document_size
valid value:
greater than or equal to 1024Available only in APISIX. Introduced in APISIX 3.20.0.
Maximum size in bytes of the main OpenAPI document and each document loaded through an HTTP or HTTPS
$ref. A larger document prevents APISIX from building the tool list.max_expanded_nodes
valid value:
greater than or equal to 1000Available only in APISIX. Introduced in APISIX 3.20.0.
Maximum number of nodes one
$refexpansion can produce in tool input schemas. When the limit is reached, references still being expanded and subsequent references degrade to generic objects. Only the OpenAPIpathstree is expanded and counted.allowed_ref_hosts
valid value:
Host names or*.example.comwildcards, optionally followed by:portAvailable only in APISIX. Introduced in APISIX 3.20.0.
Additional hosts that HTTP or HTTPS
$refvalues may target. References to the scheme, host, and effective port ofopenapi_urlare allowed without this field. An entry without a port accepts any port on the matching host.This field is separate from the API7 Gateway
allowed_hostsfield, which restricts the resolvedbase_url.allowed_origins
valid value:
Origin values in the formscheme://host[:port], or*Available only in APISIX. Introduced in APISIX 3.20.0.
Origin header values accepted on MCP requests. A request without an
Originheader is always accepted. Set the value to["*"]to accept any origin.When this field is omitted, APISIX accepts an origin only when its host is a literal
hostorhostsvalue on the route and its scheme and effective port match the request. Wildcard route hosts do not establish trust. If the route has no literal host, APISIX also accepts a loopback origin when the request is addressed to a loopback host with the same scheme and effective port.flatten_parameters
Available in APISIX and API7 Gateway. Query and path parameter flattening was introduced in API7 Enterprise 3.8.21, and header parameter support in 3.9.8. All three parameter locations are supported in APISIX 3.19.0.
Whether to flatten parameters in the tool schema.
If set to
false, query, path, and header parameters are nested underqueryParameters,pathParameters, andheaderParameters. If set totrue, they are placed directly underproperties.Setting the parameter to
truesimplifies AI model interaction by reducing schema complexity. Keep the parameter atfalsewhen query, path, and header parameters share the same names, to avoid conflicts.allow_encoded_path_separators
Available only in APISIX. Introduced in APISIX 3.20.0.
Whether APISIX accepts
/or\inside a path-parameter value and percent-encodes the separator before sending the upstream request. Enable this only when the upstream consistently treats encoded separators as data.Empty,
., and..components remain invalid.cache_enabled
Available only in API7 Gateway. Introduced in API7 Enterprise 3.9.21 and 3.10.8.
Whether the OpenAPI-to-MCP service caches the OpenAPI document of this route and the tools generated from it. If set to
false, the service downloads and parses the document again every time it loads the tools, which suits a document that is still changing.This route-level value takes precedence over the service's
CACHE_ENABLEDdefault. It requires sidecar version 1.0.5 or later; earlier versions ignore it.cache_ttl
valid value:
greater than or equal to 1Available only in API7 Gateway. Introduced in API7 Enterprise 3.9.21 and 3.10.8.
Seconds that the OpenAPI document of this route and the tools generated from it stay in the cache of the OpenAPI-to-MCP service.
This route-level value takes precedence over the service's
CACHE_TTLdefault. It requires sidecar version 1.0.5 or later; earlier versions ignore it.