Skip to main content

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​

info

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:

The gateway config.yaml supports only the service port for this plugin:

config.yaml
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.

docker-compose.yaml
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.

The API7 Gateway integration uses the following OpenAPI-to-MCP service environment variables:

VariableDefaultDescription
SSE_HOST127.0.0.1Listening 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_PORT3000For 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_ENABLEDtrueSet to false to download and parse the document for every tool-discovery request.
CACHE_TTL3600Number of seconds that a cached document and its generated tools remain available.
CACHE_MAX_SIZE100Maximum number of cached entries for the service process. This is an entry count, not a byte limit.
CACHE_CHECK_INTERVAL300Number of seconds between removal checks for expired cache entries.
VERIFY_SSLtrueWhether backend API requests verify TLS certificates.
TIMEOUT30000Backend 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

    string

    default: sse

    valid value:

    sse or streamable_http

    Available 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_http method is recommended for production because it is stateless. The sse method 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

    string

    required


    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 oneOf schemas. The service caches by the openapi_url string, so change the URL, for example with a version query parameter, to load an updated document immediately.

  • base_url

    string

    required


    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_hosts restriction.

  • allowed_hosts

    array[string]

    valid value:

    Exact host names or wildcard host names such as api.example.com and *.example.com

    Available only in API7 Gateway. Introduced in API7 Enterprise 3.9.13.

    Optional allow-list of hosts that the resolved base_url may target. When set, requests whose resolved host is not in the list are rejected with HTTP 400.

  • headers

    object


    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's x-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

    integer

    default: 1048576

    valid value:

    greater than or equal to 1024

    Available 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_LARGE instead of being buffered.

  • max_document_size

    integer

    default: 4194304

    valid value:

    greater than or equal to 1024

    Available 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

    integer

    default: 50000

    valid value:

    greater than or equal to 1000

    Available only in APISIX. Introduced in APISIX 3.20.0.

    Maximum number of nodes one $ref expansion can produce in tool input schemas. When the limit is reached, references still being expanded and subsequent references degrade to generic objects. Only the OpenAPI paths tree is expanded and counted.

  • allowed_ref_hosts

    array[string]

    valid value:

    Host names or *.example.com wildcards, optionally followed by :port

    Available only in APISIX. Introduced in APISIX 3.20.0.

    Additional hosts that HTTP or HTTPS $ref values may target. References to the scheme, host, and effective port of openapi_url are 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_hosts field, which restricts the resolved base_url.

  • allowed_origins

    array[string]

    valid value:

    Origin values in the form scheme://host[:port], or *

    Available only in APISIX. Introduced in APISIX 3.20.0.

    Origin header values accepted on MCP requests. A request without an Origin header 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 host or hosts value 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

    boolean

    default: false


    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 under queryParameters, pathParameters, and headerParameters. If set to true, they are placed directly under properties.

    Setting the parameter to true simplifies AI model interaction by reducing schema complexity. Keep the parameter at false when query, path, and header parameters share the same names, to avoid conflicts.

  • allow_encoded_path_separators

    boolean

    default: false


    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

    boolean

    default: true


    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_ENABLED default. It requires sidecar version 1.0.5 or later; earlier versions ignore it.

  • cache_ttl

    integer

    default: 3600

    valid value:

    greater than or equal to 1

    Available 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_TTL default. It requires sidecar version 1.0.5 or later; earlier versions ignore it.