MCP Server for TradeStation API - Market Data, Brokerage, and Order Execution
Project description
TradeStation MCP Server
An MCP (Model Context Protocol) server that exposes the full TradeStation API as tools for LLM-powered applications like Claude Desktop, VS Code Copilot, and other MCP clients.
Features
- 36 MCP Tools covering all three TradeStation API categories:
- Market Data (17 tools): Quotes, historical bars, option chains, market depth, symbol search, streaming
- Brokerage (11 tools): Accounts, balances, positions, orders, order history, streaming
- Order Execution (8 tools): Place/confirm/replace/cancel orders, group orders (OCO/Bracket), routes
- 5 MCP Prompts for common workflows: portfolio review, stock lookup, trade placement, options analysis, daily summary
- Built-in OAuth2 Authentication: Opens your browser for secure TradeStation login — no manual token management
- Automatic Token Refresh: Access tokens refresh automatically (they expire every 20 minutes)
- Streaming Support: Real-time market data and order updates via time-bounded collection windows
- Smart Account Resolution: Brokerage tools auto-detect your accounts when IDs aren't specified
- Rich Tool Descriptions: Domain-tagged descriptions ensure the LLM correctly routes "What's my balance?" to brokerage tools and "What's the stock price?" to market data tools
Prerequisites
- Python 3.10+
- TradeStation Account with API access
- TradeStation API Key — Get one here
Installation
From PyPI (recommended)
pip install tradestation-mcp
From source (development)
# Clone the repository
git clone https://github.com/theelderwand/tradestation-mcp.git
cd tradestation-mcp
# Create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS/Linux
# source .venv/bin/activate
# Install in development mode with dev dependencies
pip install -e ".[dev]"
Quick run with uvx (no install needed)
uvx tradestation-mcp
Configuration
-
Copy the example environment file:
copy .env.example .env
-
Edit
.envwith your TradeStation API credentials:TS_CLIENT_ID=your_api_key_here TS_CLIENT_SECRET=your_api_secret_here TS_REDIRECT_PORT=3000
-
Make sure your API key has
http://localhost:3000in its Allowed Callback URLs (this is a default for new keys).
First Run — Authentication
On first launch, the server will:
- Open your default browser to the TradeStation login page
- You log in with your TradeStation credentials and authorize the application
- The browser redirects back to
localhost:3000where the server captures the auth code - Tokens are exchanged and saved to
~/.tradestation_mcp_tokens.json
Subsequent launches will use the saved refresh token — no browser needed unless the refresh token is revoked.
Usage with GitHub Copilot CLI
GitHub Copilot CLI stores MCP server configs in ~/.copilot/mcp-config.json. You can set it up in two ways:
Option A: Interactive (inside Copilot CLI)
- Launch
copilot(orgh copilot) in your terminal - Type
/mcp add - Fill in the fields:
- Name:
tradestation - Type:
stdio - Command:
tradestation-mcp(if installed via pip)
- Name:
- Press
Ctrl+Sto save
Option B: Edit the config file directly
Create or edit ~/.copilot/mcp-config.json:
{
"mcpServers": {
"tradestation": {
"type": "stdio",
"command": "tradestation-mcp",
"env": {
"TS_CLIENT_ID": "your_api_key",
"TS_CLIENT_SECRET": "your_api_secret"
}
}
}
}
Note: If you installed from source instead of pip, replace
"command": "tradestation-mcp"with the full path to your Python executable and use"args": ["-m", "tradestation_mcp.server"].
Verify it works
Inside Copilot CLI, type /mcp to see your configured servers and confirm tradestation is listed. Then try:
Use the tradestation MCP server to get a quote for MSFT
Allow tools without manual approval (optional)
copilot --allow-tool 'tradestation'
Or deny specific dangerous tools while allowing the rest:
copilot --allow-tool 'tradestation' --deny-tool 'tradestation(place_order)' --deny-tool 'tradestation(place_group_order)'
Usage with Claude Desktop
Add to your Claude Desktop configuration (%APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"tradestation": {
"command": "tradestation-mcp",
"env": {
"TS_CLIENT_ID": "your_api_key",
"TS_CLIENT_SECRET": "your_api_secret"
}
}
}
}
Usage with VS Code (Copilot / MCP)
Add to your VS Code .vscode/mcp.json:
{
"servers": {
"tradestation": {
"command": "tradestation-mcp",
"env": {
"TS_CLIENT_ID": "your_api_key",
"TS_CLIENT_SECRET": "your_api_secret"
}
}
}
}
Tool Reference
Market Data Tools
| Tool | Description | Example Query |
|---|---|---|
get_quote_snapshots |
Current price quotes | "What's the stock price of MSFT?" |
get_bars |
Historical OHLCV bars | "Show me AAPL daily chart for last month" |
stream_bars |
Live streaming bars | "Stream live 1-minute bars for TSLA" |
get_crypto_symbol_names |
List crypto pairs | "What crypto symbols are available?" |
get_symbol_details |
Symbol info/metadata | "What exchange does MSFT trade on?" |
get_option_expirations |
Option expiry dates | "When do AAPL options expire?" |
get_option_risk_reward |
Risk/reward analysis | "What's the max profit on this spread?" |
get_option_spread_types |
Available strategies | "What option spread types exist?" |
get_option_strikes |
Available strikes | "Show strikes for AAPL options" |
stream_option_chain |
Live option chain | "Show me the AAPL option chain" |
stream_option_quotes |
Live option pricing | "Stream greeks for these contracts" |
stream_quotes |
Live quote stream | "Stream live prices for MSFT,AAPL" |
stream_market_depth_quotes |
Level 2 data | "Show market depth for MSFT" |
stream_market_depth_aggregates |
Aggregated depth | "Show aggregated order book for SPY" |
suggest_symbols |
Symbol autocomplete | "Find symbols for Tesla" |
search_symbols |
Advanced symbol search | "Search for ES futures" |
stream_tick_bars |
Tick-based bars | "Show tick bars for MSFT" |
Brokerage Tools
| Tool | Description | Example Query |
|---|---|---|
get_accounts |
List accounts | "What accounts do I have?" |
get_balances |
Current balances | "What's my account balance?" |
get_balances_bod |
Opening balances | "What was my balance at market open?" |
get_positions |
Current holdings | "What stocks do I own?" |
get_orders |
Today's orders | "Do I have any open orders?" |
get_orders_by_id |
Specific order lookup | "Show me order 123456789" |
get_historical_orders |
Past order history | "Show my trades from last week" |
get_historical_orders_by_id |
Specific past order | "Find historical order 123456789" |
stream_orders |
Live order updates | "Stream my order status updates" |
stream_orders_by_id |
Live specific order | "Watch order 123456789 for fills" |
stream_positions |
Live position updates | "Stream my portfolio P&L" |
Order Execution Tools
| Tool | Description | Example Query |
|---|---|---|
confirm_order |
Preview order cost | "How much to buy 100 MSFT?" |
place_order |
Execute a trade | "Buy 100 shares of MSFT" |
confirm_group_order |
Preview group order | "Preview my bracket order" |
place_group_order |
Place OCO/bracket | "Place bracket order on AAPL" |
replace_order |
Modify open order | "Change my limit to $150" |
cancel_order |
Cancel open order | "Cancel order 123456789" |
get_activation_triggers |
Conditional triggers | "What trigger types are available?" |
get_routes |
Order routes | "What routes can I use?" |
Security Notes
- Token Storage: Tokens are saved in plaintext at
~/.tradestation_mcp_tokens.json. This file contains your refresh token which can be used to obtain new access tokens. Ensure your home directory has appropriate permissions. - Refresh Tokens: By default, TradeStation refresh tokens do not expire. You can contact TradeStation Client Experience to enable rotation (30-minute expiry).
- Order Safety: The
place_ordertool description instructs the LLM to always callconfirm_orderfirst, but this is guidance — the tool itself does not enforce it. - Production API: This server connects to TradeStation's production API. All orders are REAL.
Troubleshooting
"TS_CLIENT_ID environment variable is required"
- Ensure your
.envfile exists or set the environment variables directly.
Browser doesn't open for authentication
- Manually visit the URL printed in stderr logs.
- Ensure port 3000 (or your configured port) is not in use.
"Token refresh failed"
- Delete
~/.tradestation_mcp_tokens.jsonand restart to re-authenticate.
"No brokerage accounts found"
- Ensure your API key has the correct logins configured. Contact TradeStation Client Experience.
Contributing
See CONTRIBUTING.md for development setup and guidelines.
License
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tradestation_mcp-1.0.0.tar.gz.
File metadata
- Download URL: tradestation_mcp-1.0.0.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec7a1e3cfb5ff342d085433a88e002d834b2e9d38ec408d94e906b08716d9407
|
|
| MD5 |
7c2539f26966baf19efddfb01e4b3477
|
|
| BLAKE2b-256 |
e3fb0b392bb40163ffc9df4d497f0690ec7b82211f1b470af0d1515f9e187adb
|
Provenance
The following attestation bundles were made for tradestation_mcp-1.0.0.tar.gz:
Publisher:
publish.yml on theelderwand/tradestation-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradestation_mcp-1.0.0.tar.gz -
Subject digest:
ec7a1e3cfb5ff342d085433a88e002d834b2e9d38ec408d94e906b08716d9407 - Sigstore transparency entry: 926581896
- Sigstore integration time:
-
Permalink:
theelderwand/tradestation-mcp@2c3df4317f4ee745f672ec1db36fb5acda0d7810 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/theelderwand
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c3df4317f4ee745f672ec1db36fb5acda0d7810 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tradestation_mcp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tradestation_mcp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
caff3f4c60f6a412a5e1281a8d80bf7127bf411b99da71c93d86271a08cc66aa
|
|
| MD5 |
c1474f1539289a9f71bb067f3941678a
|
|
| BLAKE2b-256 |
0a94d32027ece7ec80f9578611e1fc5308963eb4289f249a2dde7fffde8f629d
|
Provenance
The following attestation bundles were made for tradestation_mcp-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on theelderwand/tradestation-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tradestation_mcp-1.0.0-py3-none-any.whl -
Subject digest:
caff3f4c60f6a412a5e1281a8d80bf7127bf411b99da71c93d86271a08cc66aa - Sigstore transparency entry: 926582028
- Sigstore integration time:
-
Permalink:
theelderwand/tradestation-mcp@2c3df4317f4ee745f672ec1db36fb5acda0d7810 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/theelderwand
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2c3df4317f4ee745f672ec1db36fb5acda0d7810 -
Trigger Event:
release
-
Statement type: