This document describes the fields and references for HTTP to MCP configurations. You can use this guide to integrate tools for the MCP service with custom YAML.
Configuration fields
Server configuration
Name | Data type | Required | Description |
server.name | string | Required | The name of the MCP server. If you use a built-in MCP server plugin, such as `quark-search`, set this field to the server name. You do not need to configure the `tools` field. In HTTP to MCP scenarios, you can set this field to any value. |
server.config | object | Optional | Server configuration, such as API keys. |
server.securitySchemes | array[object] | Optional | Defines reusable authentication schemes for tools to reference. For more information, see Authentication and security. |
Allowed tools configuration
Name | Data type | Required | Description |
allowTools | array[string] | Optional | A list of tools that are allowed to be called. If not specified, all tools are allowed. |
HTTP to MCP tool configuration
Name | Data type | Required | Description |
tools | array[object] | Optional | A list of HTTP to MCP tool configurations. |
tools[].name | string | Required | The tool name. |
tools[].description | string | Required | A description of the tool's function. |
tools[].args | array[object] | Required | Tool parameter definitions. |
tools[].args[].name | string | Required | The parameter name. |
tools[].args[].description | string | Required | The parameter description. |
tools[].args[].type | string | Optional | The parameter type, such as string, number, integer, boolean, array, or object. The default is `string`. |
tools[].args[].required | boolean | Optional | Specifies whether the parameter is required. The default is `false`. |
tools[].args[].default | any | (Optional) | The default value of the parameter. |
tools[].args[].enum | array | Optional | A list of allowed values for the parameter. |
tools[].args[].items | object | Optional | The schema for array items when `type` is `array`. |
tools[].args[].properties | object | Optional | The schema for object properties when `type` is `object`. |
tools[].args[].position | string | Optional | The position of the parameter in the request, such as query, path, header, cookie, or body. |
tools[].requestTemplate | object | Required | The HTTP request template. |
tools[].requestTemplate.url | string | Required | The request URL template. |
tools[].requestTemplate.method | string | Required | The HTTP method, such as GET or POST. |
tools[].requestTemplate.headers | array[object] | Optional | The request header template. |
tools[].requestTemplate.headers[].key | string | Required | The request header name. |
tools[].requestTemplate.headers[].value | string | Required | The request header value template. |
tools[].requestTemplate.body | string | Optional | The request body template. This is mutually exclusive with |
tools[].requestTemplate.argsToJsonBody | boolean | Optional | The default is `false`. When `true`, the parameters are used directly as the JSON request body. This is mutually exclusive with |
tools[].requestTemplate.argsToUrlParam | boolean | Optional | The default is `false`. When `true`, the parameters are added to the URL as query parameters. This is mutually exclusive with |
tools[].requestTemplate.argsToFormBody | boolean | Optional | The default is `false`. When `true`, the parameters are encoded in the request body in |
tools[].responseTemplate | object | Required | The HTTP response transformation template. |
tools[].responseTemplate.body | string | Optional | The response body transformation template. This is mutually exclusive with |
tools[].responseTemplate.prependBody | string | Optional | Text to insert before the response body. This is mutually exclusive with |
tools[].responseTemplate.appendBody | string | Optional | Text to insert after the response body. This is mutually exclusive with |
tools[].security | object | Optional | Tool-level security configuration. It defines the authentication method between the MCP Client and MCP Server and supports credential passthrough. |
tools[].security.id | string | Required when | References the ID of an authentication scheme defined in |
tools[].security.passthrough | boolean | Optional | Specifies whether to enable passthrough authentication. The default is `false`. If |
tools[].requestTemplate.security | object | Optional | Security configuration for the HTTP request template. It defines the authentication method between the MCP Server and the HTTP API. |
tools[].requestTemplate.security.id | string | Required when | References the ID of an authentication scheme defined in |
tools[].requestTemplate.security.credential | string | Optional | Overrides the default credential defined in |
Authentication and security
The MCP Server plugin supports flexible authentication configurations to ensure secure communication.
Defining authentication schemes (server.securitySchemes)
You can define a set of reusable authentication schemes at the server level. Tools can reference these schemes to configure how the MCP Server authenticates with backend HTTP APIs.
Configuration fields (server.securitySchemes[]):
Name | Data type | Required | Description |
id | string | Required | A unique identifier for the authentication scheme, referenced by tool configurations. |
type | string | Required | The authentication type. Supported types are |
scheme | string | Optional | When |
in | string | Optional | When |
name | string | Optional | When |
defaultCredential | string | Optional | The default credential for this scheme. For example, for Basic Auth, it can be |
Example (server.securitySchemes):
server:
name: my-api-server
securitySchemes:
- id: MyBasicAuth
type: http
scheme: basic
defaultCredential: "admin:secretpassword" # Default username and password
- id: MyBearerToken
type: http
scheme: bearer
defaultCredential: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." # Default Bearer Token
- id: MyApiKeyInHeader
type: apiKey
in: header
name: X-Custom-API-Key # API key is in a header named X-Custom-API-Key
defaultCredential: "abcdef123456" # Default API key
- id: MyApiKeyInQuery
type: apiKey
in: query
name: "api_token" # API key is in a query parameter named api_token
defaultCredential: "uvwxyz789012"
Applying authentication schemes in tools
After you define server.securitySchemes, you can reference these schemes in each tool's requestTemplate.security field using the id. This specifies the authentication method that the MCP Server uses when it calls the backend HTTP API.
tools[].requestTemplate.security.id: References theidof an authentication scheme defined inserver.securitySchemes.tools[].requestTemplate.security.credential: Optional. If provided, this field overrides thedefaultCredentialin the referenced scheme. This lets you use different credentials for specific tools, even if they share the same authentication mechanism.
Example:
tools:
- name: get-user-details
# ... other tool configurations ...
requestTemplate:
url: "https://api.example.com/users/{{.args.userId}}"
method: GET
security:
id: MyBearerToken # Use the MyBearerToken scheme defined above
# credential: "override_token_for_this_tool" # Optional: Override the default token for this tool
# ...
- name: update-inventory
# ... other tool configurations ...
requestTemplate:
url: "https://api.example.com/inventory/{{.args.itemId}}"
method: POST
security:
id: MyApiKeyInHeader # Use the MyApiKeyInHeader scheme
# This tool will use the defaultCredential defined in MyApiKeyInHeader
Passthrough authentication
The passthrough authentication feature allows credentials that are provided when an MCP client, such as an AI assistant, calls the MCP Server to be passed directly to the MCP Server. These credentials are then used to authenticate subsequent calls to the backend HTTP API.
Configuration method:
Ensure that the relevant authentication schemes are defined in
server.securitySchemes. This includes the scheme that the client uses to connect to the MCP Server and the scheme that the MCP Server uses to connect to the backend HTTP API.Configure tool-level authentication (
tools[].security): For a tool that requires credential passthrough, configure thesecurityfield:id: References the authentication scheme defined inserver.securitySchemesthat is used for authentication between the MCP Client and the MCP Server. The plugin extracts the credential from the client request based on this scheme and removes that credential from the original request.passthrough: true: Enables passthrough authentication.
Configure request template authentication (
tools[].requestTemplate.security): Configure thesecurityfield in the tool'srequestTemplate:id: References the authentication scheme defined inserver.securitySchemesthat is used for authentication between the MCP Server and the backend HTTP API.When
tools[].security.passthroughis set totrue, the credential that is extracted from the client is applied to the call to the backend HTTP API according to thisrequestTemplate.securityscheme.
Example:
Assume that the MCP client uses a Bearer Token to call the MCP Server, and the MCP Server needs to use an API key to call the backend HTTP API.
server:
name: product-api-server
securitySchemes:
- id: ClientSideBearer # Client uses a Bearer Token
type: http
scheme: bearer
- id: BackendApiKey # Backend API uses X-API-Key
type: apiKey
in: header
name: X-API-Key
# defaultCredential: "optional_default_backend_key"
tools:
- name: get-product-securely
description: "Get product information (secure passthrough)"
security: # Client -> MCP Server authentication configuration
id: ClientSideBearer # The MCP Server expects the client to use this scheme and will try to extract this type of credential
passthrough: true # Allow credential passthrough
args:
- name: product_id
description: "Product ID"
type: string
required: true
requestTemplate:
security: # MCP Server -> backend HTTP API authentication configuration
id: BackendApiKey # The backend API requires this scheme. The passthrough credential will be applied according to this scheme.
url: "https://api.example.com/products/{{.args.product_id}}"
method: GET
Workflow
The MCP client sends a request to the
get-product-securelytool on the MCP Server. The request carriesBearer <client_token>in theAuthorizationheader.The MCP Server identifies that the client is using a Bearer Token based on
tools[].security(id:ClientSideBearer). It extracts<client_token>from the request and removes the originalAuthorizationheader.Because
passthrough: trueis set, the extracted<client_token>is marked as a passthrough credential.The MCP Server prepares to call the backend HTTP API. It checks
requestTemplate.security(id:BackendApiKey).Because passthrough is enabled, the MCP Server uses the previously extracted
<client_token>as the credential value. It adds this value to the request tohttps://api.example.com/products/...as an HTTP header namedX-API-Key, according to theBackendApiKeyscheme.The backend HTTP API receives the request with the
X-API-Keyheader set to<client_token>.
When
tools[].security.passthroughis set totrue, therequestTemplate.security.credentialfield is ignored. The passthrough credential takes precedence.The passthrough credential value is used directly for the authentication scheme specified by
requestTemplate.security. Ensure that the credential format is compatible with the target authentication scheme. TheextractAndRemoveIncomingCredentialfunction attempts to extract the core part of the credential, such as the Bearer token value or the Base64-encoded part of Basic auth.
Supported parameter types
HTTP to MCP tools support multiple parameter types, which allow you to define tool parameters more precisely:
string: A string type. This is the default.
number: A number type (floating-point number).
integer: An integer type.
boolean: A Boolean type (true/false).
array: An array type. You can use the
itemsfield to define the schema of array elements.object: An object type. You can use the
propertiesfield to define the schema of object properties.
Example:
args:
- name: query
description: "Search keyword"
type: string
required: true
- name: limit
description: "Number of results to return"
type: integer
default: 10
- name: filters
description: "Filter conditions"
type: object
properties:
category:
type: string
enum: ["food", "hotel", "attraction"]
price:
type: integer
minimum: 0
- name: coordinates
description: "List of coordinates"
type: array
items:
type: object
properties:
lat:
type: number
lng:
type: number
Parameter position control
HTTP to MCP tools support the position field, which lets you precisely control the location of each parameter in a request. This provides greater flexibility for building API requests, such as using path parameters, query parameters, and request body parameters in the same request.
Supported position types
query: The parameter is passed as a query parameter in the URL.
path: The parameter replaces a path placeholder in the URL, such as
{petId}in/pet/{petId}.header: The parameter is passed in an HTTP header.
cookie: The parameter is passed as a cookie.
body: The parameter is passed in the request body. It is automatically formatted as JSON or a form based on the content type.
Example
args:
- name: petId
description: "Pet ID"
type: string
required: true
position: path
- name: token
description: "Authentication token"
type: string
required: true
position: header
- name: sessionId
description: "Session ID"
type: string
position: cookie
- name: limit
description: "Number of results to return"
type: integer
default: 10
position: query
- name: tags
description: "List of tags"
type: array
position: body
In the example above:
petIdreplaces the{petId}placeholder in the URL.tokenis added to the request as an HTTP header.sessionIdis added to the request as a cookie.limitis added to the URL as a query parameter.tagsis added to the request body.
Relationship with batch parameter handling options
When you use position to specify a parameter's location, the parameter is processed accordingly. It is not affected by batch parameter handling options, such as argsToJsonBody, argsToUrlParam, and argsToFormBody. These batch options affect only parameters that do not have a specified position.
For example, if you use both position and argsToJsonBody:
A parameter with
position: queryis added to the URL query string.A parameter with
position: headeris added to the HTTP headers.A parameter with
position: pathreplaces a placeholder in the URL.A parameter with
position: cookieis added as a cookie.A parameter with
position: bodyis added to the JSON request body.Parameters without a specified
positionare added to the JSON request body byargsToJsonBody.
In addition, if you explicitly specify a body in the requestTemplate, all parameters with position: body are ignored to avoid conflicts.
Request parameter passing methods
In addition to using position to precisely control the location of each parameter, HTTP to MCP tools also support four batch parameter handling methods. These options are mutually exclusive. You can choose only one.
body: You can manually build the request body using a template. This is the most flexible method and gives you full control over the request body format.
requestTemplate: body: | { "query": "{{.args.query}}", "filters": {{toJson .args.filters}}, "options": { "limit": {{.args.limit}} } }argsToJsonBody: If set to
true, parameters that do not have a specifiedpositionare sent as a JSON object in the request body. TheContent-Type: application/json; charset=utf-8header is automatically added.requestTemplate: argsToJsonBody: trueargsToUrlParam: Adds parameters without a specified
positionto the URL as query parameters when set totrue.requestTemplate: argsToUrlParam: trueargsToFormBody: When set to
true, parameters that do not have a specifiedpositionare encoded in the request body in theapplication/x-www-form-urlencodedformat. The corresponding Content-Type header is automatically added.requestTemplate: argsToFormBody: true
These options simplify the configuration of common API call patterns without requiring you to manually build the request body or URL parameters. Note that these four options are mutually exclusive. You can only use one of them in a single tool configuration. If you configure multiple options at the same time, the system reports an error and refuses to load the tool configuration.
Template syntax
The HTTP-to-MCP feature uses the GJSON Template library for template rendering. It combines Go's template syntax with GJSON's powerful path syntax.
Request template
You can use the request template to construct the HTTP request URL, headers, and body:
To access configuration values, use
.config.fieldName.To access tool parameters, use
.args.parameterName.
Response template
You can use the response template to transform the HTTP response into a format that is suitable for AI consumption:
To access JSON response fields, use GJSON path syntax.
You can use template functions such as
add,upper, andlower.You can use control structures such as
ifandrange.
GJSON Template includes all functions from Sprig. It provides more than 70 template functions for string manipulation, mathematical operations, date formatting, and more, offering capabilities equivalent to Helm's templates.
Common Sprig functions include the following:
String manipulation:
trim,upper,lower,replace,plural,nospaceMathematical operations:
add,sub,mul,div,max,minDate formatting:
now,date,dateInZone,dateModifyList operations:
list,first,last,uniq,sortAlphaDictionary operations:
dict,get,set,hasKey,pluckFlow control:
ternary,default,empty,coalesceType conversion:
toString,toJson,toPrettyJson,toRawJsonEncoding/Decoding:
b64enc,b64dec,urlquery,urlqueryescapeUUID generation:
uuidv4
For a complete reference of all available functions, see the Helm function documentation. GJSON Template includes the same function set.
GJSON path syntax
GJSON provides powerful JSON query capabilities:
Dot notation:
address.cityArray index:
users.0.nameArray iteration:
users.#.nameArray filtering:
users.#(age>=30)#.nameModifiers:
users.@reverse.#.nameMultiple paths:
{name:users.0.name,count:users.#}Escaped characters:
path.with\.dot
For more complex queries, you can use the gjson function:
<!-- Use the gjson function for complex queries -->
Active users: {{gjson "users.#(active==true)#.name"}}
<!-- Array filtering with multiple conditions -->
Active developers over 30: {{gjson "users.#(active==true && age>30)#.name"}}
<!-- Using modifiers -->
Usernames (reversed): {{gjson "users.@reverse.#.name"}}
<!-- Iterating over filtered results -->
Administrators:
{{range $user := gjson "users.#(roles.#(==admin)>0)#"}}
- {{$user.name}} ({{$user.age}})
{{end}}
For a complete GJSON path syntax reference, see the GJSON documentation.
Configuration examples
Example of using a built-in MCP server: Configuring quark-search
server:
name: "quark-search"
config:
apiKey: "xxxx"
This configuration uses the built-in `quark-search` MCP server in Higress. In this case, you only need to specify the server name and necessary configuration, such as an API key. You do not need to configure the `tools` field because the tools are predefined in the server.
Basic example: Transforming the AMAP API
server:
name: HTTP-amap-server
config:
apiKey: your-api-key-here
tools:
- name: maps-geo
description: "Converts a detailed, structured address into latitude and longitude coordinates. Supports resolving landmarks, scenic spots, and building names to coordinates."
args:
- name: address
description: "The structured address to be resolved."
type: string
required: true
- name: city
description: "The city to query."
type: string
required: false
- name: output
description: "Output format."
type: string
enum: ["json", "xml"]
default: "json"
requestTemplate:
url: "https://HTTPapi.amap.com/v3/geocode/geo"
method: GET
argsToUrlParam: true
headers:
- key: x-api-key
value: "{{.config.apiKey}}"
responseTemplate:
body: |
# Geocoding Information
{{- range $index, $geo := .geocodes }}
## Location {{add $index 1}}
- **Country**: {{ $geo.country }}
- **Province**: {{ $geo.province }}
- **City**: {{ $geo.city }}
- **City Code**: {{ $geo.citycode }}
- **District**: {{ $geo.district }}
- **Street**: {{ $geo.street }}
- **Street Number**: {{ $geo.number }}
- **Adcode**: {{ $geo.adcode }}
- **Location**: {{ $geo.location }}
- **Level**: {{ $geo.level }}
{{- end }}
This configuration transforms the AMAP geocoding API into a tool that an AI can call. When the AI calls this tool:
Builds an API request using the provided address and city parameters.
Calls the AMAP API.
Transforms the JSON response into a readable Markdown format.
Returns the formatted result to the AI assistant.
Advanced example: Complex response handling with conditional logic
server:
name: weather-api-server
config:
apiKey: your-weather-api-key
tools:
- name: get-weather
description: "Gets the weather forecast for a specified city."
args:
- name: city
description: "City name"
type: string
required: true
- name: days
description: "Number of days (1-7)"
type: integer
required: false
default: 3
- name: include_hourly
description: "Specifies whether to include the hourly forecast."
type: boolean
default: true
requestTemplate:
url: "https://api.weatherapi.com/v1/forecast.json"
method: GET
argsToUrlParam: true
headers:
- key: x-api-key
value: "{{.config.apiKey}}"
responseTemplate:
body: |
# {{.location.name}}, {{.location.country}} Weather Forecast
**Current Temperature**: {{.current.temp_c}}°C
**Feels Like**: {{.current.feelslike_c}}°C
**Condition**: {{.current.condition.text}}
**Humidity**: {{.current.humidity}}%
**Wind Speed**: {{.current.wind_kph}} km/h
## Future Forecast
{{range $index, $day := .forecast.forecastday}}
### {{$day.date}} ({{dateFormat "Monday" $day.date_epoch | title}})
{{if gt $day.day.maxtemp_c 30}}**High temperature warning!**{{end}}
{{if lt $day.day.mintemp_c 0}}**Low temperature warning!**{{end}}
- **Max Temperature**: {{$day.day.maxtemp_c}}°C
- **Min Temperature**: {{$day.day.mintemp_c}}°C
- **Chance of Rain**: {{$day.day.daily_chance_of_rain}}%
- **Condition**: {{$day.day.condition.text}}
#### Hourly Forecast
{{range $hour := slice $day.hour 6 24 3}}
- **{{dateFormat "15:04" $hour.time_epoch}}**: {{$hour.temp_c}}°C, {{$hour.condition.text}}
{{end}}
{{end}}
```<p>This example shows how to:</p><ul><li><p>Use conditional statements (<code data-tag="code" dir="auto" id="8a2cd16431wep">ifThis example demonstrates:
Use a conditional statement (
if) to issue temperature warnings.Use the date formatting function (
dateFormat) to format dates.Use an array slice (
slice) to select weather data for a specific time.Use nested loops to traverse weather data across multiple days and time periods.
Example of using prependBody and appendBody: OpenAPI transformation
The prependBody and appendBody fields are useful when you want to keep the original API response but add extra context. This is especially valuable when you transform an OpenAPI or Swagger specification into an MCP tool, because you can preserve the original JSON response while you provide explanations of the fields for the AI assistant.
server:
name: product-api-server
config:
apiKey: your-api-key-here
tools:
- name: get-product
description: "Get product details"
args:
- name: product_id
description: "Product ID"
type: string
required: true
requestTemplate:
url: "https://api.example.com/products/{{.args.product_id}}"
method: GET
headers:
- key: Authorization
value: "Bearer {{.config.apiKey}}"
responseTemplate:
prependBody: |
# Product Information
The following are the product details, returned in JSON format. Field descriptions:
- **id**: The unique product identifier
- **name**: The product name
- **description**: The product description
- **price**: The product price (USD)
- **category**: The product category
- **inventory**: Inventory information
- **quantity**: The current stock quantity
- **warehouse**: The warehouse location
- **ratings**: A list of user ratings
- **score**: The rating (1-5)
- **comment**: The comment content
appendBody: |
You can use this information to understand the product's details, price, inventory status, and user reviews.
This example shows how to:
Use
prependBodyto add field descriptions before the original JSON response.Use
appendBodyto add usage suggestions at the end of the response.Preserve the original JSON response so that the AI assistant can directly access all the data.
Template syntax
Templates use the GJSON Template syntax (https://github.com/higress-group/gjson_template), which combines Go templates with the GJSON path syntax to process JSON. The template engine supports the following features:
Basic dot notation to access fields, such as `{{.fieldName}}`.
The `gjson` function for complex queries, such as `{{gjson "users.#(active==true)#.name"}}`.
All Sprig template functions, which are similar to Helm functions, such as `{{add}}`, `{{upper}}`, `{{lower}}`, and `{{date}}`.
Control structures, such as `{{if}}`, `{{range}}`, and `{{with}}`.
You can assign a variable as follows: {{$var := .value}}.
For complex JSON responses, you can use GJSON's filtering and query capabilities to extract key information.
AI prompt generation template
When you generate an HTTP to MCP configuration template with an AI assistant, you can use the following prompt:
Please help me create a Higress HTTP-to-MCP configuration to transform an HTTP API into an MCP tool.
## Configuration Format
The configuration should follow this format:
```yaml
server:
name: HTTP-api-server
config:
apiKey: Your API key
tools:
- name: tool-name
description: "A detailed description of what this tool does"
args:
- name: arg1
description: "Description of parameter 1"
type: string
required: true
position: path
- name: arg2
description: "Description of parameter 2"
type: integer
required: false
default: 10
position: query
- name: arg3
description: "Description of parameter 3"
type: array
items:
type: string
position: body
- name: arg4
description: "Description of parameter 4"
type: object
properties:
subfield1:
type: string
subfield2:
type: number
requestTemplate:
url: "https://api.example.com/endpoint"
method: POST
# The following four options are mutually exclusive. Choose only one.
argsToUrlParam: true # Add parameters to the URL query string
# or
# argsToJsonBody: true # Send parameters as a JSON object in the request body
# or
# argsToFormBody: true # Send parameters form-encoded in the request body
# or
# body: |
# {
# "param1": "{{.args.arg1}}",
# "param2": {{.args.arg2}},
# "complex": {{toJson .args.arg4}}
# }
headers:
- key: x-api-key
value: "{{.config.apiKey}}"
responseTemplate:
# The following three options are mutually exclusive. Choose only one.
body:
|
# Results
{{- range $index, $item := .items }}
## Item {{add $index 1}}
- **Name**: {{ $item.name }}
- **Value**: {{ $item.value }}
{{- end }}
# or
# prependBody: |
# # API Response Description
#
# The following is the raw JSON response. The field meanings are as follows:
# - field1: Meaning of field 1
# - field2: Meaning of field 2
#
# appendBody: |
#
# You can use this data to...My API information
The HTTP API to be transformed is: [Describe your API here, including its endpoints, parameters, and response format, or paste the Swagger/OpenAPI specification].
Based on the information above, generate a complete configuration that includes:
1. A descriptive name and appropriate server configuration.
2. Definitions for all necessary parameters, with clear descriptions and appropriate types, required/default values.
3. The most suitable parameter passing method (argsToUrlParam, argsToJsonBody, argsToFormBody, or a custom body).
4. A responseTemplate that transforms the API response into a readable format suitable for AI consumption.Notes
Specification for filling out tools[].args in YAML
The tools[].args parameter defines how the AI gateway transforms and assembles an HTTP request based on the received MCP request parameters. It describes the properties of each parameter sent to the backend service, including the parameter type, position (such as path, header, or body), and whether it is required.
Parameter value location for AI gateway transformation
When processing an MCP request, the AI gateway extracts parameters from the request body at the location specified by the MCP protocol. The AI gateway does not currently support extracting parameters from other locations, such as request headers or other parts of the request body.