Configuration
Configuration File
While CLI parameters allow you to quickly load only one OpenAPI spec, the config file allows to load as many OpenAPI specs as you want. Please note, you will need to provide unique name-space per each OpenAPI spec.
File Format
MCPBus configuration file is specified in JSON format.
Example:
{
"hostName": "localhost",
"addr": "localhost",
"port": 8080,
"openApi": {
"apis": [
{
"nameSpace": "weather",
"filePath": "https://downloads.mcpbus.io/config/openapi-weather-gov.json",
"apiAuthKey": "abcxyz"
},
{
"nameSpace": "slack",
"filePath": "../slack-spec3.yaml",
"apiAuthToken": "abcxyz",
"serverName": "https://slack.com"
},
{
"nameSpace": "pets",
"filePath": "../petstore-openapi.json",
"serverName": "https://petstore3.swagger.io",
"apiAuthKey": "abcxyz"
}
]
}
}
The field openApi.apis is an Array of Objects with fields:
- nameSpace - a unique name-space per each OpenAPI spec
- filePath - a path to OpenAPI spec, file path or URL
- serverName - server name of the API (base URL), use this field to override the one from OpenAPI spec (some specs are missing server name ot have it as a template in case API is a multi-tenant service)
- serverVars - server name variables, map of key-values, use this field if your OpenAPI spec server name contains variables (e.g. custom domain or SaaS tenant name), see example here mcpbus-configs Github repo.
- apiAuthKey - in case API's auth scheme is apiKey
- apiAuthToken - in case API's auth scheme is bearer token
- apiAuthUser abd apiAuthPasswd - in case API's auth scheme is basic auth
- allowDestructive - set it to true if you want to include API's endpoints with methods PUT, PATCH, DELETE
More MCPBus config examples can be found in mcpbus-configs Github repo.
Specifying configuration file
You can specify configuration file with CLI parameter --config=path/to/mcpbus.conf
Example with CLI command:
$ mcpbus --config=./mcpbus.conf
Example with Docker:
docker run -d -p 8080:8080 \
-v /Users/alex/project-alpha:/data \
mcpbusio/mcpbus:latest \
-config "/data/mcpbus.conf"
In this command, we assume that your MCPBus config file is available on your host file system at: /Users/alex/project-alpha/mcpbus.conf