paper-trader-mcp
The paper-trader-mcp server is a simulation-only MCP server for recording and evaluating US-equity day-order intents against historical Alpaca SIP NBBO quotes, without placing any live or broker orders.
Record trade intents (
paper_trade_record): idempotently log whole-share DAY market/limit orders (long/short) with configurable latency, backtest timestamps, and caller‑generated keys.Retrieve trade details (
paper_trade_get): view intents, estimated fills, itemized fees (commissions, SEC Section 31, FINRA TAF), raw selected quotes, and immutable evaluation snapshots – no market data call required.List trades (
paper_trade_list): browse all recorded trades, optionally filtered by state (pending_data,open,exit_pending,closed,expired,indeterminate), up to 200 rows.Evaluate trades (
paper_trade_evaluate): estimate fills for pending entries/exits or mark open positions using delayed historical SIP top‑of‑book quotes (enforces bid/ask crossing, displayed size, latency); fees are automatically calculated. Defaults tonow − 16 minutesif noas_ofis given. Requires Alpaca credentials for quote and calendar APIs.Close trades (
paper_trade_close): record a market DAY exit intent for an open trade; must be evaluated later (after the 16‑minute safety window) to estimate the fill.Backtesting: simulate past orders via
submitted_atwithbacktest=true; DAY eligibility is based on the Alpaca NY calendar (holidays, early closes).Local durable storage: SQLite database in
~/.local/share/paper-trader/with WAL, foreign keys, and idempotent retries.Configurable parameters: commission (per‑order / per‑share), order latency, quote lookback, maximum quote age, and slippage – set via environment variables or per‑order arguments.
No live trading: never connects to a broker or uses real‑time data; all outcomes are simulation‑only.
No credentials needed for recording, listing, or closing trades; credentials are required only for evaluation.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@paper-trader-mcp Record a market buy of 10 shares of AAPL"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Paper Trader MCP
A local, durable, simulation-only MCP server for recording US-equity order intents and later estimating outcomes from historical Alpaca SIP NBBO quotes. It never places live orders or Alpaca paper-broker orders. There is no order endpoint, broker SDK, generic fetch tool, trades endpoint, GTC, extended-hours, fractional-share, or partial-fill support.
Install and run
Requirements: Python 3.14, uv, and Alpaca data
credentials with historical SIP access.
./setup.sh
export APCA_API_KEY_ID='...'
export APCA_API_SECRET_KEY='...'
./run.shThe scripts are executable and run.sh uses only this project's .venv.
Credentials are read from the environment (the server does not load .env).
Recording, listing, and closing intents work without credentials; evaluation
requires them because it reads Alpaca's quote and calendar APIs.
The database defaults to
~/.local/share/paper-trader/paper-trader.sqlite3; set PAPER_TRADER_DB to
override it. See .env.example for bounded quote-policy and commission options.
Defaults you may want to configure
Setting | Default | Meaning |
Commission per order |
| Applied to every simulated fill |
Commission per share |
| Applied to every simulated fill |
Order latency |
| Override per order with |
Quote lookback |
| Search window for prevailing top-of-book quote |
Maximum quote age |
| Older quotes are unusable |
Additional slippage beyond spread |
| Buys still cross to ask; sells cross to bid |
Current sell-side SEC Section 31 and FINRA TAF fees are automatic and itemized. Set the commission variables only when modeling a broker that is not commission-free. Short borrow costs, margin interest, dividends, venue fees, rebates, and taxes are not configurable or modeled.
Related MCP server: quant-research-mcp
MCP configuration
Claude Code (~/.claude.json, within the desired project entry) or Desktop /
Cowork (claude_desktop_config.json) can use the same stdio configuration:
{
"mcpServers": {
"paper-trader": {
"command": "/absolute/path/to/paper-trader-mcp/run.sh",
"env": {
"APCA_API_KEY_ID": "YOUR_DATA_KEY",
"APCA_API_SECRET_KEY": "YOUR_DATA_SECRET"
}
}
}
}Prefer launching the client from a shell containing credentials rather than
writing secrets into configuration. The five tools are
paper_trade_record, paper_trade_get, paper_trade_list,
paper_trade_evaluate, and paper_trade_close. Mutation calls require a
caller-generated unique request_id; exact retries replay while changed input
conflicts. submitted_at is accepted only with backtest=true. Evaluation
without as_of explicitly selects now - 16 minutes.
Model and safety caveats
This is an intentionally conservative estimate, not an execution simulator.
It crosses one complete top-of-book quote (ask to buy, bid to sell), requires
the displayed size to cover the entire order, assumes zero additional
slippage, and declares resting limits or insufficient depth indeterminate.
There is no L2/depth. Quotes must be regular-session, fresh, complete,
non-crossed, SIP-feed records on or after 2025-11-03 (Alpaca changed quote-size
units then). Equal timestamps retain API ordering and raw nanosecond timestamps.
Temporary SIP embargoes use pending_data; model limitations that prevent a
defensible fill use the distinct terminal state indeterminate.
DAY eligibility uses Alpaca's New York calendar, including holidays and early closes. Data newer than the 15-minute entitlement plus a one-minute guard is never queried or clamped. Weekend, pre-open, and after-close marks use the most recent session. Multi-session results do not model splits, dividends, ticker changes, short borrow/availability and fees, dividends owed by shorts, halts/LULD, auctions, or quote corrections.
Accounting uses decimal text and cash-flow logic. Configured commissions apply per fill. Sell fees include FINRA's published 2025-2029 equity TAF schedule and the SEC Section 31 rate (zero through 2026-04-03; 0.00002060 thereafter in the verified 2026 period); dates outside explicit SEC ranges produce warnings. TAF is calculated at the published per-share rate without an invented penny minimum or per-fill rounding, capped per trade, and exempted when execution price is below the applicable per-share rate. Results expose commissions, SEC fees, and FINRA fees separately. Snapshots are immutable. SQLite uses WAL, foreign keys, busy timeout, explicit short transactions, and one connection per operation; network requests occur before write transactions.
The only HTTP destinations implemented are redirect-disabled GET requests to:
https://data.alpaca.markets/v2/stocks/quotes(alwaysfeed=sip, one symbol)https://paper-api.alpaca.markets/v2/calendar
Authoritative references: Alpaca historical stock quotes, historical stock data, and calendar API.
Tests
Core tests use only the standard library and fake providers, so MCP need not be installed:
PYTHONPATH=src python3 -m unittest discover -s tests -vNo test uses credentials or network access.
License
Copyright 2026 Emile Fortier.
Licensed under the Apache License 2.0.
Available Tools
5 toolspaper_trade_closeA
Durably record a simulation-only market DAY exit intent for an open trade; never sends a live or broker-paper order and does not close immediately. Evaluate later, after the 16-minute SIP safety window, to estimate fill.
Inputs: trade_id (required), request_id (required), backtest, latency_ms, +1 more. Returns: object
paper_trade_evaluateA
Evaluate a pending simulated entry/exit or mark an open position using delayed historical consolidated SIP top-of-book quotes; no order is sent. Buys use ask, sells use bid, latency and displayed size are enforced, and fees are itemized. A fill's execution time is its submitted_at plus latency (or session open); quote_as_of identifies the latest qualifying quote used at or before that instant. For entries, a separate position mark uses as_of. If as_of is omitted, it means now minus 16 minutes—not latest/live data. Read outcome_reason, state_after, next_action, and warnings; never infer a fill from an indeterminate outcome.
Inputs: trade_id (required), request_id (required), as_of. Returns: object
paper_trade_getA
Read one durable simulated trade with native structured intents, fills, itemized fees, raw selected quotes, and immutable evaluation snapshots. No market-data or broker call is made.
Inputs: trade_id (required). Returns: object
paper_trade_listA
List durable simulated trades, optionally filtered by state. No market-data or broker call is made.
Inputs: limit, state. Returns: object
paper_trade_recordA
Durably record a simulation-only whole-share US-equity DAY entry intent; never sends a live or broker-paper order. Without submitted_at, the server timestamps receipt. Historical submitted_at requires backtest=true. Regular hours only: pre-open DAY orders wait for the open; after-close or non-session DAY orders later expire.
Inputs: symbol (required), quantity (required), order_type (required), request_id (required), +6 more. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct lifecycle action: recording entry, recording exit, evaluating, reading one, and listing. The purposes are clearly separated by the verb (record, close, evaluate, get, list) and by the descriptive text, so an agent should not confuse them.
All tool names follow the same pattern: the resource prefix 'paper_trade' followed by a clear verb (_record, _get, _list, _evaluate, _close). This is a perfectly consistent verb_noun (or resource_verb) convention.
Five tools is well-scoped for a paper trading simulator. It covers the core operations without redundancy or bloat, fitting comfortably in the ideal 3-15 range.
The tool set covers a complete lifecycle: record entry intent, evaluate fills/marks, close exits, and query individual or all trades. No obvious gaps exist for simulation-only day trading; even potential missing operations like cancel are handled by day-order expiration.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Production MCP server for US equity and options intelligence: real-time IV radar, Monte Carlo simulation, options pressure, strategy backtesting, AI prediction, pre-trade risk analysis, and automated stock research reports.
Hosted MCP server for SEC, FRED, Polymarket, Deribit, OKX, and FMP.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceReview-only MCP server for stock, options, and crypto screening, trade planning, risk checks, backtesting, and journaling, designed to work alongside Robinhood's Trading MCP without placing orders.1-
- AlicenseAqualityCmaintenanceAn MCP server exposing a registry of paper-backed quantitative trading methods plus a deterministic, no-LLM decision helper for reproducible trading research.13MIT
- FlicenseNot gradedqualityDmaintenanceA Test/Sandbox MCP server that integrates with the SnapTrade API Sandbox environment to provide portfolio oversight, market data, and trading capabilities.-
- AlicenseCqualityBmaintenanceLocal paper-trading and market simulation MCP server for multi-account portfolios, advanced orders, options/futures, backtesting, alerts, and automation.60MIT