Deployment¶
Deployment Options¶
emerald-exchange exposes its MCP server (console script emerald-exchange-mcp) four ways. Pick the row that
matches where the server runs relative to your MCP client, then copy the matching
mcp_config.json below. Add the service-connection environment variables documented in the Configuration section.
Provider endpoint, credential, selector, identity, and trust material are supplied at
runtime through AgentConfig (~/.config/agent-utilities/config.json) or environment —
none of it is stored in this repository or belongs hardcoded in mcp_config.json.
| # | Option | Transport | Where it runs | mcp_config.json key |
|---|---|---|---|---|
| 1 | stdio | stdio |
client launches a subprocess | command |
| 2 | Streamable-HTTP (local) | streamable-http |
a local network port | command or url |
| 3 | Local container / uv | stdio or streamable-http |
Docker / Podman / uv on this host | command or url |
| 4 | Remote URL | streamable-http |
a remote host behind Caddy | url |
1. stdio (local subprocess)¶
The client launches the server over stdio via uvx — best for local IDEs
(Cursor, Claude Desktop, VS Code):
{
"mcpServers": {
"emerald-exchange-mcp": {
"command": "uvx",
"args": ["--from", "emerald-exchange", "emerald-exchange-mcp"],
"env": {"MCP_TOOL_MODE": "condensed"}
}
}
}
2. Streamable-HTTP (local process)¶
Run the server as a long-lived HTTP process:
uvx --from emerald-exchange emerald-exchange-mcp --transport streamable-http --host 0.0.0.0 --port 8000
curl -s http://localhost:8000/health # {"status":"OK"}
For a loopback-only development listener (no published port, nothing else on the host or network can reach it), bind
--host 127.0.0.1instead of0.0.0.0. Do not expose a0.0.0.0listener beyond a trusted network boundary: a real network deployment needs direct TLS or an explicitly trusted TLS-terminating ingress, configured authentication, an exactMCP_ALLOWED_HOSTS, and an exact trusted-proxy CIDR policy (see Behind a Caddy reverse proxy below).
Then either let the client launch it:
{
"mcpServers": {
"emerald-exchange-mcp": {
"command": "uvx",
"args": ["--from", "emerald-exchange", "emerald-exchange-mcp", "--transport", "streamable-http", "--port", "8000"],
"env": {
"TRANSPORT": "streamable-http",
"HOST": "0.0.0.0",
"PORT": "8000"
}
}
}
}
…or connect to the already-running process by URL:
3. Local container / uv¶
(a) Launch a container directly from mcp_config.json (stdio over the container —
no ports to manage). Swap docker for podman for a daemonless runtime:
{
"mcpServers": {
"emerald-exchange-mcp": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TRANSPORT=stdio",
"knucklessg1/emerald-exchange:2.1.0"
]
}
}
}
(a2) Least-privilege container run — the same launch, hardened for an
untrusted or shared host (read-only root filesystem, all capabilities dropped, no
privilege escalation, a bounded process count, and a noexec tmpfs for the one
writable path the process needs):
docker run -i --rm \
--read-only \
--cap-drop=ALL \
--security-opt=no-new-privileges \
--pids-limit=256 \
--tmpfs /tmp:rw,noexec,nosuid,nodev,size=64m \
-e TRANSPORT=stdio \
knucklessg1/emerald-exchange@sha256:<digest> emerald-exchange-mcp
Pin the immutable release digest (rather than the mutable floating tag) for this
form, and project the selected AgentConfig profile into the process at runtime —
the image itself carries no environment-specific connection profile.
(b) Run a local streamable-http container, then connect by URL:
docker run -d --name emerald-exchange-mcp -p 8000:8000 \
-e TRANSPORT=streamable-http \
-e PORT=8000 \
knucklessg1/emerald-exchange:2.1.0
# or, from a clone of this repo:
docker compose -f docker/mcp.compose.yml up -d
(c) From a local checkout with uv:
4. Remote URL (deployed behind Caddy)¶
When the server is deployed remotely (e.g. as a Docker service) and published through
Caddy at a deployment-selected HTTPS hostname, connect with the "url" key — no local process or
image required:
{
"mcpServers": {
"emerald-exchange-mcp": { "url": "https://emerald-exchange-mcp.example.invalid/mcp" }
}
}
Caddy reverse-proxies https://emerald-exchange-mcp.example.invalid to the container's :8000
streamable-http listener; https://emerald-exchange-mcp.example.invalid/health returns
{"status":"OK"} when the service is live. Keep the real remote URL, outbound
identity references, and TLS trust profile in AgentConfig
(~/.config/agent-utilities/config.json) rather than duplicating them across
mcp_config.json files or documentation.
This page covers running emerald-exchange as a long-lived service: the
transports, the companion A2A agent server, a Docker Compose stack, putting it
behind a Caddy reverse proxy, and giving it a DNS name with Technitium.
emerald-exchange ships two console scripts: the MCP server
(emerald-exchange-mcp) and a full A2A agent server
(emerald-exchange-agent) that drives the MCP toolset through a Pydantic-AI
agent. A text-mode cockpit (emerald-cockpit) is documented in
Usage.
Run the MCP server¶
The transport is selected with --transport (or the TRANSPORT env var):
Health check (HTTP transports):
Configuration (environment)¶
The MCP server starts with no required configuration — the default Paper backend is fully self-contained. Live trading and data connectors read their own credentials and remain inactive when those credentials are absent. The variables most commonly set:
| Var | Default | Meaning |
|---|---|---|
TRANSPORT |
stdio |
Transport: stdio, streamable-http, or sse |
HOST |
127.0.0.1 |
Bind address for HTTP transports |
PORT |
8100 |
Listen port for HTTP transports |
FUNDAMENTALSTOOL |
True |
Register the SEC EDGAR fundamentals tool group |
EDGAR_IDENTITY |
— | SEC identity ("Name email@example.com") for fundamentals |
WALLETINTELTOOL |
True |
Register the Polymarket wallet-intelligence tool group |
POLY_TRADES_PATH |
— | Path to a processed Polymarket trades CSV/Parquet |
ALPACA_API_KEY / ALPACA_SECRET_KEY |
— | Alpaca credentials (only when using Alpaca) |
BINANCE_API_KEY / BINANCE_SECRET |
— | Binance credentials (only when using Binance) |
COINBASE_API_KEY / COINBASE_SECRET |
— | Coinbase credentials (only when using Coinbase) |
All trading behavior — the default backend, default mode, risk limits, and
per-exchange settings — is configured in the trading block of
~/.config/agent-utilities/config.json. The full schema, the backend matrix, and
the complete environment-variable list are documented in the
Configuration schema. See also
Configuration, trust, and privacy for the runtime-only-secrets
policy this package follows.
Backing service¶
emerald-exchange connects to managed, SaaS exchange and data APIs — Alpaca,
Binance, Coinbase, Kraken (via CCXT), Kalshi, Polymarket, and SEC EDGAR. These are
provider-hosted services with no local deployment, so there is no backing-system
recipe to provision: only connection configuration (API keys and identities) is
required, and the package operates entirely against the in-process Paper backend
until those credentials are supplied.
Docker Compose¶
The repository ships docker/mcp.compose.yml.
It reads a sibling .env, publishes the HTTP MCP server on :8100, and starts the
companion agent server on :9100:
services:
emerald-exchange-mcp:
image: knucklessg1/emerald-exchange:2.1.0
container_name: emerald-exchange-mcp
hostname: emerald-exchange-mcp
command: ["emerald-exchange-mcp"]
restart: always
env_file:
- ../.env
environment:
- PYTHONUNBUFFERED=1
- HOST=0.0.0.0
- PORT=8100
- TRANSPORT=streamable-http
ports:
- "8100:8100"
healthcheck:
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8100/health')"]
interval: 30s
timeout: 10s
retries: 3
cp .env .env.local # then edit the connector credentials you use
docker compose -f docker/mcp.compose.yml up -d
docker compose -f docker/mcp.compose.yml logs -f
A2A agent server¶
The agent server (emerald-exchange-agent) launches emerald-exchange as a full
Pydantic-AI agent with Agent-to-Agent support, wired to the MCP toolset via
MCP_URL. It is defined alongside the MCP server in
docker/mcp.compose.yml
and listens on :9100:
emerald-exchange-agent:
image: knucklessg1/emerald-exchange:2.1.0
container_name: emerald-exchange-agent
hostname: emerald-exchange-agent
command: ["emerald-exchange-agent"]
depends_on:
- emerald-exchange-mcp
restart: always
env_file:
- ../.env
environment:
- PYTHONUNBUFFERED=1
- HOST=0.0.0.0
- PORT=9100
- MCP_URL=http://emerald-exchange-mcp:8100/mcp
- PROVIDER=openai
- LLM_BASE_URL=${LLM_BASE_URL:-http://host.docker.internal:1234/v1}
- LLM_API_KEY=${LLM_API_KEY:-llama}
- MODEL_ID=${MODEL_ID:-qwen/qwen3.5-9b}
- ENABLE_WEB_UI=True
ports:
- "9100:9100"
Run it directly:
Behind a Caddy reverse proxy¶
Expose the HTTP server on a hostname with automatic TLS. Add to your Caddyfile:
# Deployment-selected HTTPS hostname
emerald-exchange.example.invalid {
tls internal
reverse_proxy emerald-exchange-mcp:8100
}
# Public — automatic Let's Encrypt
emerald-exchange.example.com {
reverse_proxy emerald-exchange-mcp:8100
}
Reload Caddy:
DNS with Technitium¶
Point the hostname at the host running Caddy. Via the Technitium API:
curl -s "https://dns-admin.example.invalid/api/zones/records/add" \
--data-urlencode "token=$TECHNITIUM_DNS_TOKEN" \
--data-urlencode "domain=emerald-exchange.example.invalid" \
--data-urlencode "zone=arpa" \
--data-urlencode "type=A" \
--data-urlencode "ipAddress=10.0.0.10" \
--data-urlencode "ttl=3600"
…or add an A record emerald-exchange.example.invalid → <caddy-host-ip> in the Technitium
web console (https://dns-admin.example.invalid). The ecosystem
technitium-dns-mcp automates
this as a tool.
Register with an MCP client¶
Add to your client's mcp_config.json (multiplexer nickname ee):
{
"mcpServers": {
"emerald-exchange": {
"command": "uv",
"args": ["run", "emerald-exchange-mcp"],
"env": {}
}
}
}
For a remote HTTP server, point the client at https://emerald-exchange.example.invalid/mcp
instead.