Metadata-Version: 2.4
Name: bunkerweb-mcp
Version: 0.8.0
Summary: MCP server that exposes BunkerWeb's API to large language models
Author-email: Bunkerity <contact@bunkerity.com>
License-Expression: MIT
Project-URL: Homepage, https://www.bunkerweb.io
Project-URL: Documentation, https://docs.bunkerweb.io
Project-URL: Repository, https://github.com/bunkerity/bunkerweb-mcp
Project-URL: Issues, https://github.com/bunkerity/bunkerweb-mcp/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.109.0
Requires-Dist: uvicorn[standard]>=0.31.1
Requires-Dist: httpx[http2]>=0.27.1
Requires-Dist: pydantic>=2.11.0
Requires-Dist: pydantic-settings>=2.5.2
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: tenacity>=8.2.2
Requires-Dist: pyyaml>=6
Requires-Dist: mcp==2.3.0
Requires-Dist: slowapi>=0.1.9
Requires-Dist: limits>=3
Requires-Dist: aiocache>=0.12.2
Requires-Dist: prometheus-client>=0.19.0
Requires-Dist: opentelemetry-api>=1.21.0
Requires-Dist: opentelemetry-sdk>=1.21.0
Requires-Dist: opentelemetry-instrumentation-fastapi>=0.42b0
Requires-Dist: opentelemetry-instrumentation-httpx>=0.42b0
Requires-Dist: opentelemetry-exporter-otlp-proto-grpc>=1.21.0
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: asgiref>=3.8.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.7.0; extra == "dev"
Requires-Dist: bandit>=1.7.5; extra == "dev"
Requires-Dist: locust>=2.15.0; extra == "dev"
Requires-Dist: pre-commit>=4; extra == "dev"
Dynamic: license-file

<p align="center">
  <a href="https://www.bunkerweb.io">
    <img alt="BunkerWeb logo" src="https://github.com/bunkerity/bunkerweb/raw/v1.6.17-rc1/misc/logo.png" width="350" />
  </a>
</p>

<h1 align="center">BunkerWeb MCP Server</h1>

<!-- mcp-name: io.github.bunkerity/bunkerweb-mcp -->

<p align="center">
  Expose the BunkerWeb API to MCP clients through tools, read-only resources, and tool guidance prompts.
</p>

<p align="center">
  <img alt="36 API tools, 13 Agent Skills, streamable HTTP and stdio transports." src="https://raw.githubusercontent.com/bunkerity/bunkerweb-mcp/main/docs/assets/stats.svg" width="100%" />
</p>

<p align="center">
  <a href="https://github.com/bunkerity/bunkerweb-mcp/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/bunkerity/bunkerweb-mcp/actions/workflows/ci.yml/badge.svg" /></a>
  <a href="https://score.getplumber.io/github.com/bunkerity/bunkerweb-mcp"><img alt="Plumber CI/CD security score" src="https://score.getplumber.io/github.com/bunkerity/bunkerweb-mcp.svg" /></a>
  <a href="https://securityscorecards.dev/viewer/?uri=github.com/bunkerity/bunkerweb-mcp"><img alt="OpenSSF Scorecard" src="https://api.securityscorecards.dev/projects/github.com/bunkerity/bunkerweb-mcp/badge" /></a>
  <a href="https://glama.ai/mcp/servers/bunkerity/bunkerweb-mcp"><img alt="Glama MCP server score" src="https://glama.ai/mcp/servers/bunkerity/bunkerweb-mcp/badges/score.svg" /></a>
  <a href="https://hub.docker.com/r/bunkerity/bunkerweb-mcp"><img alt="Docker pulls" src="https://img.shields.io/docker/pulls/bunkerity/bunkerweb-mcp" /></a>
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg" /></a>
</p>

<p align="center">
  <a href="https://www.bunkerweb.io">Website</a> &#124;
  <a href="https://docs.bunkerweb.io">BunkerWeb documentation</a> &#124;
  <a href="#quick-start">Quick start</a> &#124;
  <a href="#connect-an-mcp-client">Client setup</a>
</p>

Manage services, instances, bans, configuration snippets, plugins, and scheduler jobs.
Connect through streamable HTTP or a local stdio subprocess. Legacy JSON-RPC HTTP
and WebSocket endpoints remain available for existing integrations.

