Files
feuerwerk/tools/mcp/compose.yml
T
adminandClaude Opus 5.5 48ec722660
feuerwerk / gate (push) Successful in 5m41s
feuerwerk / suite (push) Successful in 18m44s
Let an AI agent see the open editor through MCP (#429)
Claude Code should be able to work inside the user's open editor tab.
This first stage connects the two and lets the agent look: what the
user sees and a picture of it. Changing the project comes in stage 2.

- An agent token per account opens only /mcp, no API route. The
  dialog "Agent tokens..." in the account menu creates it once, shows
  the ready "claude mcp add" line and revokes it. The server keeps
  only its sha256 (api/lib/AgentTokens.php).
- Wrong tokens count into the sign-in brake from #427. Changing the
  password, renaming or deleting an account ends its tokens.
- The relay (tools/mcp/) is a small Node service without packages,
  WebSocket server included. It runs in the container feuerwerk-mcp
  because PHP-FPM cannot hold connections. Whether a token or a tab
  ticket is valid is still decided by the PHP API, through two routes
  that answer only with the relay key.
- The tab joins over WebSocket on the same origin with the normal
  session, an Origin check and a one-time ticket. It connects only
  after "Agent" is switched on in the account menu. One tab per
  account is active, a new one takes over. Guests get nothing.
- Tools: get_view (project, tab, document, selection with names,
  camera, play state, open dialog) and screenshot. The resource
  feuerwerk://view can be subscribed. Claude Code does not act on
  that reliably, so a changed view is also noted on the next answer.
- A badge next to the account menu shows the connected agents. It
  counts only agents with an open stream or a request in the last
  two minutes.
- CI starts the relay in front of php -S (tools/ci/serve.sh), and
  e2e 71 runs the whole path in the browser.

Found on the live test: the badge showed four agents because old
sessions of revoked tokens were still counted.

Tests:
- Gate on atx: 316 files, 4888 tests
- relay protocol test with fake API and fake tabs: 23/23
- get_view, tools, socketUrl: 16/16
- PHP agents 29, rights 103 checks
- e2e 71 on atx 10/10, against the live site 10/10, no CSP violation
- real Claude Code against the live site: get_view answered
- ZAP against /mcp: nothing at High or Medium
- every new check fails when the guard it covers is taken out (6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 10:39:34 +02:00

41 lines
1.7 KiB
YAML

# The MCP relay on stein2 (#429), a compose project of its own beside the web stack:
#
# docker compose -f tools/mcp/compose.yml up -d
#
# nginx passes /feuerwerk/mcp on to it (the location in /_stacks/web/nginx.conf). It listens on the
# docker bridge's gateway alone, where nginx's container reaches it and nothing from outside does,
# and asks the API through the web stack's published port. Its network of its own separates
# nothing on stein2: the docker daemon runs with `iptables: false` there, so every container
# reaches every other (measured 2026-10-17, the PHP container's FastCGI port included).
#
# It reads its own code, the tool list and the key it shares with the API, nothing else of the
# checkout. A change to tools/mcp/ needs a restart; the tool list is read on every use.
name: feuerwerk-mcp
services:
feuerwerk-mcp:
container_name: feuerwerk-mcp
image: node:22-alpine
restart: unless-stopped
user: '33:33'
working_dir: /srv/feuerwerk
volumes:
- ../../tools/mcp:/srv/feuerwerk/tools/mcp:ro
- ../../src/editor/agent:/srv/feuerwerk/src/editor/agent:ro
- ../../data/mcp-relay.key:/run/feuerwerk/mcp-relay.key:ro
environment:
FEUERWERK_MCP_API: http://172.16.0.1:8080/feuerwerk/api/index.php
FEUERWERK_MCP_KEY_FILE: /run/feuerwerk/mcp-relay.key
FEUERWERK_MCP_ORIGINS: https://nockal.com,https://feuerwerk.nockal.com
FEUERWERK_MCP_TRUST_PROXY: '1'
FEUERWERK_MCP_PORT: '8090'
ports:
- 172.16.0.1:8091:8090
read_only: true
cap_drop: [ALL]
security_opt: ['no-new-privileges:true']
command: ['node', 'tools/mcp/serve.mjs']
cpus: 1
mem_limit: 256m
pids_limit: 64