Skip to main content
Glama
dearvn

tradebox-mcp

by dearvn

tradebox-mcp

AI 트레이딩 에이전트를 위한 플라이트 레코더 + 회로 차단기.

거래소들이 AI 에이전트의 거래를 허용하기 시작하면서도, 에이전트가 생각하는 것을 거래소가 볼 수 없다는 점을 인정하고 있습니다. tradebox는 여러분의 LLM(Claude, Cursor 또는 모든 MCP 호스트)과 각 브로커 MCP 서버 사이에 위치하는 로컬 프록시입니다. 모든 도구 호출과 에이전트의 추론을 기록하며, 한도를 위반하는 주문을 거래소에 도달하기 전에 차단합니다.

  • 에이전트 수정 불필요 — MCP 호스트가 브로커 서버 대신 tradebox를 바라보게 하면 됩니다. 에이전트는 완전히 동일한 도구를 보게 됩니다.

  • 로컬 우선 — API 키는 브로커 자식 프로세스로 직접 전달됩니다. tradebox는 이 키를 파싱, 기록 또는 전송하지 않으며, 자체적으로 네트워크 호출을 전혀 하지 않습니다.

  • 거부 ≠ 충돌 — 차단된 주문은 에이전트가 읽고 대응할 수 있는 명확한 언어의 도구 결과로 반환됩니다. 프로토콜 오류로 재시도 루프에 빠지는 일은 없습니다.


작동 방식

tradebox는 양쪽 모두 MCP로 통신합니다. 호스트에게는 서버이고, 생성한 각 브로커 서버에게는 클라이언트입니다.

flowchart LR
    subgraph HOST["Your machine"]
        A["MCP host<br/>(Claude Desktop / Cursor)"]
        subgraph TB["tradebox-mcp"]
            G["Guardrail engine<br/>(allow / deny)"]
            R["Recorder<br/>(JSONL blackbox)"]
        end
        C["CCXT MCP server<br/>(child process)"]
        L[("~/.tradebox/logs/<br/>YYYY-MM-DD.jsonl")]
    end
    X["Exchange<br/>(Binance, …)"]

    A -- "stdio (JSON-RPC / MCP)" --> G
    G -- "allowed calls only" --> C
    G -.-> R
    R -.-> L
    C -- "HTTPS (your API keys<br/>never leave this hop)" --> X

모든 tools/call은 동일한 파이프라인을 통과합니다.

sequenceDiagram
    participant Agent as Agent (LLM)
    participant TB as tradebox
    participant Broker as CCXT MCP
    participant Ex as Exchange

    Note over Agent,Ex: ✅ order within limits
    Agent->>TB: createOrder BTC/USDT, $150
    TB->>TB: classify → trade.place<br/>guardrails → ALLOW
    TB->>Broker: forward
    Broker->>Ex: place order
    Ex-->>Broker: filled
    Broker-->>TB: result
    TB->>TB: log call + result (JSONL)
    TB-->>Agent: result

    Note over Agent,Ex: ⛔ order over the limit
    Agent->>TB: createOrder DOGE/USDT, $520
    TB->>TB: classify → trade.place<br/>guardrails → DENY (allowed_symbols)
    TB->>TB: log the denial
    TB-->>Agent: "Order denied: DOGE/USDT is not<br/>in allowed_symbols (BTC/USDT, ETH/USDT)."
    Note over Agent: agent reads the reason<br/>and adjusts — no crash loop

규칙이 거부하면 주문은 브로커 프로세스에 절대 도달하지 않습니다 — 차단은 키가 계속되기 이전 단계에서 이루어집니다.


Related MCP server: SentinelGate

빠른 시작

1 — 설정 파일 생성 (키는 여러분의 컴퓨터에 남습니다. chmod 600으로 보호하세요):

mkdir -p ~/.tradebox
cp config.example.yaml ~/.tradebox/config.yaml
chmod 600 ~/.tradebox/config.yaml
# ~/.tradebox/config.yaml (minimal)
downstreams:
  ccxt:
    command: npx
    args: ["-y", "@lazydino/ccxt-mcp", "--config", "~/.tradebox/ccxt-accounts.json"]
    # ccxt-accounts.json holds your exchange keys (see config.example.yaml).
    # Use a read + trade key. NEVER enable withdrawals on it.

guardrails:
  allowed_symbols: ["BTC/USDT", "ETH/USDT"]
  max_order_notional: 200        # $ per single order
  max_orders_per_hour: 6
  max_daily_loss: 100            # trips the circuit breaker (UTC day)
  dry_run: true                  # ON by default — flip to false to go live