> [!NOTE]
> You need a reachable BunkerWeb API and its credentials when authentication is enabled.
> See the [BunkerWeb documentation](https://docs.bunkerweb.io) for API setup.

## How it fits together

The server holds no BunkerWeb state. It turns each tool call into a request to the BunkerWeb API.

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/bunkerity/bunkerweb-mcp/main/docs/assets/architecture-dark.svg">
    <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/bunkerity/bunkerweb-mcp/main/docs/assets/architecture-light.svg">
    <img alt="Architecture: an MCP client talks to the BunkerWeb MCP server over streamable HTTP or stdio. The server calls the BunkerWeb API over REST. It also reads local logs and calls an optional search service." src="https://raw.githubusercontent.com/bunkerity/bunkerweb-mcp/main/docs/assets/architecture-light.svg" width="100%">
  </picture>
</p>

<table>
  <tr>
    <td width="33%" valign="top"><b><a href="#quick-start">Run it</a></b><br>Docker Compose against your own API, or the bundled demo stack.</td>
    <td width="33%" valign="top"><b><a href="#connect-an-mcp-client">Connect a client</a></b><br>Streamable HTTP at <code>/mcp/</code>, or stdio for Claude Code and Claude Desktop.</td>
    <td width="33%" valign="top"><b><a href="#tools-and-resources">36 API tools</a></b><br>Services, instances, bans, configuration snippets, plugins, and scheduler jobs.</td>
  </tr>
  <tr>
    <td valign="top"><b><a href="#agent-skills">13 Agent Skills</a></b><br>Served as <code>skill://bunkerweb/</code> resources.</td>
    <td valign="top"><b><a href="#security">Security</a></b><br>Shared-secret checks, <code>MCP_READ_ONLY</code>, secret redaction.</td>
    <td valign="top"><b><a href="#observability">Observability</a></b><br>Prometheus <code>/metrics</code>, <code>/health</code>, <code>/ready</code>, opt-in tracing.</td>
  </tr>
</table>

## Upgrading to 0.8.0

> [!WARNING]
> **The HTTP server now fails closed.** It refuses to start when write tools are enabled and
> `BUNKERWEB_WEBSOCKET_TOKEN` is not set. Before 0.8.0 it started and left `/mcp/` open.

Pick one way out:

- **Set the token.** `export BUNKERWEB_WEBSOCKET_TOKEN=$(openssl rand -hex 32)`. Clients send
  `Authorization: Bearer <token>`. Recommended.
- **Serve read tools only.** `MCP_READ_ONLY=true` starts without a token, with a warning, and
  `/mcp/` stays open. A configured token is still enforced.
- **Accept the risk.** `MCP_ALLOW_UNAUTHENTICATED=true` starts with writes and no token. Anyone who
  can reach the port can then delete services, install plugins and mint API tokens. Use it only
  behind a trusted network boundary.

Also changed:

- The token is checked on `/mcp/` and `/rpc` whenever it is set, not only with `BUNKERWEB_LOGS_PATH`.
  `x-mcp-token` and `?token=` are **deprecated** aliases: `x-mcp-token` on `/mcp/` and `/rpc`,
  `?token=` on `/ws`. Move clients to `Authorization: Bearer`.
- `/rpc`, `/ws` and `/tools` now apply the Host check that `/mcp/` already had. Add every name a
  client uses to `MCP_ALLOWED_HOSTS`, with and without the port. A request that carries an `Origin`
  header gets `403` unless the origin is in `MCP_ALLOWED_ORIGINS`.
- `/rpc` answers `415` unless `Content-Type` is `application/json`.
- `list_services`, `list_bans`, `list_jobs` and `list_cache_files` return one page. Pass `limit` and
  `offset`; read `next_offset` until it is `null`. [n8n workflows](n8n-workflows/) that listed
  everything now page.
- Stdio is unaffected: it has no HTTP listener and no client token.

Details: [Security](#security), [docs/security.md](docs/security.md) and
[ADR 0009](docs/adr/0009-fail-closed-http-auth.md).

## Quick start

### Connect to an existing BunkerWeb API

1. Clone this repository and open its directory.
2. Copy [.env.example](.env.example) to `.env`. Set `BUNKERWEB_BASE_URL` to an API
   address reachable **from the container**, and supply its bearer token or Basic
   credentials. A container's `localhost` refers to itself. Set
   `BUNKERWEB_WEBSOCKET_TOKEN` to a random value (`openssl rand -hex 32`): the Compose
   file refuses to start without it.
3. Set `MCP_ALLOWED_HOSTS=localhost,localhost:8080,127.0.0.1,127.0.0.1:8080` for
   local HTTP clients. Keep `SEARCH_MODE=disabled` unless you have a search service.
4. Run `docker compose -f docker-compose-mcp-only.yml up --build -d`.
5. Check liveness with `curl http://127.0.0.1:8080/health`; expect `"status":"healthy"`.
6. Connect your client to `http://127.0.0.1:8080/mcp/` with the header
   `Authorization: Bearer <BUNKERWEB_WEBSOCKET_TOKEN>`.

The [MCP-only Compose file](docker-compose-mcp-only.yml) loads `.env`, builds the
server, and publishes port 8080. For the published image instead, run
`docker run --rm -p 127.0.0.1:8080:8080 --env-file .env bunkerity/bunkerweb-mcp:latest`.
Use a release tag for a fixed version; the [release workflow](.github/workflows/release.yml)
builds images for AMD64 and ARM64.

### Try the bundled demo stack

Run `docker compose up --build -d` from the repository directory. The default
[docker-compose.yml](docker-compose.yml) starts BunkerWeb 1.6.13, its scheduler and
API, MariaDB, Redis, and this server. It publishes BunkerWeb on ports 80/443 and
MCP on 8080. The included [.mcp.json](.mcp.json) points Claude Code at this server and sends
`Authorization: Bearer ${BUNKERWEB_WEBSOCKET_TOKEN}`: export `BUNKERWEB_WEBSOCKET_TOKEN` with the
same value before starting Claude Code, or the server answers `401`.

> [!WARNING]
> The demo publishes MCP on `127.0.0.1:8080` and requires `BUNKERWEB_WEBSOCKET_TOKEN`
> (export it or put it in `.env`); clients send it as `Authorization: Bearer <token>`.
>
> This file sets the API URL and demo credentials in its service definitions;
> editing `.env` does not replace those values. It also disables search. Use it on a
> trusted development machine; review credentials, port exposure, and host validation
> before exposing it to a network.

## Install

Pick the way BunkerWeb runs on your side. [docs/integrations.md](docs/integrations.md) has the
steps for each.

| Platform | How | Details |
| --- | --- | --- |
| Any, stdio client | `uvx bunkerweb-mcp` from PyPI | [Stdio quick start](docs/integrations.md#stdio-quick-start) |
| Linux (Debian, Ubuntu, RHEL, Fedora) | deb or rpm from the GitHub Release, run as a systemd service | [Linux (deb and rpm)](docs/integrations.md#linux-deb-and-rpm) |
| Docker | `bunkerity/bunkerweb-mcp` image in your Compose file | [Docker](docs/integrations.md#docker) |
| Docker autoconf | The same service, without labels | [Docker autoconf](docs/integrations.md#docker-autoconf) |
| Kubernetes | `bunkerweb-helm` chart with `mcp.enabled: true` | [Kubernetes](docs/integrations.md#kubernetes) |
| MCP client setup | Claude Code, Claude Desktop, Cursor, VS Code | [Connect a client](docs/integrations.md#connect-a-client) |

## Connect an MCP client

### Streamable HTTP

Use `/mcp/`, including the trailing slash. The repository's Claude Code config uses:

```json
{
  "mcpServers": {
    "bunkerweb": {
      "type": "http",
      "url": "http://127.0.0.1:8080/mcp/",
      "headers": { "Authorization": "Bearer <BUNKERWEB_WEBSOCKET_TOKEN>" }
    }
  }
}
```

For a remote server, change the URL to your HTTPS endpoint. Keep the real token out of version
control. A server started with `MCP_READ_ONLY=true` or `MCP_ALLOW_UNAUTHENTICATED=true` and no token
needs no header. Read the authentication rules in [Security](#security) before exposing HTTP.

### Stdio: Claude Code or Claude Desktop

From the repository directory, install with Python 3.11 or newer using the
hash-pinned build and runtime dependencies:

```bash
python3 -m venv .venv
.venv/bin/pip install --require-hashes --no-deps -r requirements-build.txt -r requirements.txt
.venv/bin/pip install --no-deps --no-build-isolation .
```

This creates `.venv/bin/bunkerweb-mcp` in your checkout. Use its absolute path in
the client JSON below, replacing `/absolute/path/to` with your repository directory.
It runs a stdio subprocess without an HTTP listener.

For Claude Code, replace the HTTP entry in `.mcp.json` with this configuration.
For Claude Desktop, put it in `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "bunkerweb": {
      "command": "/absolute/path/to/.venv/bin/bunkerweb-mcp",
      "env": {
        "BUNKERWEB_BASE_URL": "http://api.example.com:8888",
        "BUNKERWEB_API_TOKEN": "<api-token>",
        "SEARCH_MODE": "disabled"
      }
    }
  }
}
```

Replace the executable path and API address with your own. Keep real credentials
out of version control. Stdio uses your local process permissions and API credentials.

## Tools and resources

Read `GET /tools` for the running server's tool names, descriptions, and input
schemas. The [registry](src/bunkerweb_mcp/tools/registry.py) defines 36 API tools, all named `verb_noun` ([ADR 0007](docs/adr/0007-verb-noun-tool-names.md)):

| Group | Tools |
| --- | --- |
| Authentication and probes | `create_api_token`, `ping_api`, `diagnose_bunkerweb` |
| Instances | `list_instances`, `get_instance`, `create_instance`, `update_instance`, `delete_instances`, `ping_instances`, `stop_instances`, `reload_instances` |
| Bans | `list_bans`, `ban_ips`, `unban_ips` |
| Services | `list_services`, `get_service`, `create_service`, `update_service`, `delete_service` |
| Global configuration | `get_global_config`, `update_global_config` |
| Custom configuration | `list_configs`, `get_config`, `create_config`, `create_configs_from_files`, `update_config`, `update_config_from_file`, `delete_configs` |
| Plugins | `list_plugins`, `install_plugins`, `uninstall_plugin` |
| Job cache files | `list_cache_files`, `get_cache_file`, `delete_cache_files` |
| Scheduler jobs | `list_jobs`, `run_jobs` |

Optional tools:

- `list_logs`, `read_log`: register when `BUNKERWEB_LOGS_PATH` points to a runtime
  log directory. Mount it read-only; HTTP mode also requires the shared secret.
  Reads scan up to 1 MiB and return at most 500 lines or 64 KiB of content, with
  cursors for older history. Compressed `.gz` rotations are excluded. Treat log
  content as untrusted data.
- `search_bunkerweb_docs`: registers in remote search mode.

### Tool behavior

Use `diagnose_bunkerweb` to check the connected API's host, reachability, authentication, version,
`MULTISITE`, and instance counts. Pass `service` to inspect its existence, draft state,
and setting-owner counts. An unknown version appears as
`unknown (strictest rules applied)`.

`update_service` validates, writes, then reads back:

- It checks setting names and ownership before sending changes. It refuses
  the request if validation reads fail or `MULTISITE` is not `yes`. It skips invalid or
  externally owned keys and unsupported renames; if nothing remains, it sends no write.
- After an accepted write, it reads the service back without the result cache. The result
  adds `summary` as its first field and a `receipt` with `db` (`verified`, `partial`, or
  `unverified`), plus `issues` and `hints` when needed. These report names and reasons,
  without setting values.
- A complete match reads `DB VERIFIED (2/2 MATCH). LIVE UNVERIFIED.`
  A failed read-back reads `WRITE ACCEPTED. DB UNVERIFIED. LIVE UNVERIFIED.`
  Only a read-back that confirms a draft adds `DRAFT: NOT PUBLISHED.`
  A failed read-back omits the draft marker.
- The summary always ends `LIVE UNVERIFIED.` BunkerWeb 1.6 offers no live-state signal;
  the receipt does not prove that instances use the saved configuration.

`stop_instances` and `reload_instances` need exactly one of `hostname` or `all=true`; any other
combination fails validation and sends nothing to BunkerWeb. `delete_instances`,
`delete_configs` and `delete_cache_files` take a list and always call the bulk endpoint.
`update_service` with `is_draft` toggles a service between draft and online.

`list_services`, `list_bans`, `list_jobs` and `list_cache_files` return one page of items.
They take `limit` (1 to 1000; default 100, 20 for `list_jobs`, 10 for `list_cache_files` with
`with_data`) and `offset`, and add `total`, `returned` and `next_offset` (`null` on the last
page) to the result. The `logs://jobs` and `bans://active` resources stay complete.

Tool metadata identifies reads and destructive writes. Eight write tools also carry the hint
`anthropic/requiresUserInteraction` so hosts that honour it ask a person first; it is a client
hint, not a server control (see [docs/security.md](docs/security.md#approval-hint)). `MCP_READ_ONLY=true` removes
write tools and their prompts on every transport, including `create_api_token`, which
returns a credential. See [ADR 0006](docs/adr/0006-tool-effects-and-read-only-mode.md)
for the version rules and enforcement boundary.

### Resources

The [MCP adapter](src/bunkerweb_mcp/mcp_adapter.py) also exposes read-only resources:

| URI | Contents |
| --- | --- |
| `config://global` | Global configuration; an empty upstream result includes guidance to use `get_service` with `full=true`. |
| `logs://jobs` | Scheduler jobs and execution history, separate from runtime log files. |
| `bans://active` | Active IP bans. |
| `instances://status` | Registered instances and their status. |
| `skill://bunkerweb/<skill>/<path>` | Bundled Agent Skills and reference files as text; see [Agent Skills](#agent-skills). |

The first four resources return JSON. Skill resources register when `MCP_ENABLE_SKILLS=true`.

### Prompts

Tool guidance comes from the bundled [prompt catalog](src/bunkerweb_mcp/data/tool_prompts.json).
The server exposes matching MCP prompts when catalog text exists. Override the
catalog with `BUNKERWEB_PROMPT_CATALOG`.

Examples and legacy workflow integrations live in [n8n-workflows](n8n-workflows/).

## Agent Skills

The server bundles 13 BunkerWeb Agent Skills (59 files), available through MCP
`resources/list` and `resources/read`. Start with `skill://bunkerweb/bunkerweb/SKILL.md`;
the server's initialization instructions point there too. This entrypoint links
to the other 12 skills on GitHub and to its bundled `references/` files.

Read bundled files at `skill://bunkerweb/<skill>/<path>`, for example
`skill://bunkerweb/bunkerweb/references/docker.md`. Files are served verbatim,
with `text/markdown` for `.md` files. Set `MCP_ENABLE_SKILLS=false` to omit skill
resources and the skills sentence from the server instructions.

### Skills extension

The server also advertises the MCP skills extension, `io.modelcontextprotocol/skills` (SEP-2640),
with two methods: `skills/list` returns each skill's `uri`, `frontmatter` and files (`uri`,
`digest`, `size`), and `skills/get` returns one entry by its `SKILL.md` URI. Digests and sizes are
those of the bytes `resources/read` returns. It serves the same files as the `skill://` resources,
and shares the `MCP_ENABLE_SKILLS` switch. On `/mcp/` it needs the same `Authorization: Bearer`
header as every other call.

Claude Code loads skills through these two methods, not through plain resources. It needs a host
that speaks protocol 2026-07-28 to the server (`server/discover`), calls `skills/list` and
`skills/get`, and reads the files with `resources/read`; 2.1.332 is the version this was built
against. Native discovery in Claude Code has not been run against this server: the wire was
tested with the SDK client and raw HTTP. A client on an older protocol version sees no extension
but still reads the `skill://` resources. See
[ADR 0010](docs/adr/0010-skills-extension-before-the-sdk-release.md).

Skills come from [bunkerity/bunkerweb-skills](https://github.com/bunkerity/bunkerweb-skills), pinned by [SKILLS_REF](SKILLS_REF).
Refresh with [scripts/sync_skills.py](scripts/sync_skills.py) `--ref <sha>`; CI runs the script with `--check` to detect drift.

## Configuration

[config.py](src/bunkerweb_mcp/config.py) reads environment variables and `.env`.
Defaults below come from that settings model; Compose service values and container
environment variables can override them. `unset` denotes an absent value or an empty string.

| Environment variable | Default | Meaning |
| --- | --- | --- |
| `BUNKERWEB_BASE_URL` | `http://localhost:8888` | Base URL for the BunkerWeb control-plane API. |
| `BUNKERWEB_API_TOKEN` | `unset` | Static API token used for Authorization bearer header (masked in logs). |
| `BUNKERWEB_BASIC_USERNAME` | `unset` | Username for HTTP Basic authentication. |
| `BUNKERWEB_BASIC_PASSWORD` | `unset` | Password for HTTP Basic authentication (masked in logs). |
| `BUNKERWEB_REQUEST_TIMEOUT_SECONDS` | `30.0` | HTTP request timeout in seconds. |
| `BUNKERWEB_MAX_RETRIES` | `3` | Maximum number of retries for transient HTTP errors. |
| `BUNKERWEB_RETRY_BACKOFF_INITIAL` | `0.5` | Initial backoff delay in seconds. |
| `BUNKERWEB_RETRY_BACKOFF_MAX` | `5.0` | Maximum backoff delay in seconds. |
| `BUNKERWEB_WEBSOCKET_TOKEN` | `unset` | Shared secret for `/mcp/`, `/rpc` and `/ws`, sent as `Authorization: Bearer <token>`. The HTTP server refuses to start without it when writes are enabled, unless `MCP_READ_ONLY` or `MCP_ALLOW_UNAUTHENTICATED` is true; always required with `BUNKERWEB_LOGS_PATH`. See Security. |
| `MCP_ALLOW_UNAUTHENTICATED` | `false` | Start the HTTP server with writes enabled and no token. Anyone who can reach the port can then change BunkerWeb. A configured token is still enforced. |
| `BUNKERWEB_LOG_LEVEL` | `INFO` | Application log level. |
| `BUNKERWEB_LOGS_PATH` | `unset` | Runtime log directory; unset disables log tools. Mount read-only. |
| `BUNKERWEB_PROMPT_CATALOG` | `unset` | Custom tool-prompt JSON path; unset uses the bundled catalog. |
| `BUNKERWEB_REDACT_SECRETS` | `false` | Mask the values of settings whose names match a sensitive pattern in tool and resource outputs, withhold upstream error details and refuse writes to sensitive settings. See Security. |
| `BUNKERWEB_REDACT_PATTERN` | `unset` | Regular expression that replaces the built-in sensitive setting name pattern; unset keeps the built-in one. Avoid nested quantifiers such as `(a+)+$`. |
| `SEARCH_MODE` | `remote` | `remote` enables documentation search; `disabled` omits the tool. Compose and `.env.example` use `disabled`. |
| `SEARCH_API_URL` | `http://localhost:8000` | URL of the remote search service API. |
| `SEARCH_TIMEOUT` | `10.0` | Search API request timeout in seconds. |
| `MCP_ENABLE_DNS_REBINDING_PROTECTION` | `true` | Enable DNS rebinding protection for MCP endpoints (recommended for production). |
| `MCP_ALLOWED_HOSTS` | `localhost,127.0.0.1` | Comma-separated MCP Host allowlist. Include the port variants clients send. |
| `MCP_ALLOWED_ORIGINS` | `unset` | Comma-separated MCP Origin allowlist for browser clients. |
| `MCP_ENABLE_SKILLS` | `true` | Serve bundled Agent Skills as `skill://bunkerweb/` resources and through the skills extension. Set `false` to omit both. |
| `MCP_READ_ONLY` | `false` | Register only read-only tools; write tools are not available on any transport. |
| `RATE_LIMIT_ENABLED` | `false` | Enable rate limiting on endpoints. |
| `RATE_LIMIT_TOOLS` | `30/minute` | Requests to `/tools` per client IP, when rate limiting is enabled. |
| `RATE_LIMIT_RPC` | `100/minute` | Requests to `/rpc` per client IP, when rate limiting is enabled. |
| `RATE_LIMIT_WS` | `500/minute` | Messages per WebSocket connection, when rate limiting is enabled. |
| `CACHE_ENABLED` | `true` | Cache selected read operations in process memory. |

`WORKERS` is a Docker entrypoint setting, default `1`, rather than a Pydantic
setting. Caches and rate-limit state live in each worker process.

### Documentation search

Search needs a separate service: set `SEARCH_MODE=remote` and `SEARCH_API_URL`
to its URL. This repository does not bundle that service. Without it, disable search;
otherwise the server registers `search_bunkerweb_docs` and readiness checks the service.

## Security

> [!WARNING]
> Tools can change configuration, stop instances, delete services, and install plugins.
> Grant access only to clients you trust with the configured BunkerWeb API credentials.
> Set `MCP_READ_ONLY=true` to serve only read tools on every transport. The server has no
> per-client roles.

When `BUNKERWEB_WEBSOCKET_TOKEN` is set, the HTTP application enforces it on `/mcp/`, `/rpc` and
`/ws`. It never relaxes a configured token, whatever `MCP_READ_ONLY` or `MCP_ALLOW_UNAUTHENTICATED`
say.

| Endpoint | Credential accepted | Host and Origin check | Refusal |
| --- | --- | --- | --- |
| `/mcp/` | `Authorization: Bearer <token>`; `x-mcp-token` is deprecated | Yes | `401` with `WWW-Authenticate: Bearer realm="bunkerweb-mcp"`; `421` or `403` |
| `/rpc` | `Authorization: Bearer <token>`; `x-mcp-token` is deprecated | Yes | `421`, `403`, `401` with the same challenge, `415` unless `Content-Type: application/json` |
| `/ws` | `Authorization: Bearer <token>`; `?token=` is deprecated | Yes | Handshake refused: `ws.close(1008)` before `accept`; under Uvicorn clients see an HTTP `403` handshake response, not a `1008` close frame |
| `/tools` | None (tool descriptors only) | Yes | `421` or `403` |
| `/health`, `/ready`, `/metrics` | None | No | None |

HTTP startup fails when `BUNKERWEB_LOGS_PATH` is set without a token, and when writes are enabled
without a token unless `MCP_READ_ONLY=true` or `MCP_ALLOW_UNAUTHENTICATED=true`. See
[Upgrading to 0.8.0](#upgrading-to-080). `BUNKERWEB_API_TOKEN` and Basic credentials
authenticate the server to BunkerWeb; they do not authenticate MCP clients. The API client
prefers a bearer token over Basic auth. Stdio has no HTTP listener and no client token.

Keep HTTP on a trusted network or behind an authenticated reverse proxy. Use TLS
for remote connections, restrict the exposed endpoints, and configure
`MCP_ALLOWED_HOSTS` and `MCP_ALLOWED_ORIGINS` for your clients. DNS rebinding
protection does not replace authentication. See [docs/security.md](docs/security.md) and
the MCP [authorization](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization)
and [security best practices](https://modelcontextprotocol.io/docs/tutorials/security/security_best_practices)
guides.

### Secret redaction

Set `BUNKERWEB_REDACT_SECRETS=true` to mask the values of sensitive settings (matched by
name) in tool and resource outputs before they reach the client. Upstream API error
details are withheld and only the HTTP status is returned. It is not a content scanner:
custom config snippets, log lines, documentation search results, cache files outside the
denylist and secrets embedded in other values are not masked. See
[docs/security.md](docs/security.md#secret-redaction).

## Observability

The HTTP server exposes Prometheus metrics at `/metrics`, liveness at `/health`,
and dependency readiness at `/ready`. Readiness probes BunkerWeb's `/ping` without
API credentials and, in remote search mode, the search service's `/health`; a
protected API can therefore fail readiness even when authenticated tools work.

See [docs/OBSERVABILITY.md](docs/OBSERVABILITY.md) for metrics, tracing, and dashboard
reference. Grafana dashboards: [BunkerWeb MCP](deploy/grafana/dashboards/bunkerweb-mcp.json)
and [MCP BunkerWeb](deploy/grafana/dashboards/mcp-bunkerweb.json).
Tracing is opt-in; this repository does not include a monitoring Compose stack.

## Development

Use the hash-pinned build and development dependencies before installing this
package from source. [AGENTS.md](AGENTS.md) contains installation, lint, formatting,
strict type-checking, and test commands. Tests mock upstream HTTP calls and enforce
an 80% coverage floor.

[.pre-commit-config.yaml](.pre-commit-config.yaml) checks YAML/TOML, file hygiene,
and Python lint/formatting. Run `pre-commit install` to install the local hooks.
The [architecture decisions](docs/adr/README.md) record design context.
[docs/tdqs.md](docs/tdqs.md) explains the Glama quality score and how to run the same
scorer locally with `scripts/tdqs.py` before changing tool descriptions.

## Supply chain

- Build, runtime, and development dependencies use hash-pinned
  `requirements-build.txt`, `requirements.txt`, and `requirements-dev.txt` locks.
  Edit their `.in` sources and regenerate with the uv commands in [AGENTS.md](AGENTS.md);
  do not hand-edit generated locks.
- [CI](.github/workflows/ci.yml) runs quality checks, tests on Python 3.11–3.14,
  CodeQL, and container checks. [Plumber](.github/plumber/README.md) checks CI/CD
  security; [OpenSSF Scorecard](.github/workflows/scorecards-analysis.yml) analyzes
  repository security practices. Badges link to published results.
- The [release workflow](.github/workflows/release.yml) requests build provenance
  and an SBOM for Docker images.
- Follow [.github/SECURITY.md](.github/SECURITY.md) to report vulnerabilities.

## License

MIT. See [LICENSE](LICENSE).
