Skip to main content

Emerald Exchange - API | MCP | A2A

PyPI - Version MCP Server

Version: 2.3.0

Documentation — Installation, deployment, usage across the API, CLI, and MCP interfaces, the A2A agent server, and the trading configuration schema are maintained in the official documentation.

Overview

Emerald Exchange is a unified Finance MCP Server providing fully abstracted exchange backends for equities, crypto, and derivatives trading. All trading feature is tool-driven via MCP, with built-in financial hardening controls (OS-5.1).

Key Features:

  • 5 Exchange Backends: Paper (default), Alpaca (FREE), CCXT (100+ exchanges), Freqtrade
  • 6 MCP Tool Domains: market-data, orders, portfolio, risk, signals, strategy
  • Financial Hardening: Paper-first default, Kelly criterion position sizing, circuit breakers, kill switch
  • Config-Driven: All settings via ~/.config/agent-connectors/config.json

Architecture

flowchart TB
    A["Agent / IDE"] --> B["emerald-exchange MCP"]
    B --> C["Risk Guard (OS-5.1)"]
    C --> D{"Exchange Router"}
    D --> E["Paper Backend (Default)"]
    D --> F["Alpaca Backend (FREE)"]
    D --> G["CCXT Backend (Binance/Coinbase/Kraken)"]
    D --> H["Freqtrade Backend"]

    style B fill:#10B981,stroke:#065F46,color:#fff
    style C fill:#EF4444,stroke:#991B1B,color:#fff
    style E fill:#6366F1,stroke:#4338CA,color:#fff

MCP Tools

Auto-generated from the live MCP server — do not edit by hand.

Condensed action-routed tools (MCP_TOOL_MODE=condensed)

MCP Tool Toggle Env Var Description
ee_prediction_markets PREDICTION_MARKETTOOL Prediction Markets operations.
emerald_crypto CRYPTOTOOL Crypto-native analytics and arbitrage. CONCEPT:EX-AHE.harness.ee-14
emerald_debate DEBATETOOL Multi-agent trading debate engine. CONCEPT:EX-AHE.harness.ee-13
emerald_derivatives DERIVATIVESTOOL SABR volatility surface + vol-arb. CONCEPT:AU-AHE.assimilation.decision-distillation
emerald_fundamentals FUNDAMENTALSTOOL SEC EDGAR fundamentals operations. CONCEPT:EX-AHE.harness.ee-26.
emerald_ingest_snapshot KG_INGESTTOOL Ingest a live trading snapshot into epistemic-graph as typed nodes.
emerald_market_data MARKET_DATATOOL Market data operations. CONCEPT:EX-AHE.harness.ee-7
emerald_market_making MARKET_MAKINGTOOL Market-making controller, fee model, and forensic screener. CONCEPT:EX-AHE.harness.ee-22
emerald_orders ORDERTOOL Order management with pre-trade risk validation. CONCEPT:EX-AHE.harness.ee-8
emerald_portfolio PORTFOLIOTOOL Portfolio management operations. CONCEPT:EX-AHE.harness.ee-9
emerald_risk RISKTOOL Risk management and monitoring. CONCEPT:AU-AHE.assimilation.skill-workflow-ingest
emerald_signals SIGNALTOOL Signal generation and fusion. Routes to agent-connector-sdk finance domain. CONCEPT:EX-AHE.harness.ee-11
emerald_statarb STATARBTOOL OU statistical-arbitrage signal + dynamic-beta hedge. CONCEPT:EX-AHE.harness.ee-29
emerald_strategy STRATEGYTOOL Strategy lifecycle management. CONCEPT:AU-AHE.assimilation.trading-ecosystem-spec
emerald_wallet_intel WALLET_INTELTOOL Polymarket wallet-intelligence operations. CONCEPT:EX-AHE.harness.ee-27.

Verbose 1:1 API-mapped tools (MCP_TOOL_MODE=verbose or both)

