trading-crew-mcp
# trading-crew-mcp
An MCP server that lets Claude read and annotate the chart open in a **locally running TradingView Desktop** app: read price and candles, draw lines, manage price alerts. Written from scratch (original code, MIT).
## Tools (21)
| Group | Tools |
|---|---|
| Read | `chart_health`, `get_quote`, `get_candles` (up to 500 candles as a compact table; optional `resolution` reads D, 240, 60... and restores the chart), `save_candles` (writes up to 20,000 candles to a JSON file so analysis never copies numbers by hand), `find_pivots`, `suggest_chain` (finds a chain of swing points that no candle cuts, ready for `draw_chain`) |
| View | `set_timeframe`, `set_visible_range`, `screenshot` |
| Draw | `list_drawings`, `get_drawing`, `draw_trend_line`, `draw_chain`, `draw_horizontal_line`, `remove_drawing`, `clear_drawings` |
| Alerts | `list_alerts`, `create_alert`, `modify_alert`, `list_fires`, `delete_alert` |
`draw_chain` takes pivot points and draws a connected chain of straight lines (each starts where the last ended). It checks every segment against the candles first and refuses, listing the candles it would cut through, unless `force` is set.
Safety by design:
- There is **no** tool that clicks the UI, types, or runs arbitrary page code, so the server cannot reach the order panel or place a trade.
- `create_alert` refuses a level on the wrong side of live price (it would fire at once), then reads the alert back and fails if the stored level differs.
- `modify_alert` changes a message or level in place (same alert id), applies the same wrong-side check, and reads the result back.
- `delete_alert` confirms the alert is gone.
## How it works
TradingView Desktop is started with Chromium's standard debug port. The server connects to that port on `localhost` and runs small functions in the open chart page: it reads candles and draws through the page's own chart object (`window.TradingViewApi`). For alerts it makes the same requests to TradingView's alert service that the page itself makes, using your already signed-in session, so it does talk to TradingView's servers on your behalf. It does not bypass any login, subscription or access control.
## Install
```
npm install
```
Start TradingView with its debug port (macOS example):
```
open -a TradingView --args --remote-debugging-port=9222
```
Add to Claude Code:
```
claude mcp add trading-crew --scope project -- node /full/path/to/trading-crew-mcp/src/server.js
```
Environment: `TV_DEBUG_HOST` (default `127.0.0.1`), `TV_DEBUG_PORT` (default `9222`), `TV_DATA_DIR` (where `save_candles` writes; default `./trading-crew-data`).
Check it against your chart: `npm run selftest` (23 live checks: reads, draws and removes lines, creates, edits and deletes a far-away test alert, restores your zoom, and confirms your alert and drawing counts are unchanged).
## Reliability
Chart calls run strictly one at a time, in the order they arrive. Agents often fire several tool calls at once, and two timeframe switches or history loads at the same moment leave the chart on the wrong timeframe. Every tool call has a time limit (60 to 180 seconds depending on the tool). If TradingView is busy or the page does not answer, you get an error back instead of a hang, and the connection is closed and reopened. The timeframe and zoom are restored even after a failed read, and a shape TradingView refuses to create is retried once.
## Status
Version 0.1. Works on TradingView Desktop (macOS) with the page version of 12 Nov 2026. TradingView can change its internals at any time, which would break the page calls; the alert payload in particular was matched to a real request and may need updating.
## Disclaimer
Personal and educational use. Not affiliated with, endorsed by, or associated with TradingView Inc. TradingView's Terms of Use restrict automated access to their platform, and this tool drives the desktop app programmatically, which may conflict with those terms. You are responsible for your own use and accept the risk, including account restrictions. Do not use it to resell market data or for automated trading. Nothing here is financial advice.
TDQS
Scored across 21 tools
Most tools target a distinct resource+action (draw_* vs list/get/remove/clear_drawings, alerts CRUD, chart control, data reads). A few pairs are close: draw_trend_line vs draw_chain (single line vs connected pivot chain), and find_pivots vs suggest_chain (raw swings vs a validated chain), but the descriptions clearly separate these by input/output and purpose (suggest_chain explicitly hands off points to draw_chain). get_candles vs save_candles is well delineated by the 500-candle cap and file-export intent.
Almost all names follow a verb_noun or verb_noun_noun pattern (draw_trend_line, set_timeframe, list_alerts, create_alert, delete_alert, save_candles). The only deviations are the noun-style chart_health and screenshot, which break the verb-first convention but remain unambiguous. Minor deviation overall, not confusing.
At 21 tools the surface is at the upper end of what an agent can hold comfortably; the rubric's 16-25 band is borderline heavy. Each tool does earn a place (7 drawing, 5 data, 5 alerts, 4 chart/screenshot), so it is justified by breadth of functionality rather than padding. Still, some consolidation (e.g. a single draw tool with a type parameter, or merging get_drawing into list_drawings) could trim the set.
Drawings have full lifecycle (multiple create types, list, get, remove, clear) and alerts have near-complete CRUD plus fired-history, with data reads, pivots, screenshots, and chart state all covered. Notable gaps: no way to edit/move an existing drawing (only delete and redraw), no alert enable/disable toggle despite 'active' being listed, and no tool to change the chart symbol (only timeframe), which agents might expect on a trading server. These are workable around but real.