Rustyschwab
FreeNot checkedUnofficial Rust SDK, Python package and MCP server for the Charles Schwab Trader API: orders sent at most once, risk limits outside the strategy, a deterministi
About
Unofficial Rust SDK, Python package and MCP server for the Charles Schwab Trader API: orders sent at most once, risk limits outside the strategy, a deterministic paper venue, and policy-gated tools for LLM agents.
README
An unofficial Rust SDK, Python package and MCP server for the Charles Schwab Trader and Market Data APIs, built for automated strategies and LLM agents that place real orders.
[!WARNING] Automated trading can lose money. This software is provided as is, without warranty. Start with the paper venue, which runs locally and does not connect to thinkorswim paperMoney. Not affiliated with or endorsed by Charles Schwab & Co., Inc.
Status: 0.3.0. The Rust crates are on crates.io; the Python package is not on PyPI yet, so build it from this repository. One maintainer. Everything is tested against recorded Schwab responses and local fakes, but no live-account run has been recorded yet, so treat live trading as unproven. See what is core, what is experimental, and what has run live.
What is in it
| Part | For | Docs |
|---|---|---|
| rustyschwab | Rust applications: OAuth, REST, the streamer, the order journal, risk limits, paper venue, history cache, performance analytics | crate guide |
| rustyschwab (Python) | The same SDK from asyncio or blocking Python, order templates, one strategy for backtest, paper and live, a NautilusTrader adapter | Python guide |
| rustyschwab-mcp | LLM agents: an MCP server with 40 tools over the SDK, behind per-principal policy, approvals and a paper mode, plus operator and gateway commands | MCP guide |
| rustyschwab-dash | You, watching the agents: a terminal dashboard of every tool call and the model's reasons, with approvals, delegation, halt and kill (on rustyschwab-console, for other frontends) | Dashboard guide |
What it does differently
The hard part of broker automation is what happens when something goes wrong. rustyschwab is built around that:
- An order is sent at most once. Every submission is journaled before it leaves the process. A timeout or dropped connection becomes
SubmissionUnknown, never a retry, and the account's next submission waits until the journal reconciles the order against Schwab. - Limits hold outside the strategy. Risk limits, a daily-loss halt, an operator halt and a dead-man switch that cancels a silent agent's orders are enforced by the SDK and the server, not by the code placing the orders.
- Agents get a narrow, checked surface. MCP write tools are off by default. Each principal is held to its accounts, tools, symbols, price collar and daily budget; orders can require operator or user approval;
check_orderexplains every local reason an order would fail before anything reaches Schwab; and every write is recorded, with the model's stated rationale, in a hash-chained audit journal. - Simulation uses the same code path. The paper venue is deterministic and durable (SQLite), with finite liquidity, latency, fees and settlement in exact decimals. A Python strategy runs unchanged as a backtest, against the paper venue on live data, or live.
- Credentials stay out of reach. Tokens live in the OS keychain or an encrypted file, are zeroized in memory, and never appear in logs, errors or reprs.
Quickstart
Register an app at developer.schwab.com with callback URL https://127.0.0.1:8080, then:
git clone https://github.com/epistates/rustyschwab && cd rustyschwab
cp .env.example .env # set SCHWAB_APP_KEY, SCHWAB_APP_SECRET
cargo run -p oauth-flow # sign in once; tokens are stored securely
The setup guide covers each step, the token stores, and a one-time mkcert setup that removes the browser's certificate warning from sign-in.
Rust
[dependencies]
rustyschwab = "0.3"
tokio = { version = "1", features = ["full"] }
use rustyschwab::prelude::*;
let client = SchwabClient::new(SchwabConfig::from_env()?)?;
client.init().await?;
let quotes = client.get_quotes(&["AAPL", "MSFT"]).await?;
Placing orders, brackets and options: ORDERS.md. Streaming: STREAMING.md.
Python
pip install ./crates/schwab-py # from the clone; builds the extension, needs a Rust toolchain
import asyncio
from rustyschwab import Client, orders
from rustyschwab.trader import Trader
def strategy(tc, events):
for event in events:
if event["type"] == "candle" and not tc.positions.get(event["symbol"]):
tc.order(orders.equity_buy_market(event["symbol"], 1))
async def main():
run = await Trader(Client.from_env()).backtest(strategy, ["AAPL"], days=5, cash=10_000)
print(run.report())
asyncio.run(main())
trader.paper(...) and trader.live(...) run the same function. PYTHON.md has the rest; coming from Schwabdev maps every Schwabdev call to its equivalent.
MCP
cargo install rustyschwab-mcp # installs the server and its operator tools
claude mcp add schwab -e SCHWAB_APP_KEY=… -e SCHWAB_APP_SECRET=… \
-e SCHWAB_TOKENS_FILE="$PWD/schwab_tokens.json" \
-- "$(command -v rustyschwab-mcp)"
Order tools stay off until you enable them. To let an agent trade without real money, run the server over the paper venue:
SCHWAB_MCP_PAPER_CONFIG=ops/paper/config.json SCHWAB_MCP_PAPER_STATE=state/paper.sqlite3 \
SCHWAB_MCP_ALLOW_TRADING=1 rustyschwab-mcp
To follow the agent while it works, run rustyschwab-dash in another terminal with the same settings: every tool call and the model's reasons, orders waiting for your approval, and keys to approve, delegate, halt or kill (dashboard guide).
Claude Desktop configuration, the tool catalog and the policy model: MCP guide. Policies, approvals, risk limits, metrics and recovery: Operations.
Documentation
docs/INDEX.md lists every guide. The ones most people need:
- Setup and callback URLs
- Orders and streaming
- Python and coming from Schwabdev
- MCP and LLM integration and the dashboard for following the agents
- Paper trading and what it does not model
- Operations and shared authority for multi-process deployments
- Troubleshooting
- Architecture, for contributors
Runnable programs are under examples/: cargo run -p oauth-flow, comprehensive, auth_test, and streaming-examples (--bin streaming_quotes).
Contributing and security
See CONTRIBUTING.md and the changelog. Report vulnerabilities privately as described in SECURITY.md.
License
MIT or Apache-2.0, at your option.
Installing Rustyschwab
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/Epistates/rustyschwabFAQ
Is Rustyschwab MCP free?
Yes, Rustyschwab MCP is free — one-click install via Unyly at no cost.
Does Rustyschwab need an API key?
No, Rustyschwab runs without API keys or environment variables.
Is Rustyschwab hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Rustyschwab in Claude Desktop, Claude Code or Cursor?
Open Rustyschwab on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Opencode Omniroute Plugin
OpenCode plugin for the OmniRoute AI Gateway. Drives dynamic model discovery, /connect auth flow, and multi-instance OmniRoute providers via the official @openc
by GitHub ActionsRoblox Studio
Enables AI coding tools to control Roblox Studio for workspace exploration, instance manipulation, and script management. It provides tools for playtesting, sce
by paralovAntigravity Drawio
MCP server that enables AI assistants to create, parse, render, and validate Draw.io diagrams programmatically.
by S-SUJAN-SFetch
Web content fetching and conversion for efficient LLM usage.
AWS KB Retrieval
Retrieval from AWS Knowledge Base using Bedrock Agent Runtime.
by modelcontextprotocolSpring AI MCP Server
Provides auto-configuration for setting up an MCP server in Spring Boot applications.
llm-analysis-assistant
A very streamlined mcp client that supports calling and monitoring stdio/sse/streamableHttp, and can also view request responses through the /logs page. It also
by xuzexin-hzMCP-Agent
A simple, composable framework to build agents using Model Context Protocol by [LastMile AI](https://www.lastmileai.dev)
by lastmile-aiSpring AI MCP Client
Provides auto-configuration for MCP client functionality in Spring Boot applications.
mcp.natoma.ai
A Hosted MCP Platform to discover, install, manage and deploy MCP servers by [Natoma Labs](https://www.natoma.ai)
Compare Rustyschwab with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All ai MCPs