9 per-operation tools — one per public API method (click to expand)
MCP Tool Toggle Env Var Description
emerald_cancel_order PAPER_BACKENDTOOL Invoke the cancel_order operation.
emerald_connect PAPER_BACKENDTOOL Invoke the connect operation.
emerald_disconnect PAPER_BACKENDTOOL Invoke the disconnect operation.
emerald_get_account PAPER_BACKENDTOOL Invoke the get_account operation.
emerald_get_historical PAPER_BACKENDTOOL Invoke the get_historical operation.
emerald_get_order_status PAPER_BACKENDTOOL Invoke the get_order_status operation.
emerald_get_positions PAPER_BACKENDTOOL Invoke the get_positions operation.
emerald_get_quote PAPER_BACKENDTOOL Invoke the get_quote operation.
emerald_submit_order PAPER_BACKENDTOOL Invoke the submit_order operation.

15 action-routed tool(s) · 9 verbose 1:1 tool(s). Each is enabled unless its <DOMAIN>TOOL toggle is set false; MCP_TOOL_MODE selects the surface (intent default — the six verb-tools, granular set loaded on demand · condensed action-routed · verbose 1:1 · both). Auto-generated — do not edit.

Exchange Backends

Backend Assets Paper Live Free
Paper All ✅ — ✅
Alpaca Equities, Crypto ✅ ✅ ✅
CCXT (Binance) Crypto ✅ ✅ ✅
CCXT (Coinbase) Crypto ✅ ✅ ✅
CCXT (Kraken) Crypto ✅ ✅ ✅
Freqtrade Crypto ✅ ✅ ✅
Prediction Markets (Kalshi/Polymarket) Events/Weather ✅ ✅ ✅

Financial Hardening (OS-5.1)

Control Default
Trading Mode Paper (must explicitly opt into live)
Max Position Size 2% of portfolio (Kelly criterion)
Max Portfolio Drawdown 10% auto-halt
Max Daily Loss 3% auto-halt
Regime Shift Detection KS-test auto-halt
Human Approval for Live Required
Kill Switch emerald_orders(action="halt")

Usage

MCP Configuration

Install the slim [mcp] extra. The examples below install emerald-exchange[mcp] — the MCP-server extra that pulls only the FastMCP / FastAPI tooling (agent-connector-sdk). It deliberately excludes the heavy agent-orchestration runtime (pydantic-ai, dspy, llama-index, tree-sitter and the agent frontends), so uvx/container installs stay smaller and faster — note the mandatory epistemic-graph[full] engine is still present either way, since it is a base dependency of agent-connector-sdk itself, not gated behind an extra. Use the full [agent] extra only when the operator need the integrated Pydantic AI agent (see Installation). Add trading-backend extras ([alpaca], [crypto], [prediction_markets], …) on top as needed.

stdio Mode

{
  "mcpServers": {
    "emerald-exchange": {
      "command": "uvx",
      "args": ["--from", "emerald-exchange[mcp]", "emerald-exchange-mcp"],
      "env": {}
    }
  }
}

Streamable HTTP Mode

emerald-exchange-mcp --transport streamable-http --port 8100

Configuration

All trading settings are configured via ~/.config/agent-connectors/config.json:

{
  "trading": {
    "default_mode": "paper",
    "default_exchange": "alpaca",
    "exchanges": {
      "alpaca": {
        "enabled": true,
        "api_key_env": "ALPACA_API_KEY",
        "api_secret_env": "ALPACA_SECRET_KEY",
        "base_url": "https://paper-api.alpaca.markets"
      }
    },
    "risk_limits": {
      "max_position_pct": 0.02,
      "max_portfolio_drawdown_pct": 0.10,
      "max_daily_loss_pct": 0.03,
      "require_human_approval_live": true
    }
  }
}

Additional Deployment Options

emerald-exchange can run as a local stdio process or container, or behind a remote network boundary. The Deployment guide carries the detailed transport contract.

  • Local container — launch a reviewed immutable image as a least-privilege stdio child with no listener or published port.
  • Remote URL — connect through an operator-supplied authenticated HTTPS ingress. Keep its URL, outbound identity references, trust profile, and exact MCP_ALLOWED_HOSTS in AgentConfig.

