feat: add optional tools allowlist via MCP_TOOLS_INCLUDED
When MCP_TOOLS_INCLUDED is set to a comma-separated list of tool names, only those tools are exposed (tools/list and calls); unset or empty exposes every generated tool. Unknown names are ignored with a startup warning and the active selection is logged at startup.
This commit is contained in:
@@ -82,6 +82,7 @@ OPENAPI_SPEC_URL=https://petstore3.swagger.io/api/v3/openapi.json uv run xmcp
|
||||
| `MCP_HOST` | no | `0.0.0.0` | Listen host for the HTTP transport |
|
||||
| `MCP_PORT` | no | `8000` | Listen port for the HTTP transport |
|
||||
| `MCP_SERVER_NAME` | no | spec `info.title` | Name advertised by the MCP server |
|
||||
| `MCP_TOOLS_INCLUDED` | no | – (all tools) | Comma-separated allowlist of tool names to expose |
|
||||
| `HTTP_TIMEOUT` | no | `30` | Timeout in seconds for spec fetch and API calls |
|
||||
| `LOG_LEVEL` | no | `INFO` | Python log level |
|
||||
|
||||
@@ -116,6 +117,20 @@ API request, except credential headers such as `Authorization` and `Cookie`.
|
||||
MCP clients that support custom transport headers should send the key on every
|
||||
request (at least on `tools/call`).
|
||||
|
||||
### Tool allowlist
|
||||
|
||||
By default every operation in the OpenAPI document is exposed as an MCP tool.
|
||||
Set `MCP_TOOLS_INCLUDED` to a comma-separated list of tool names to expose
|
||||
only those:
|
||||
|
||||
```sh
|
||||
MCP_TOOLS_INCLUDED=getPetById,findPetsByStatus
|
||||
```
|
||||
|
||||
Unset or empty exposes all tools. Names that do not match a generated tool are
|
||||
ignored with a startup warning, and the active selection is reported at startup
|
||||
(`Tools allowlist active: exposing N of M tool(s): ...`).
|
||||
|
||||
### Serving a local spec file
|
||||
|
||||
```sh
|
||||
|
||||
Reference in New Issue
Block a user