feat: filter tools by OpenAPI tag via MCP_TOOLS_TAGS_INCLUDED
CI / Build and push docker image (push) Successful in 1m21s
CI / Build and push docker image (push) Successful in 1m21s
Adds a comma-separated tag allowlist alongside the existing name allowlist. When both are configured a tool must match both (AND). Unknown names/tags are ignored with a startup warning, and a filter that resolves to nothing exposes no tools rather than falling back to all of them. Startup logs the active filters and the exposed tools.
This commit is contained in:
@@ -83,6 +83,7 @@ OPENAPI_SPEC_URL=https://petstore3.swagger.io/api/v3/openapi.json uv run xmcp
|
||||
| `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 |
|
||||
| `MCP_TOOLS_TAGS_INCLUDED` | no | – (all tags) | Comma-separated allowlist of OpenAPI tags to expose |
|
||||
| `HTTP_TIMEOUT` | no | `30` | Timeout in seconds for spec fetch and API calls |
|
||||
| `LOG_LEVEL` | no | `INFO` | Python log level |
|
||||
|
||||
@@ -117,19 +118,24 @@ 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
|
||||
### Tool allowlists
|
||||
|
||||
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:
|
||||
Two environment variables can restrict the exposed set; each accepts a
|
||||
comma-separated list, and unset or empty disables that filter:
|
||||
|
||||
```sh
|
||||
# Only these operations
|
||||
MCP_TOOLS_INCLUDED=getPetById,findPetsByStatus
|
||||
|
||||
# Only operations tagged "pet" in the OpenAPI document
|
||||
MCP_TOOLS_TAGS_INCLUDED=pet
|
||||
```
|
||||
|
||||
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): ...`).
|
||||
When both are set, a tool must match both filters (name **and** tag). Entries
|
||||
that do not match anything are ignored with a startup warning, and the active
|
||||
selection is reported at startup
|
||||
(`Tool filters active (names: ...; tags: ...): exposing N of M tool(s): ...`).
|
||||
|
||||
### Serving a local spec file
|
||||
|
||||
|
||||
Reference in New Issue
Block a user