⚙️ Dynamic Tool Selection & Visibility

This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows the operator to restrict the set of exposed tools to prevent blowing up the LLM's context window.

The operator can configure tool filtering via multiple input channels:

  • CLI Arguments: Pass --tools or --toolsets (or their disabled counterparts --disabled-tools and --disabled-toolsets) during startup.
  • Environment Variables: Define standard environment variables:
    • MCP_ENABLED_TOOLS / MCP_DISABLED_TOOLS
    • MCP_ENABLED_TAGS / MCP_DISABLED_TAGS
  • HTTP SSE Request Headers: Pass custom headers during transport initialization:
    • x-mcp-enabled-tools / x-mcp-disabled-tools
    • x-mcp-enabled-tags / x-mcp-disabled-tags
  • HTTP SSE Request Query Parameters: Append query parameters directly to the operator's transport connection URL:
    • ?tools=tool1,tool2
    • ?tags=tag1

When query strings or parameters are provided, an LLM-free Knowledge Graph resolution layer (using DynamicToolOrchestrator) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.


Installation

Pick the extra that matches what the operator want to run, then layer trading-backend extras on top:

Extra Installs Use when
emerald-exchange[mcp] Slim MCP server (agent-connector-sdk — FastMCP/FastAPI; still carries the mandatory epistemic-graph[full] base engine) + paper backend The operator only run the MCP server (smallest install / image)
emerald-exchange[agent] Full agent runtime (agent-connector-sdk — Pydantic AI/DSPy orchestration + epistemic-graph[full]) The operator run the integrated agent
emerald-exchange[all] Everything (mcp + agent + every trading backend) Development / full surface
pip install "emerald-exchange[mcp]"                # MCP server only (slim deps)
pip install "emerald-exchange[agent]"              # Full agent runtime (Pydantic AI + engine)
pip install "emerald-exchange[mcp,alpaca]"         # + Alpaca equities
pip install "emerald-exchange[mcp,crypto]"         # + CCXT crypto
pip install "emerald-exchange[mcp,prediction_markets]"  # + Kalshi & Polymarket
pip install "emerald-exchange[all]"                # Everything

Docker

Container images (:mcp vs :agent)

One multi-stage docker/Dockerfile builds two right-sized images, selected by --target:

