Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ docker compose up -d
- Invite-code-based user registration

### MCP Server (optional)
- **Model Context Protocol server** - Expose your Blackbox data to AI assistants (Claude Desktop, claude.ai, and any MCP-compatible client). Toggle on/off from Admin > System > MCP Server. When enabled, serves an HTTP/SSE MCP endpoint with five tools: `list_incidents`, `get_incident`, `list_entries`, `search_entries`, and `list_nodes`.
- **Model Context Protocol server** - Expose your Blackbox data to AI assistants (Claude Desktop, claude.ai, and any MCP-compatible client). Toggle it on or off from Admin > System > MCP Server. When enabled, Blackbox mounts MCP at `/mcp` on the main server and protects it with a server-wide bearer token that you can regenerate from Admin. Older MCP clients configured for a separate port or `/sse` endpoint must be updated. Available tools: `list_incidents`, `get_incident`, `list_entries`, `search_entries`, and `list_nodes`.

### Admin & Observability
- **Audit log** - Every admin action (user management, invite creation, OIDC provider changes, notification destination changes) is recorded with actor identity, IP address, and timestamp. Viewable in Admin > Access > Audit Log. Last 10,000 entries retained.
Expand Down
3 changes: 2 additions & 1 deletion demo/worker/src/seed-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,8 @@ export function createDemoData(nowMs = Date.now()): DemoData {
ai_api_key_set: true,
ai_mode: 'analysis',
mcp_enabled: true,
mcp_port: 8765,
mcp_endpoint_url: '',
mcp_migration_warning: false,
mcp_auth_token_set: true,
mcp_auth_token_suffix: '7KQ9',
mcp_running: false,
Expand Down
4 changes: 2 additions & 2 deletions demo/worker/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export interface AdminConfig {
ai_api_key_set: boolean
ai_mode: 'analysis' | 'enhanced'
mcp_enabled: boolean
mcp_port: number
mcp_endpoint_url: string
mcp_migration_warning: boolean
mcp_auth_token_set: boolean
mcp_auth_token_suffix: string
mcp_running: boolean
Expand Down Expand Up @@ -213,4 +214,3 @@ export interface DemoData {
webhooks: WebhookEndpoint[]
sources: SourcesResponse
}

6 changes: 6 additions & 0 deletions docs/site/docs/data-sources/komodo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ title: Komodo

# Komodo

:::danger

This data source is currently nonfunctional. It is reliant on a [PR](https://github.com/moghtech/komodo/pull/1399) I submitted to the Komodo repo. When that is merged, it will function as intended.

:::

Blackbox supports [Komodo](https://komo.do/) as a server-scoped webhook source. Komodo manages deployments, builds, automations, and server resources across multiple hosts. Events from Komodo appear on the timeline alongside Docker, file, and systemd events from your agents.

Unlike Watchtower and Uptime Kuma, Komodo is **non-singleton**: you can create one source per Komodo instance, so prod and staging environments can each have their own entry with separate secrets and filtering rules.
Expand Down
15 changes: 12 additions & 3 deletions docs/site/docs/deployment/reverse-proxy-and-tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,16 @@ Blackbox trusts `X-Forwarded-For` only from loopback by default. If your proxy
is on another machine, set `TRUSTED_PROXY_IP` on the server container so audit
logs record the real client IP.

## MCP Port
## MCP Endpoint

If you enable the MCP server, remember that it runs on a separate port from the
main UI and API. Proxy it separately if your AI client needs external access.
If you enable the MCP server, it is mounted at `/mcp` on the main Blackbox
server.

- No separate MCP listener or port needs to be exposed through your reverse
proxy.
- Proxy `/mcp` the same way you proxy the rest of the UI and API.
- MCP still requires the server-wide bearer token from **Admin > System > MCP
Server**.

This is a breaking change for older deployments that previously routed MCP to a
dedicated port or `/sse` path.
4 changes: 3 additions & 1 deletion docs/site/docs/getting-started/first-login-and-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Use **Admin > System** to:

- Configure file diff secret redaction behavior.
- Enable and configure optional Ollama-backed incident analysis.
- Enable the MCP server if you want AI assistants to query Blackbox data.
- Enable or disable the mounted MCP endpoint if you want AI assistants to query
Blackbox data.
- Copy or regenerate the server-wide MCP bearer token.

### Integrations

Expand Down
23 changes: 18 additions & 5 deletions docs/site/docs/integrations/mcp-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ When enabled, the MCP server exposes tools including:

1. Open **Admin > System > MCP Server**
2. Enable the service
3. Choose the port
4. Copy the generated token
3. Copy or regenerate the server-wide bearer token

## Claude Desktop Example

```json
{
"mcpServers": {
"blackbox": {
"url": "http://your-server:3001/sse",
"url": "http://your-server/mcp",
"headers": {
"Authorization": "Bearer <your-token>"
}
Expand All @@ -38,8 +37,22 @@ When enabled, the MCP server exposes tools including:
}
```

## Endpoint

Blackbox mounts MCP on the main server at `/mcp`.

- No separate MCP listener or port is required.
- Reverse proxies should forward `/mcp` to the same Blackbox server as the UI
and API.

## Breaking Change

Older MCP setups that pointed clients at a dedicated port or `/sse` endpoint
must be updated to `/mcp` on the main Blackbox server.

## Security

- Every request requires a bearer token.
- The full token is not shown again after generation.
- The MCP port is separate from the main app port.
- The token is server-wide and can be regenerated from **Admin > System > MCP
Server**.
- You can enable or disable MCP from **Admin > System > MCP Server**.
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
# Mounted Streamable HTTP MCP Design

Date: 2026-05-19
Status: Approved for planning

## Summary

Blackbox will replace its separate-port MCP HTTP/SSE server with a mounted MCP
endpoint on the main server listener. The new public endpoint will live at
`/mcp`, use the current server-wide bearer token model, remain toggleable from
`Admin > System`, and return `503 Service Unavailable` when disabled.

This is a clean break from the current port-based design. Legacy `mcp_port`
settings will be ignored at runtime, and Blackbox will surface a one-time admin
warning explaining that MCP moved onto the main server at `/mcp`.

## Goals

- Move MCP under the main Blackbox server instead of binding a second port.
- Switch from the legacy HTTP+SSE transport to Streamable HTTP.
- Preserve the existing server-wide MCP bearer token workflow.
- Keep MCP enable/disable behavior in the admin UI.
- Show a copyable MCP endpoint URL in the admin UI.
- Document the transport and endpoint change clearly as a breaking change.

## Non-Goals

- Preserve backward compatibility with the old separate-port SSE endpoint.
- Introduce user-scoped auth, OAuth, or session auth for MCP.
- Keep `mcp_port` as an active runtime setting.
- Add unrelated MCP tools or expand MCP feature scope.

## Current State

Blackbox currently starts a separate MCP server that:

- validates and stores `mcp_port`
- binds its own TCP listener
- serves the legacy `mcp-go` SSE transport
- is documented as a separate externally exposed port

The main Blackbox Chi router does not currently mount MCP handlers.

## Proposed Architecture

### Transport

Blackbox will upgrade to a Streamable HTTP-capable `mcp-go` release and use its
mounted HTTP transport rather than managing a second listener.

The preferred implementation is:

1. keep the existing MCP tool definitions and business logic
2. replace the separate-listener manager lifecycle with a mounted MCP handler
3. mount that handler into the main server at `/mcp`

If the upgraded SDK cannot exactly match Blackbox's required public behavior,
Blackbox will keep `/mcp` as the public contract and add a small server-side
adapter around the SDK handler rather than owning the whole transport.

### Routing

The main server will expose MCP from the primary HTTP listener at `/mcp`.

Behavior:

- when enabled, authenticated MCP requests are served under `/mcp`
- when disabled, `/mcp` returns `503` with a JSON error payload
- no dedicated MCP TCP listener is created

### Auth

Blackbox will keep the existing server-wide MCP bearer token model:

- token is stored in app settings
- token is generated on first enable if absent
- token can be regenerated from the admin UI
- requests must send `Authorization: Bearer <token>`

This change affects routing and transport only, not auth semantics.

### Origin Validation

Because Streamable HTTP is mounted on the main server, Blackbox must add origin
validation to reduce browser-based abuse risk.

Behavior:

- requests with no `Origin` header are allowed
- requests with an `Origin` header must match the configured or inferred server
origin
- mismatched origins are rejected before MCP processing

This keeps non-browser and server-to-server clients working while enforcing a
basic browser safety check.

## Settings Model

### Kept Settings

- `mcp_enabled`
- `mcp_auth_token`

### Legacy-Only Settings

- `mcp_port`

`mcp_port` remains readable for migration detection only. It has no runtime
effect after this change.

### Admin Config Contract

The admin config API will stop exposing an editable MCP port field. Instead, it
will expose MCP endpoint display data derived from:

1. stored `base_url`, when present
2. the current browser origin in the web UI, when `base_url` is empty

The UI will show a full copyable endpoint URL such as
`https://blackbox.example.com/mcp`.

## Admin UI Behavior

The MCP settings card in `Admin > System` will:

- keep the enable/disable toggle
- remove the port input
- keep token status and token regeneration controls
- show the derived MCP endpoint URL
- show whether MCP is effectively running
- show a one-time migration warning when legacy `mcp_port` data is detected

The migration warning is informational only. It explains that MCP moved from a
separate port to `/mcp` on the main server.

## Migration Behavior

### Runtime

- legacy `mcp_port` values are ignored
- MCP enablement depends only on `mcp_enabled` and `mcp_auth_token`

### User-Facing Migration Notice

On upgrade, when legacy port-based MCP configuration is detected, Blackbox will
surface a one-time admin warning. The warning must explain:

- MCP no longer listens on a dedicated port
- clients must be updated to target `/mcp`
- existing bearer token behavior is unchanged

The warning should be dismissible or otherwise tracked so it is not shown on
every page load forever.

## Protocol Contract

The public MCP contract for Blackbox after this change is:

- endpoint path: `/mcp`
- mounted on the main server listener
- bearer-token protected
- toggleable
- disabled state returns `503`

The implementation should align with current Streamable HTTP expectations and
use `/mcp` as the canonical server URL users configure in clients.

## Error Handling

Expected cases:

- disabled MCP: `503 Service Unavailable` with JSON error body
- missing or invalid bearer token: `401 Unauthorized`
- origin mismatch: request rejected before reaching MCP handler
- unsupported or invalid MCP requests: delegated to the transport handler's
normal protocol error handling

The disabled and auth failure responses should stay predictable and concise so
they are easy to diagnose in external MCP clients.

## Testing Strategy

Follow test-driven development for all production changes.

### Backend Tests

Add tests for:

- mounted `/mcp` routing when enabled
- `503` response when MCP is disabled
- `401` response for missing or invalid bearer token
- origin validation rejecting mismatched origins
- legacy `mcp_port` ignored at runtime
- migration warning surfacing when legacy settings exist
- admin config shape no longer exposing editable port data
- token regeneration continuing to work

### Frontend Tests

Add tests for the MCP admin card:

- endpoint URL display
- absence of port field
- migration warning rendering
- continued token regeneration flow

## Documentation Changes

Update all MCP docs and product copy to reflect the new model:

- README MCP section
- integration docs for MCP setup
- reverse proxy guidance
- any examples that currently reference `/sse` or a dedicated MCP port

The docs must explicitly call this a breaking change for existing remote MCP
clients.

## Risks

### Dependency Upgrade Risk

Upgrading `mcp-go` may require adaptation to a different transport API or
request lifecycle.

Mitigation:

- isolate transport-specific code behind a narrow internal wrapper
- keep MCP tool registration unchanged where possible

### Migration Risk

Existing users may have clients still pointed at the old dedicated port.

Mitigation:

- show a one-time migration warning
- update docs and examples clearly

### Browser-Safety Risk

Mounting MCP onto the main server without origin checks increases exposure to
browser-based request abuse.

Mitigation:

- validate `Origin` when present
- keep bearer-token auth in place

## Implementation Boundaries

The implementation should stay focused on:

- transport migration
- route mounting
- settings cleanup
- admin UI updates
- migration warning
- tests and docs

Do not add new MCP capabilities or expand auth scope as part of this change.
Loading
Loading