Docker & deployment¶
Docker¶
The repository includes a Dockerfile. The image:
- is based on
python:3.12-slimand includes Node.js, sonpxservers work; - runs as a non-root user;
- downloads Pyodide when the image is built, so containers start offline.
docker build -t codemode-mcp .
export CODEMODE_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
docker run -p 127.0.0.1:8000:8000 \
-v "$PWD/mcp.json:/config/mcp.json:ro" \
-v codemode-data:/home/codemode/.codemode-mcp \
-e CODEMODE_TOKEN -e GITHUB_TOKEN \
codemode-mcp
The container listens on all of its interfaces, so it needs an access token and will not
start without CODEMODE_TOKEN. Clients send it as Authorization: Bearer <token>.
-p 127.0.0.1:8000:8000 keeps the port on your own machine; drop the 127.0.0.1: only if
other machines should reach it.
- MCP endpoint:
http://localhost:8000/mcp - Dashboard:
http://localhost:8000/dashboard/ - Build with
--build-arg WITH_NODE=0for a smaller image if you don't use npm-based servers. - The
codemode-datavolume keeps usage statistics and OAuth tokens across restarts.
The default command is
serve --config /config/mcp.json --transport http --host 0.0.0.0 --port 8000. Override
it to run any other CLI command:
Running as a shared HTTP service¶
On any host other than 127.0.0.1 or localhost this command refuses to start until you
set an access token:
export CODEMODE_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
codemode-mcp serve -c mcp.json --transport http --host 0.0.0.0 --port 8000
Every request must then carry Authorization: Bearer <token>. In a client config that is
usually a headers entry:
{"mcpServers": {"codemode": {"url": "https://tools.example.com/mcp",
"headers": {"Authorization": "Bearer YOUR_TOKEN"}}}}
The dashboard at /dashboard/ asks your browser for a user name and password: leave the
name as anything and paste the token as the password. Use --token-env NAME to read the
token from a different environment variable.
One token is one tenant
The token is a shared secret, not user accounts. Everyone who has it can use every
configured tool with your upstream credentials. It travels in a header, so put TLS in
front (a reverse proxy) on any network you do not control. For several users with
different rights, run one instance per user or use a gateway that authenticates them.
DNS-rebinding protection is enabled automatically when the host is 127.0.0.1 or
localhost.
Other things to know when several people share one instance:
- One sandbox process serves all clients, and runs execute one at a time.
- With
persistent_state, all clients share the same variables.serveprints a note about this at startup. - Usage statistics are combined in one database.
systemd (Linux)¶
[Unit]
Description=codemode-mcp
After=network-online.target
[Service]
User=codemode
EnvironmentFile=/etc/codemode-mcp.env
# put CODEMODE_TOKEN=... in the EnvironmentFile if --host is not 127.0.0.1
ExecStart=/opt/codemode/venv/bin/codemode-mcp serve -c /etc/codemode-mcp/mcp.json --transport http --port 8000
Restart=on-failure
[Install]
WantedBy=multi-user.target