2 — MCP 호스트를 브로커 서버 대신 tradebox에 연결하세요 (claude_desktop_config.json 또는 .cursor/mcp.json):

{
  "mcpServers": {
    "trading": {
      "command": "npx",
      "args": ["-y", "tradebox-mcp", "run", "--config", "~/.tradebox/config.yaml"]
    }
  }
}

3 — (선택 사항이지만 권장) 에이전트 시스템 프롬프트에 한 줄을 추가하면 블랙박스가 행동뿐 아니라 추론까지 기록합니다:

모든 거래 결정 전에 log_reasoning 도구를 호출하여 하려는 일과 그 이유를 짧게 설명하세요.

이것으로 끝입니다. 에이전트는 평소처럼 ccxt__createOrder, ccxt__fetchTicker, …를 볼 수 있습니다. 에이전트 쪽에서는 달라지는 것이 없습니다.


가드레일

규칙

설정 키

동작

심볼 화이트리스트

allowed_symbols

목록에 없는 모든 주문 거부

주문 규모 상한

max_order_notional

상한을 초과하는 단일 주문 거부 (시장가 주문은 60초 이내의 티커 가격으로 평가되며, 그 전이면 "티커를 먼저 요청"으로 거부)

비율 제한

max_orders_per_time

오류 루프 차단기 — 버그가 있는 에이전트의 가장 흔한 실제 고장 모드(슬라이딩 1시간 창)

일일 손실 차단기

max_daily_loss

주요 회로 차단기 — 아래 다이어그램 참조

거래 시간

trading_hours

UTC 시간 창 내에 있는 주문만 허용

자금 전송

내장

기본적으로 거부됨. 트레이딩 애이전트가 자금을 출금할 일은 없습니다. 허용하려면 allow_transfers: true가 명시적으로 있어야 합니다.

알 수 없는 도구

unknown_tools

매핑에서 인식되지도 않고 변형시키는 것으로 보이는 도구는 읽기 전용으로 가정하지 않습니다. 대신 거부.

패닉 버튼

tradebox stop

에이전트가 실행 중이더라도 모든 거래 도구를 즉시 거부합니다.

회로 차단기의 수명 주기

stateDiagram-v2
    [*] --> Trading
    Trading --> Locked : realized daily PnL ≤ −max_daily_loss
    Trading --> Locked : operator runs "tradebox stop"
    Locked --> Trading : operator runs "tradebox resume"
    Locked --> Locked : every trade.* call → denied<br/>(reads still pass through)

    note right of Locked
        The lock survives restarts —
        state is a projection of the log,
        so a crash never resets the breaker.
    end note

Dry-run: 돈을 넣기 전에 에이전트를 테스트하세요

dry_run: true(기본값)는 모든 거래를 프록시에서 차단하고 실제처럼 기록하며 시뮬레이션된 체결을 반환합니다. tradebox는 가상의 주문 상태를 유지하여 시뮬레이션이 일관성이 있게 합니다. 시뮬레이션된 주문 ID를 취소하거나 가져오면 일관된 응답이 나오며 모든 시뮬레이션 결과값에는 "simulated": true가 붙습니다. 에이전트를 일주일간 dry-run으로 돌리고 리포트를 읽은 뒤 다음에 스위치를 켜세요.


블랙박스

허용되든 차단되든 모든 호출은 ~/.tradebox/logs/YYYY-MM-DD.jsonl에 한 줄에 하나의 JSON 이벤트로 추가됩니다.

{"ts":"2026-08-25T12:00:00.123Z","event":"tool_call","server":"ccxt","tool":"createOrder","category":"trade.place","args":{"symbol":"BTC/USDT","side":"buy","type":"limit","amount":0.02,"price":58900},"decision":"allow","latency_ms":840,"result":{"order_id":"123","filled":0.02,"avg_price":58895}}
{"ts":"2026-08-25T12:05:01.000Z","event":"tool_call","server":"ccxt","tool":"createOrder","category":"trade.place","args":{"symbol":"DOGE/USDT","side":"buy","amount":50000},"decision":"deny","rule":"allowed_symbols","latency_ms":2}
{"ts":"2026-08-25T12:05:04.500Z","event":"reasoning","text":"DOGE blocked. Holding BTC, waiting for the 58K retest."}
{"ts":"2026-08-25T13:00:00.000Z","event":"guardrail_trip","rule":"max_daily_loss","value":-102.5,"limit":-100,"action":"trading_locked"}

