TradeStaq MCP
Official# TradeStaq MCP Server
[](https://www.npmjs.com/package/@the-staq/tradestaq-mcp)
[](https://opensource.org/licenses/MIT)
**[Website](https://tradestaq.com)** · **[Docs](https://tradestaq.com/docs)** · **[MCP / AI Tools](https://tradestaq.com/mcp)** · **[Pricing](https://tradestaq.com/pricing)**
**56 AI-powered trading tools for Claude, Cursor, and any MCP client.**
Create strategies, backtest them, deploy trading bots, copy top traders, monitor positions, and manage your crypto portfolio, all from conversation. Supports Binance, Bybit, OKX, Bitget, Hyperliquid, dYdX, and more.
```
"Show me my portfolio" → get_portfolio
"Backtest GhostRider on BTC/USDT for 3 months" → what_if_backtest
"Deploy it on my Binance account" → deploy_bot
"Who are the top traders this month?" → list_top_traders
"Generate a momentum strategy for ETH" → generate_strategy
```
## Quick Start
### Option A: Remote server (no install needed)
For MCP clients that support HTTP transport:
```json
{
"mcpServers": {
"tradestaq": {
"url": "https://mcp.tradestaq.com/mcp"
}
}
}
```
### Option B: npx (recommended for local)
No clone, no build. Just add to your MCP config:
**Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
```json
{
"mcpServers": {
"tradestaq": {
"command": "npx",
"args": ["-y", "@the-staq/tradestaq-mcp"]
}
}
}
```
**Cursor** (`.cursor/mcp.json`):
```json
{
"mcpServers": {
"tradestaq": {
"command": "npx",
"args": ["-y", "@the-staq/tradestaq-mcp"]
}
}
}
```
**Claude Code:**
```sh
claude mcp add tradestaq -- npx -y @the-staq/tradestaq-mcp
```
### Option C: Clone and build
```sh
git clone https://github.com/the-staq/tradestaq-mcp.git
cd tradestaq-mcp
npm install
npm run build
```
Then point your MCP client to `dist/index.js`.
## Authenticate
After adding the server, ask your AI assistant to log in:
- **"Log me in to TradeStaq"** — uses email/password directly
- **"Authenticate with TradeStaq"** — opens a browser window for secure OAuth login
Credentials never enter the chat when using the browser flow. Token is stored locally at `~/.tradestaq/mcp-config.json` with restricted permissions (0600).
## Tools
### Auth
| Tool | Description |
|------|-------------|
| `login` | Log in with email and password |
| `authenticate` | Log in via browser (OAuth + PKCE) |
| `check_auth` | Check authentication status |
| `set_token` | Manually set a JWT token |
| `connect_exchange` | Connect an exchange account via browser |
| `logout` | Remove stored credentials |
### Market Data
| Tool | Description |
|------|-------------|
| `get_price` | Current price, 24h change, volume |
| `get_candles` | OHLCV candlestick data (1m to 1d) |
| `list_exchanges` | List connected exchange accounts |
| `create_paper_exchange` | Create a paper-trading exchange with a simulated balance (no API keys) |
| `search_markets` | Find trading pairs on a specific exchange |
### Portfolio
| Tool | Description |
|------|-------------|
| `get_portfolio` | Total balance, exchanges, active bots |
| `get_positions` | Open positions with live PnL |
### Strategies
| Tool | Description |
|------|-------------|
| `list_strategies` | Browse marketplace or your own strategies |
| `get_strategy` | Full strategy details and performance |
| `explain_strategy` | Plain-English explanation with risk profile |
| `compare_strategies` | Side-by-side metrics comparison |
| `create_strategy` | Create a strategy from TradeDroid code |
| `generate_strategy` | Generate a strategy from natural language using AI |
| `update_strategy` | Edit one of your strategies: metadata and/or code (code writes a draft version; bots keep running the stable one) |
| `list_strategy_versions` | A strategy's version history with validation status and the channel each version serves |
| `validate_strategy_version` | Run the validation pipeline on a strategy's latest draft version (async) |
| `promote_strategy_version` | Promote a validated version to the stable or beta channel (stable changes what live bots run; needs `mcp:live`) |
| `start_optimization_run` | Start a Strategy Lab run that improves one of your strategies (costs wallet money: estimate first, then confirm) |
| `get_optimization_status` | Progress and result of a Strategy Lab run |
| `send_optimization_guidance` | Steer a running Strategy Lab run with free-text guidance |
| `cancel_optimization_run` | Cancel a Strategy Lab run (the best version found so far is kept, held) |
### Backtesting
| Tool | Description |
|------|-------------|
| `what_if_backtest` | Run a historical backtest (async, 30-120s) |
| `get_backtest_results` | Check status of a running backtest |
| `export_backtest` | CSV and PDF download links for a finished backtest |
### Bot Management
| Tool | Description |
|------|-------------|
| `list_bots` | All bots with status and performance |
| `get_bot_status` | Detailed bot metrics and config |
| `get_bot_logs` | Run-by-run history: why a bot did or did not trade, dropped signals, errors |
| `deploy_bot` | Deploy a strategy as a trading bot |
| `update_bot` | Edit a bot: rename, switch strategy or apply a preset, timeframe, execution mode, strategy parameters, version channel, risk settings, notifications, `stopAfterClose` |
| `start_bot` | Start a paused or stopped bot |
| `stop_bot` | Stop a running bot now (open positions are left unmanaged) |
| `delete_bot` | Delete a bot (refused while it has an open trade) |
| `close_position` | Close an open position (full or partial) |
| `export_bot_trades` | A bot's closed trades with entry/exit prices and PnL, plus a performance summary |
| `list_bot_share_links` | A bot's public chart links (tradestaq.com/chart/...) |
| `create_bot_share_link` | Make a public link to a bot's live chart (choose expiry and whether PnL shows) |
| `revoke_bot_share_link` | Turn a public chart link off |
| `list_bot_webhooks` | A bot's outgoing webhook destinations (header values are never shown) |
| `add_bot_webhook` | Send a bot's trade opens and closes to an https URL (JSON body template, custom headers) |
| `update_bot_webhook` | Change a destination (URL, body, headers, constants, events, on/off) |
| `delete_bot_webhook` | Remove a destination |
| `preview_bot_webhook` | Render the body with a sample trade; sends nothing |
| `test_bot_webhook` | Send a REAL test request to the URL (needs `confirm: true`) |
| `get_bot_webhook_deliveries` | A destination's delivery log: status, timing, errors |
`deploy_bot` defaults to paper trading. Pass `live: true` for real money. The bot trades on the strategy's own timeframe; pass `timeframe` (e.g. `4h`) only to override it. Leave out `name` and the server names the bot. The bot starts trading as soon as it is created, so give it its settings in the same call: `presetId` (a preset's ID or slug, of the same strategy), `parameterOverrides` and `executionMode`; the server applies them in the create itself (with a preset the bot is created paused, then started). `strategyId` takes an ID or a slug. `start: false` creates it paused for `start_bot`.
`update_bot` sends everything you pass in one update, after merging it onto the bot's current settings (position sizing, spin settings and parameter overrides are never wiped by a partial change). Size and leverage change only when you pass them. `strategyId` and `presetId` take an ID or a slug (`trade-wind`, `trade-wind-long-short`). A strategy or timeframe change needs the bot to be flat: pause it with `stopAfterClose: true` first, wait until `get_bot_status` shows no open position, then switch, then `start_bot`. A live bot needs the `mcp:live` scope for any change; a paper bot `mcp:paper`. The reply is the resulting config (strategy, version, timeframe, mode, overrides, size, leverage, status) plus server warnings.
For example, switching a paused 15m GhostRider bot to Trade Wind on 4h with its Long & Short preset, and renaming it:
```json
{ "id": "6ab7c2d60014ba19b0c54258", "presetId": "trade-wind-long-short", "timeframe": "4h", "name": "Trade Wind · SUI · 4h" }
```
### Outgoing webhooks
A bot can send every trade it opens or closes to a URL you choose, for example a signal-bot endpoint on an exchange or your own service. Each event is an HTTP POST with a JSON body you shape with a template (`{{action}}`, `{{symbol}}`, `{{price}}`, `{{size}}`, `{{pnl}}`, `{{const.NAME}}` and more; `add_bot_webhook` lists them all) and the headers you set.
- Add one with `add_bot_webhook`, or give `deploy_bot` / `update_bot` a `webhooks` array. With `deploy_bot` the destinations are added while the bot is still paused and the bot is started afterwards, so its first trade is not missed. Each webhook is first checked against the server's own rules (https on port 443, no TradeStaq, private or reserved address, header and secret names and values, template variables, valid JSON, 16 KB at most), so those mistakes create no bot. A plan without signal forwarding (e.g. Free) and the account's limits can only be refused after the bot exists: then the bot is kept, left paused (not started), and the reply says which webhook failed and why. `update_bot` only ever adds; use `update_bot_webhook` and `delete_bot_webhook` to change or remove one.
- Secrets for the body (`secrets`, used as `{{secret.NAME}}`) are write-only like header values: encrypted, never shown again, never repeated by the tools. Constants are plain text, so tokens go in `secrets` or headers. Changing a URL's host needs every header and secret sent again.
- Header values (tokens) are write-only: they are encrypted and the server never returns them (only the last 4 characters of a long value as a hint). The tools scrub the values sent in a call from every reply to that call, also JSON-escaped, URL-encoded or in another letter case. A value from an earlier call can still show up when a receiver echoes it in `test_bot_webhook` or the delivery log; there `Bearer ...` values and fields named like `token`, `signalToken`, `secret`, `passphrase`, `password` or `apiKey` are masked, but not every echo. Put secrets in headers or `secrets`, not in the URL. The template, constants and URL are shown in plain text exactly as saved, so they can be edited and sent back; a value shown as `[hidden]` or `(hidden)` is refused.
- Check the body with `preview_bot_webhook` first: it renders a sample trade (and the same template for an exit booked without a price) and sends nothing. `test_bot_webhook` sends a real request, and a trading service may act on it, so it needs `confirm: true` and the user's agreement. When the URL gives no HTTP answer (a timeout or a dropped connection) the result is `sent: "unknown"`: the request may have arrived, so check the receiver before testing again. Tests are limited to 5 per destination, 10 per bot and 20 per account per hour, 2 at a time.
- Paper trades are only sent when `includePaper` is true, so a paper bot (the `deploy_bot` default) sends nothing without it; the replies say what each destination will send. Never set `includePaper` for a URL that places real orders: the paper bot's trades would become real orders. A failed delivery is tried again, 8 attempts in total over about 21 minutes. The server turns a destination off after 20 failed events in a row; `get_bot_webhook_deliveries` shows why.
- Delivery is at least once: dedupe on `event_id` (also the `X-TradeStaq-Event-Id` header). An exit can arrive for a position the receiver does not hold, and an open older than 5 minutes is dropped. Bots that copy another trader cannot have webhooks.
- Needs a TradeStaq plan with signal forwarding (otherwise the server answers 403) and the write scope of the bot's account (`mcp:live` for a live bot). Reading and the delivery log work with any scope. A bot has up to 5 destinations.
### Trade History
| Tool | Description |
|------|-------------|
| `get_trade_history` | Closed trades, one row per close: direction, entry/exit prices, PnL, return on position size |
| `get_performance_metrics` | ROI, win rate, Sortino ratio, PnL breakdown |
### Copy Trading
| Tool | Description |
|------|-------------|
| `list_top_traders` | Browse the leaderboard of top traders |
| `follow_trader` | Subscribe to copy a trader's trades |
### Advisor
| Tool | Description |
|------|-------------|
| `suggest_strategies` | Match strategies to your risk profile |
| `get_market_context` | Trend, volatility, support/resistance for a symbol |
## Prompt Templates
**Trading Assistant** — Start a conversation about your portfolio and positions. The AI calls `get_portfolio` and `get_positions` to ground its responses in your actual data.
**Strategy Builder** — Walk through creating, backtesting, and deploying a strategy. Pass an optional `goal` like "momentum strategy for ETH" to get focused suggestions.
**Portfolio Reviewer** — Deep analysis of your portfolio, positions, trade history, and performance. Identifies what's working, what isn't, and suggests improvements.
## Resources
MCP resources provide browsable data that AI clients can read directly:
| Resource | URI | Description |
|----------|-----|-------------|
| Portfolio | `tradestaq://portfolio` | Balances, positions, and active bots |
| Bots | `tradestaq://bots` | All bots with status and PnL |
| Strategies | `tradestaq://strategies` | Strategy catalog with ratings |
## Architecture
```
stdio HTTPS
┌──────────────┐◄──────────►┐ ┌────────────────►┌──────────────┐
│Claude Desktop│ │ │ │ │
│Cursor / CLI │ │ tradestaq-mcp │ Bearer JWT │ TradeStaq │
└──────────────┘ │ 56 tools │◄────────────────│ API │
│ 3 prompts │ │ │
┌──────────────┐ HTTP+SSE │ 3 resources │ └──────────────┘
│ Any MCP │◄──────────►│ │
│ client (web) │ └──────────────────┘
└──────────────┘
```
- **Two transports:** stdio (local, default) and HTTP+SSE (remote, `--http` flag)
- Hosted at `https://mcp.tradestaq.com/mcp` for remote clients
- JWT auth via OAuth PKCE or email/password login
- All tools return structured JSON with error contract
- Token auto-refresh before the access token expires. Several local copies (say an interactive session plus headless `claude -p` runs) can share one sign-in: they refresh one at a time under a lockfile next to `~/.tradestaq/mcp-config.json`, and a copy whose tokens another one rotated picks up the new pair from the file
## Development
```sh
npm run dev # watch mode with tsx
npm run build # compile TypeScript
npm run lint # type check without emitting
npm test # run tests
npm start # run server (stdio)
npm run start:http # run server (HTTP+SSE on port 3100)
```
### Releasing
```sh
npm run release:patch # or release:minor / release:major
```
This bumps the version (and the `server.json` versions), files the CHANGELOG's
`[Unreleased]` notes under it, commits, tags `vX.Y.Z` and pushes. The tag triggers
`.github/workflows/publish.yml`:
1. **Approve the run.** The publish job waits in the `npm` environment for a maintainer's
approval (Actions, then the run, then *Review deployments*).
2. It type-checks, tests and publishes to npm through trusted publishing (no npm token
anywhere), with provenance.
3. It updates the listing on the official MCP Registry.
Then run the **Deploy MCP** workflow to update the hosted server at mcp.tradestaq.com.
## Error Handling
All tool errors return structured responses:
```json
{
"error": {
"code": "INSUFFICIENT_BALANCE",
"message": "Human-readable description",
"retryable": true,
"retryAfterMs": 5000
}
}
```
Error codes: `AUTH_EXPIRED`, `TIMEOUT`, `RATE_LIMITED`, `NETWORK_ERROR`, `HTTP_4xx`, `HTTP_5xx`.
## Security
- Credentials never enter AI conversation history
- OAuth PKCE flow with browser-based authentication
- Token stored with 0600 file permissions
- Localhost-only OAuth callbacks
- `deploy_bot`, `stop_bot`, `close_position`, and `follow_trader` are destructive operations (AI confirms with user)
## Links
- **Website:** [tradestaq.com](https://tradestaq.com)
- **Documentation:** [tradestaq.com/docs](https://tradestaq.com/docs)
- **MCP & AI trading tools:** [tradestaq.com/mcp](https://tradestaq.com/mcp)
- **Pricing:** [tradestaq.com/pricing](https://tradestaq.com/pricing)
- **npm package:** [@the-staq/tradestaq-mcp](https://www.npmjs.com/package/@the-staq/tradestaq-mcp)
## License
MIT
TDQS
Scored across 34 tools
Most tools have clearly distinct purposes, with only minor overlap among auth-related tools (authenticate, login, set_token) and portfolio vs positions vs trade history. Descriptions are sufficiently detailed to resolve ambiguity.
Tool names consistently follow the verb_noun pattern (e.g., close_position, create_strategy, list_bots). Only login/logout deviate, but that's standard for auth verbs. The pattern is predictable and uniform.
34 tools is above the typical 3-15 range for a well-scoped server. While the domain is broad (strategy management, backtesting, bots, portfolio, copy trading), the number feels heavy and may overwhelm agents.
The tool surface covers core trading workflows but lacks update and delete operations for strategies and bots. Create and deploy are present, but modifications and deletions are absent, creating notable gaps.