Image tag Build target Contents Entrypoint
knucklessg1/emerald-exchange:mcp --target mcp emerald-exchange[mcp] — slim: no pydantic-ai/dspy/llama-index/tree-sitter agent-orchestration stack (the mandatory epistemic-graph[full] engine is still present — it's a base dependency of agent-connector-sdk) emerald-exchange-mcp
knucklessg1/emerald-exchange:2.3.0 --target agent (default) emerald-exchange[agent] — full agent runtime (agent-connector-sdk) + epistemic-graph[full] emerald-exchange-agent
docker build --target mcp   -t knucklessg1/emerald-exchange:mcp    docker/   # slim MCP server
docker build --target agent -t knucklessg1/emerald-exchange:2.3.0 docker/   # full agent
docker compose -f docker/mcp.compose.yml up -d                               # run the slim :mcp server
docker compose -f docker/compose.yml up -d                                   # full stack

Knowledge-graph database (epistemic-graph)

Both [mcp] and [agent] carry the epistemic-graph engine through the required Agent Connector SDK core dependency (epistemic-graph[full]) — it is a mandatory base dependency of agent-connector-sdk, not gated behind an extra. The [mcp] extra keeps the server slim/connector-focused (no agent-orchestration stack); [agent] also enables Pydantic AI/DSPy model orchestration. Local deployments can use the bundled engine. For production — or to share one knowledge graph across multiple agents — run epistemic-graph as its own dedicated database service and point the runtime at it instead of embedding it. Deployment recipes (single-node + Raft HA), connection configuration, and the full database architecture (with diagrams) are documented in the epistemic-graph deployment guide.

Documentation

The complete documentation is published as the official documentation site and is the recommended reference for installation, deployment, and day-to-day operation.

Page Contents
Installation pip, source, extras, prebuilt Docker image
Deployment run the MCP and agent servers, Compose, Caddy + Technitium, env config
Usage the MCP tools, the Python API, the cockpit CLI
Overview enterprise features, tool surface, architecture
Configuration Schema the trading config block and backend matrix
Concepts concept registry (CONCEPT:EE-*)

AGENTS.md is the canonical contributor/agent guidance.

Deploy with agent-os-genesis

This package can be provisioned for you — skill-guided — by the agent-os-genesis universal skill (its single-package deploy mode): it picks your install method, seeds secrets to OpenBao/Vault (or .env), trusts your enterprise CA, registers the MCP server, and verifies it — the same machinery that stands up the whole Agent OS, narrowed to just this package. Ask your agent to "deploy emerald-exchange with agent-os-genesis".

Install mode Command
Bare-metal, prod (PyPI) uvx emerald-exchange-mcp · or uv tool install emerald-exchange
Bare-metal, dev (editable) uv pip install -e ".[all]" · or pip install -e ".[all]"
Container, prod deploy knucklessg1/emerald-exchange:2.3.0 via docker-compose / swarm / podman / podman-compose / kubernetes
Container, dev (editable) deploy docker/compose.dev.yml (source-mounted at /src; edits live on restart)

Secrets are read-existing + seeded via vault_sync — you are only prompted for what's missing.

Single-package self-setup: deployment

For a tiny/single-node-prod profile scoped to just this package (no whole-homelab genesis), the deployment skill runs the equivalent install-mode/secrets/doctor/registration/observability/rollback sequence. Ask the operator's agent to "deploy emerald-exchange with deployment".

Install mode Command
Installed package uv tool install "emerald-exchange[mcp]", then run emerald-exchange-mcp
Editable source uv pip install -e ".[agent]", then run emerald-exchange-mcp
Immutable container deploy knucklessg1/emerald-exchange:2.3.0 through the operator-selected orchestrator

Either path: the repository embeds no deployment profile, credential value, certificate path, or environment-specific endpoint. Runtime secrets, TLS trust material, and endpoints come from AgentConfig / the configured secret provider (OpenBao or .env), never from a committed file.

Environment Variables

Package environment variables

Variable Example Description
BINANCE_API_KEY secret-injected Per-exchange credentials are resolved at runtime from the trading config's *_env keys; only the agent-connector-sdk-inherited Binance pair is read statically. Other exchanges (Alpaca, Coinbase, ...) supply credentials via operator config.
BINANCE_SECRET_KEY secret-injected
CRYPTOTOOL True crypto market tools
DEBATETOOL True multi-agent debate tools
DERIVATIVESTOOL True options/futures derivatives tools
FUNDAMENTALSTOOL True SEC/EDGAR fundamentals tools
MARKET_DATATOOL True market-data tools
MARKET_MAKINGTOOL True market-making tools
ORDERTOOL True order placement/management tools
PORTFOLIOTOOL True portfolio tools
PREDICTION_MARKETTOOL True prediction-market tools
RISKTOOL True risk tools
SIGNALTOOL True signal tools
STATARBTOOL True statistical-arbitrage tools
STRATEGYTOOL True strategy tools
WALLET_INTELTOOL True Polymarket wallet-intelligence tools
KG_INGESTTOOL True knowledge-graph ingest tools
EDGAR_IDENTITY Your Name your.email@example.com SEC EDGAR identity ("Name email")
EDGAR_USER_AGENT Your Name your.email@example.com legacy fallback for EDGAR_IDENTITY
POLY_TRADES_PATH /path/to/poly_trades.parquet Polymarket trade dataset for wallet-intel
EMERALD_STAGE_APPROVAL_TOKEN secret-injected human approval token to promote execution stage
EPISTEMIC_GRAPH_SOCKET /run/epistemic-graph.sock UDS path to the epistemic-graph engine
GRAPH_SERVICE_SOCKET /run/epistemic-graph.sock alternate UDS path env var
EPISTEMIC_GRAPH_TCP 127.0.0.1:50051 host:port for a TCP engine endpoint

Inherited agent-connector-sdk variables (apply to every connector)

Variable Example Description
TRANSPORT stdio MCP transport: stdio | streamable-http | sse
HOST 127.0.0.1 Loopback bind host (set an authenticated ingress explicitly)
PORT 8000 Bind port (HTTP transports)
MCP_TOOL_MODE intent Tool surface: intent | condensed | verbose | both
MCP_ENABLED_TOOLS — Comma-separated tool allow-list
MCP_DISABLED_TOOLS — Comma-separated tool deny-list
MCP_ENABLED_TAGS — Comma-separated tag allow-list
MCP_DISABLED_TAGS — Comma-separated tag deny-list
EUNOMIA_TYPE none Authorization mode: none | embedded | remote
EUNOMIA_POLICY_FILE mcp_policies.json Embedded Eunomia policy file
EUNOMIA_REMOTE_URL — Remote Eunomia authorization server URL
ENABLE_OTEL False Enable OpenTelemetry export
OTEL_EXPORTER_OTLP_ENDPOINT — OTLP collector endpoint
MCP_CLIENT_AUTH — Outbound MCP child auth: oidc-client-credentials | basic | none
OIDC_CLIENT_ID — OIDC client id (service-account auth)
OIDC_CLIENT_SECRET_REF secret://identity/oidc-client-secret Runtime secret reference for the OIDC service account
MCP_BASIC_AUTH_USERNAME — HTTP Basic username (MCP_CLIENT_AUTH=basic)
MCP_BASIC_AUTH_PASSWORD_REF secret://identity/mcp-basic-password Runtime secret reference for HTTP Basic auth (MCP_CLIENT_AUTH=basic)
DEBUG False Verbose logging
PYTHONUNBUFFERED 1 Unbuffered stdout (recommended in containers)
MCP_URL http://localhost:8000/mcp URL of the MCP server the agent connects to
PROVIDER — Operator-configured LLM provider for the agent
MODEL_ID — Operator-configured model id for the agent
ENABLE_WEB_UI True Serve the AG-UI web interface

24 package + 24 inherited variable(s). Auto-generated from .env.example + the shared agent-connector-sdk set — do not edit.

Governed capability contract

This package ships a compact canonical skill surface with specialist procedures kept as referenced workflows. The current MCP tools, skill metadata, connector_manifest.yml, ontology, mappings, shapes, fixtures, migrations, tool-schema fingerprints, and certification metadata form one versioned capability contract. Validate them together; do not rely on stale tool names or historical per-task skill wrappers.

Runtime endpoints, credentials, certificate trust, tenant identity, retention, and observability policy are deployment inputs and are never packaged values. See Configuration, trust, and privacy before enabling a network transport, connector ingestion, Arbora delegation, or trace export.

Metadata

Release files for emerald-exchange 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for emerald-exchange 2.3.0
File Interpreter ABI Platform
emerald_exchange-2.3.0-py3-none-any.whl Python 3 none any Details

Release files / emerald_exchange-2.3.0-py3-none-any.whl

Download URL emerald_exchange-2.3.0-py3-none-any.whl
Size 160.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3c99f31fee1c381f145197fd860682b2d7a00558207e8368df8495d22af91f1
BLAKE2b-256 checksum
How to use checksums
91348fd2fe07c6656d85990fb1ae550963fe3ab8242b336f14dfd793f0f96dbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

2.3.2

2 release files

2.3.1

2 release files

This release

2.3.0 This release

1 release file

2.2.1

1 release file

2.2.0

1 release file

1.0.1

2 release files

0.18.0

2 release files

0.16.1

2 release files

0.16.0

2 release files

0.10.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page