비밀 정보는 로그에 들어가지 않습니다. 다운스트림 env 블록은 리코더가 볼 수 없으며 key|secret|token|password와 같은 이름의 필드는 전부 마스킹 처리됩니다.

Drift 리포트 — 에이전트가 아직 테스트했던 에이전트인가요?

$ tradebox report --window 7d

AGENT BEHAVIOR REPORT              2026-08-18 → 2026-08-25
──────────────────────────────────────────────────────────
                      baseline (7d)    last 24h        Δ
orders/day                  4.2            11        ×2.6  ⚠
avg order notional        $145           $410        ×2.8  ⚠
symbols traded        BTC 82% · ETH 18%  +SOL 37%          ⚠ new symbol
avg hold time             3.1 h          22 min      ÷8.5  ⚠
denied calls                 0             7    max_order_notional ×5
realized PnL              +$83           −$61
──────────────────────────────────────────────────────────
⚠ BEHAVIORAL DRIFT: the agent is behaving differently than
  it did 7 days ago. Model update? Prompt change? Check
  before it costs you.

오프라인에서 로컬 JSONL만 읽으며 네트워크를 사용하지 않습니다.


CLI

tradebox run --config <path>    start the proxy (spawned by your MCP host)
tradebox report [--window 7d]   behavior + drift report from local logs
tradebox stop                   PANIC — deny all trading immediately
tradebox resume                 clear the panic / daily-loss lock

솔직한 한계 (v0.1)

실제 돈으로 발견되기보다는 미리 알려드리는 것이 낫다고 생각합니다:

  1. stdio 다운스트림만 지원 (CCXT MCP 및 그에 해당하는 서버). HTTP 전송 지원(Binance Agent OS / Robinhood MCP)이 최우선 로드맵 항목입니다.

  2. 일일 손실 차단기는 프록시로 들어온 체결만 볼 수 있습니다. 체결 결과는 주문 결과와 에이전트의 fetch_my_trades / fetch_closed_orders 호출에서 파싱됩니다. 체결을 조회하지 않는 에이전트는 차단기가 보지 못하게 됩니다.

  3. 포지션 추적은 추정치입니다 — 프록시를 지나가는 주문 만으로 구성되며 거래소 잔액과의 대사가 아직 없습니다.

  4. Dry-run 체결은 즉시 시뮬레이션됩니다. 실제 잔액/포지션 조회는 그대로 통과하며 시뮬레이션 거래를 반영하지 않습니다(모든 시뮬레이션 결과에는 "simulated": true가 포함됩니다).

  5. 모든 일간 경계는 UTC입니다. 한 번에 하나의 프록시 인스턴스만 실행합니다.


규칙 기여

파일 하나, 인터페이스 하나 — PR은 언제나 환영합니다:

export interface GuardrailRule {
  name: string;
  // return null to pass; return a string to deny (the reason is sent to the LLM)
  check(call: ClassifiedToolCall, state: SessionState, cfg: Config): string | null;
}

src/guardrails/rules/ 안에 넣고 engine.ts에 등록한 뒤 테스트를 추가하면 됩니다. 아키텍처 결정과 그 이유는 docs/DESIGN.md를 참고하세요.

로드맵

  1. HTTP 전송 프록시 → Binance Agent OS, Robinhood MCP

  2. 거래소 잔액으로 부터 대사하는 포지션 한도

  3. 호스팅 대시보드 + 실시간 알림 — 로컬 프록시와 리포트는 계속 무료이며 MIT 라이선스가 유지됩니다

License

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A transparent proxy and execution firewall that intercepts and audits AI agent tool calls against configurable security policies before forwarding them to downstream MCP servers. It provides safe execution environments with features like data redaction, anti-loop protection, and unified alert dispatching.
  • A
    license
    Not graded
    quality
    A
    maintenance
    Open-source MCP proxy that enforces security policies, content scanning, and audit logging between AI agents and tool servers
    25
    AGPL 3.0
  • A
    license
    Not graded
    quality
    A
    maintenance
    Security gateway for MCP tool calls. Sits between your LLM client and MCP servers, enforcing per-tool policies (allow/block/approve/read-only), logging every call, and pausing dangerous operations for human approval in terminal or Slack.
    2
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Enables AI agents to operate a local financial terminal, including market data, backtesting, paper portfolio management, and news digest, through safe, gated tools over MCP.
    6
    MIT

View all related MCP servers

Related MCP Connectors

  • Security firewall for AI agents — scans MCP calls for injection, secrets, and risks.

  • MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dearvn/tradebox-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server