TradingView MCP
by Kabeeraa27
README.md
# TradingView MCP
Control and read a live TradingView Desktop chart from Claude Code via Chrome DevTools Protocol — plus a local web dashboard for market scanning, backtesting, and live NSE PCR data.
Built on [tradingview-mcp-jackson](https://github.com/LewisWJackson/tradingview-mcp-jackson) by [@LewisWJackson](https://github.com/LewisWJackson), itself built on [tradingview-mcp](https://github.com/tradesdontlie/tradingview-mcp) by [@tradesdontlie](https://github.com/tradesdontlie). Go star both.
> [!WARNING]
> **Not affiliated with TradingView Inc. or Anthropic.** Requires a valid TradingView subscription — this does not bypass any paywall, it only reads/controls the TradingView Desktop app already running on your machine. All data processing is local; nothing is sent anywhere. See [Disclaimer](#disclaimer).
---
## What's New in This Fork
| Feature | What it does |
|---------|-------------|
| `morning_brief` / `session_save` / `session_get` | Scan your watchlist, apply `rules.json`, generate a session bias, save/compare day to day |
| `tv brief` CLI | Run the morning brief from the terminal |
| Launch fix | `tv_launch` compatibility with TradingView Desktop v2.14+ |
| Local web dashboard (`npm run dashboard`) | `localhost:3010` — Market Data table, Strategy-1 scanner, S1-Lab (first-hour OH/OL backtesting + signal-frequency leaderboard), Heatmap, live NIFTY/BANKNIFTY/FINNIFTY/MIDCPNIFTY PCR from NSE |
| Light / dark theme | Toggle in the dashboard header, persists across sessions |
---
## Setup
**Prerequisites**: TradingView Desktop (paid subscription), Node.js 18+, Claude Code (or any terminal for the CLI), macOS/Windows/Linux.
```bash
git clone https://github.com/Kabeeraa27/TradingViewMCP.git
cd TradingViewMCP
npm install
cp rules.example.json rules.json # fill in your watchlist, bias & risk rules
```
**Launch TradingView with the debug port enabled** (required for every MCP/CDP tool and the dashboard's scans):
| OS | Command |
|----|---------|
| Windows | `scripts\launch_tv_debug.bat` |
| Mac | `./scripts/launch_tv_debug_mac.sh` |
| Linux | `./scripts/launch_tv_debug_linux.sh` |
**Add to Claude Code** — merge into `~/.claude/.mcp.json`:
```json
{
"mcpServers": {
"tradingview": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/TradingViewMCP/src/server.js"]
}
}
}
```
Restart Claude Code, then ask: *"Use tv_health_check to verify TradingView is connected."*
**Optional — local dashboard** (independent of Claude Code): `npm run dashboard`, then open `http://localhost:3010`. Live PCR fetches from NSE automatically, no extra config.
**Optional — CLI**: `npm link` once, then `tv brief`, `tv status`, `tv --help`, etc.
Or paste this into Claude Code and it handles the clone/install/config/verify for you:
```
Set up TradingView MCP for me.
Clone https://github.com/Kabeeraa27/TradingViewMCP.git to ~/TradingViewMCP, run npm install, then add it to my MCP config at ~/.claude/.mcp.json (merge with any existing servers, don't overwrite them).
The config block is: { "mcpServers": { "tradingview": { "command": "node", "args": ["/Users/YOUR_USERNAME/TradingViewMCP/src/server.js"] } } } — replace YOUR_USERNAME with my actual username.
Then copy rules.example.json to rules.json and open it so I can fill in my trading rules.
Finally restart and verify with tv_health_check.
```
Runtime data (`rules.json`, `strategy1-log.json`, `strategy1-lab-log.json`, `pcr/history.json`) is gitignored — your trading data never gets committed or clobbered by `git pull`.
---
## Morning Brief Workflow
1. TradingView is open (debug port on)
2. `tv brief` in your terminal (or ask Claude: *"run morning_brief"*)
3. Claude scans your watchlist, applies `rules.json`, prints a bias per symbol:
```
BTCUSD | BIAS: Bearish | KEY LEVEL: 94,200 | WATCH: RSI crossing 50 on 4H
```
4. *"save this brief"* → `session_save`; next morning, *"get yesterday's session"* → `session_get`
---
## What This Tool Does
Morning brief · Pine Script dev (write/inject/compile/debug) · chart navigation & indicators · reading price levels/labels/tables from custom Pine drawings · drawing trend lines/levels/boxes · alerts · replay mode with P&L tracking · screenshots · multi-pane layouts · live JSONL streaming · CLI for every tool.
Claude picks the right tool automatically via the decision tree in `CLAUDE.md`.
---
## Tool Reference (81 MCP tools)
### Chart Reading
| Tool | Use | Size |
|------|-----|------|
| `chart_get_state` | First call — symbol, timeframe, indicator IDs | ~500B |
| `data_get_study_values` | Current RSI/MACD/BB/EMA values | ~500B |
| `quote_get` | Latest price, OHLC, volume | ~200B |
| `data_get_ohlcv` | Price bars — use `summary: true` for compact stats | 500B–8KB |
### Pine Drawings (`line.new()`, `label.new()`, `table.new()`, `box.new()`)
| Tool | Reads |
|------|-------|
| `data_get_pine_lines` | Horizontal price levels |
| `data_get_pine_labels` | Text annotations + prices |
| `data_get_pine_tables` | Data tables |
| `data_get_pine_boxes` | Price zones as `{high, low}` |
Use `study_filter: "MyIndicator"` to target one indicator.
### Chart Control
`chart_set_symbol` · `chart_set_timeframe` · `chart_set_type` · `chart_manage_indicator` (use full names, e.g. "Relative Strength Index" not "RSI") · `chart_scroll_to_date` · `indicator_set_inputs` / `indicator_toggle_visibility`
### Pine Script
`pine_set_source` → `pine_smart_compile` → `pine_get_errors` → `pine_get_console` → `pine_save`. Offline: `pine_analyze`, `pine_check`.
### Replay
`replay_start` → `replay_step` / `replay_autoplay` → `replay_trade` → `replay_status` → `replay_stop`
### Multi-pane, alerts, drawing, UI
`pane_set_layout` (`s`/`2h`/`2v`/`2x2`/`4`/`6`/`8`) · `pane_set_symbol` · `draw_shape` · `alert_create`/`list`/`delete` · `batch_run` · `watchlist_get`/`add` · `capture_screenshot` · `tv_launch` / `tv_health_check`
### Morning Brief
`morning_brief` (reads `rules.json`) · `session_save` · `session_get`
---
## CLI
```bash
tv brief tv status tv symbol BTCUSD
tv session get tv quote tv ohlcv --summary
tv session save --brief "…" tv screenshot -r chart tv pine compile
tv pane layout 2x2 tv stream quote | jq '.close'
```
Full list: `tv --help`
---
## Troubleshooting
| Problem | Solution |
|---------|----------|
| `cdp_connected: false` / `ECONNREFUSED` | TradingView isn't running with `--remote-debugging-port=9222` — use the launch script |
| MCP server not showing in Claude Code | Check `~/.claude/.mcp.json` syntax, restart Claude Code |
| `tv` command not found | `npm link` from the project directory |
| "No rules.json found" | `cp rules.example.json rules.json` |
| Watchlist empty | Add symbols to `rules.json`'s `watchlist` array |
| Stale data | TradingView still loading — wait a few seconds |
| Pine Editor tools fail | Open the panel first: `ui_open_panel pine-editor open` |
---
## Architecture
```
Claude Code ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)
```
CLI (`tv`) talks to the same server. No external network calls except live PCR (NSE) in the dashboard — everything else runs locally.
---
## Disclaimer
For personal, educational, and research use only. Uses the Chrome DevTools Protocol — a standard Chromium debugging interface, explicitly enabled by you via a command-line flag. Does not reverse-engineer any proprietary protocol or bypass access controls.
By using this you agree: you're responsible for complying with [TradingView's Terms of Use](https://www.tradingview.com/policies/); this accesses undocumented internal APIs that may change anytime; it must not be used to redistribute/resell/commercially exploit TradingView's data; the authors aren't responsible for account bans or other consequences. **Use at your own risk.**
## License
MIT — see [LICENSE](LICENSE). Applies to source code only, not TradingView's software, data, or trademarks.
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues