@specialagentk/tradingview-mcp
v3.0.0
Published
MCP bridge for TradingView Desktop via Chrome DevTools Protocol
Maintainers
Readme
TradingView MCP Bridge
Personal AI assistant for your TradingView Desktop charts. Connects Claude Code to your locally running TradingView app via Chrome DevTools Protocol for AI-assisted chart analysis, Pine Script development, and workflow automation.
[!WARNING] This tool is not affiliated with, endorsed by, or associated with TradingView Inc. It interacts with your locally running TradingView Desktop application via Chrome DevTools Protocol. Review the Disclaimer before use.
[!IMPORTANT] Requires a valid TradingView subscription. This tool does not bypass or circumvent any TradingView paywall or access control. It reads from and controls the TradingView Desktop app already running on your machine.
[!NOTE] All data processing occurs locally on your machine. No TradingView data is transmitted, stored, or redistributed externally by this tool.
[!CAUTION] This tool accesses undocumented internal TradingView APIs via the Electron debug interface. These can change or break without notice in any TradingView update. Pin your TradingView Desktop version if stability matters to you.
How It Works (and why it's safe to run)
This tool does not connect to TradingView's servers, modify any TradingView files, or intercept any network traffic. It communicates exclusively with your locally running TradingView Desktop instance via Chrome DevTools Protocol (CDP) — a standard debugging interface built into all Chromium/Electron applications by Google, including VS Code, Slack, and Discord.
The debug port is disabled by default and must be explicitly enabled by you using a standard Chromium flag (--remote-debugging-port=9222). Nothing happens without that deliberate step.
What This Tool Does Not Do
- Connect to TradingView's servers or APIs
- Store, transmit, or redistribute any market data
- Work without a valid TradingView subscription and installed Desktop app
- Bypass any TradingView paywall or access restriction
- Execute real trades (chart interaction only)
- Work if TradingView changes their internal Electron structure
Research Context
This project explores an open research question: how can LLM-based agents interact with professional trading interfaces to support human decision-making?
Specifically it investigates:
- How structured tool APIs (MCP) can bridge LLMs and stateful desktop financial applications
- What latency, context, and reliability constraints emerge when an agent operates on live chart data
- How agents handle ambiguous financial UI state (e.g. interpreting Pine Script output, reading indicator tables)
- Whether natural language is an effective interface for chart navigation and Pine Script development
- The failure modes of LLM agents operating in real-time data environments
This is not a trading bot. It is an interface layer that makes a trading application legible to an LLM agent, allowing researchers and developers to study human-AI collaboration in financial workflows.
See RESEARCH.md for open questions, findings, and related work.
Prerequisites
- TradingView Desktop app (paid subscription required for real-time data)
- Node.js 18+
- Claude Code with MCP support (for MCP tools) or any terminal (for CLI)
- macOS, Windows, or Linux
What It Does
Gives your AI assistant eyes and hands on your own chart:
- Pine Script development — write, inject, compile, debug, and iterate on scripts with AI assistance
- Chart navigation — change symbols, timeframes, zoom to dates, add/remove indicators
- Visual analysis — read your chart's indicator values, price levels, and annotations
- Backtest readout — pull Strategy Tester metrics, trade lists, and equity curves
- Order-book depth — read DOM (Depth of Market) snapshots
- Draw on charts — trend lines, horizontal lines, rectangles, text annotations
- Manage alerts — create, list, and delete price alerts
- Replay practice — step through historical bars, practice entries/exits
- Screenshots — capture chart state for AI visual analysis
- Multi-pane layouts — set up 2x2, 3x1, etc. grids with different symbols per pane
- Monitor your chart — stream JSONL from your locally running chart for local monitoring scripts
- CLI access — every MCP tool is also a
tvCLI command, pipe-friendly with JSON output - Launch TradingView — auto-detect and launch with debug mode from any platform
Install via npm (recommended)
The server is published to npm — you don't need to clone anything. Claude launches it on
demand with npx.
One-liner (Claude Code):
claude mcp add tradingview -- npx -y @specialagentk/tradingview-mcpOr add it to your MCP config manually (~/.claude/.mcp.json or project .mcp.json):
{
"mcpServers": {
"tradingview": {
"command": "npx",
"args": ["-y", "@specialagentk/tradingview-mcp"]
}
}
}That's it — restart Claude and ask "Use tv_health_check to verify TradingView is connected."
You still need TradingView Desktop running with the debug port (see Launch TradingView with
CDP below, or use the tv_launch tool). The package has a single
entrypoint — npx -y @specialagentk/tradingview-mcp runs the MCP server, and
npx -y @specialagentk/tradingview-mcp cli <command> exposes every tool as a pipe-friendly command.
If npx can't launch it — some Node runners (e.g. Volta on Windows) don't resolve package bins
on the fly, and offline/proxied setups can't fetch on demand — install it once and point Claude at
the installed command:
npm i -g @specialagentk/tradingview-mcp# macOS / Linux
claude mcp add tradingview -- tradingview-mcp
# Windows (run from PowerShell, not git-bash, so the /c isn't path-mangled)
claude mcp add tradingview -- cmd /c tradingview-mcpQuick Start (from source)
Prefer to run from a clone (for development or to pin a local version)?
1. Install
git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp
npm install2. Launch TradingView with CDP
TradingView Desktop must be running with Chrome DevTools Protocol enabled on port 9222.
Mac:
./scripts/launch_tv_debug_mac.shWindows:
scripts\launch_tv_debug.batLinux:
./scripts/launch_tv_debug_linux.shOr launch manually on any platform:
/path/to/TradingView --remote-debugging-port=9222Or use the MCP tool (auto-detects your install):
"Use tv_launch to start TradingView in debug mode"
3. Add to Claude Code
Add to your Claude Code MCP config (~/.claude/.mcp.json or project .mcp.json):
{
"mcpServers": {
"tradingview": {
"command": "node",
"args": ["/path/to/tradingview-mcp/src/server.js"]
}
}
}Replace /path/to/tradingview-mcp with your actual path.
4. Verify
Ask Claude: "Use tv_health_check to verify TradingView is connected"
CLI
Every MCP tool is also reachable through the package's CLI. All output is JSON for piping with jq.
# Installed from npm
tradingview-mcp cli <command>
# From a source clone
node src/bin.js cli <command> # or: npm run tv -- <command>Migration (2.x): the CLI is now a subcommand of the single
tradingview-mcpentrypoint. The separatetradingview-mcp-clibin was removed — replacetradingview-mcp-cli <command>withtradingview-mcp cli <command>.
In the examples below, tv is shorthand for whichever entrypoint you use — tradingview-mcp cli
(installed) or node src/bin.js cli (from source).
Quick Examples
tv status # check connection
tv quote # current price
tv symbol AAPL # change symbol
tv ohlcv --summary # price summary
tv screenshot -r chart # capture chart
tv pine compile # compile Pine Script
tv pane layout 2x2 # 4-chart grid
tv pane symbol 1 ES1! # set pane symbol
tv stream quote | jq '.close' # monitor price changesAll Commands
tv status / launch / state / symbol / timeframe / type / info / search
tv quote / ohlcv / values
tv data lines/labels/tables/boxes/strategy/trades/equity/depth/indicator
tv pine get/set/compile/raw-compile/analyze/check/save/new/open/list/errors/console
tv draw shape/list/get/remove/clear
tv alert list/create/delete
tv watchlist get/add
tv indicator add/remove/toggle/set/get
tv layout list/switch
tv pane list/layout/focus/symbol
tv tab list/new/close/switch
tv replay start/step/stop/status/autoplay/trade
tv stream quote/bars/values/lines/labels/tables/all
tv ui click/keyboard/hover/scroll/find/eval/type/panel/fullscreen/mouse
tv screenshot / discover / ui-state / range / scrollStreaming
The tv stream commands poll your locally running TradingView Desktop instance at regular intervals via Chrome DevTools Protocol on localhost.
No connection is made to TradingView's servers. All data stays on your machine.
[!WARNING] Programmatic consumption of TradingView data may conflict with their Terms of Use regardless of the data source. You are solely responsible for ensuring your usage complies.
tv stream quote # price tick monitoring
tv stream bars # bar-by-bar updates
tv stream values # indicator value monitoring
tv stream lines --filter "NY Levels" # price level monitoring
tv stream tables --filter Profiler # table data monitoring
tv stream all # all panes at once (multi-symbol)How Claude Knows Which Tool to Use
Claude reads CLAUDE.md automatically when working in this project. It contains a complete decision tree:
| You say... | Claude uses... |
|------------|---------------|
| "What's on my chart?" | chart_get_state → data_get_study_values → quote_get |
| "What levels are showing?" | data_get_pine_lines → data_get_pine_labels |
| "Read the session table" | data_get_pine_tables with study_filter |
| "Give me a full analysis" | quote_get → data_get_study_values → data_get_pine_lines → data_get_pine_labels → data_get_pine_tables → data_get_ohlcv (summary) → capture_screenshot |
| "Switch to AAPL daily" | chart_set_symbol → chart_set_timeframe |
| "Write a Pine Script for..." | pine_set_source → pine_smart_compile → pine_get_errors |
| "Start replay at March 1st" | replay_start → replay_step → replay_trade |
| "Set up a 4-chart grid" | pane_set_layout → pane_set_symbol for each pane |
| "Draw a level at 24500" | draw_shape (horizontal_line) |
| "Take a screenshot" | capture_screenshot |
Tool Reference (78 MCP tools)
The 78 tools are registered across 14 modules. Every tool below is live in the current build.
Chart Reading
| Tool | When to use | Output size |
|------|------------|-------------|
| chart_get_state | First call — get symbol, timeframe, all indicator names + IDs | ~500B |
| data_get_study_values | Read current RSI, MACD, BB, EMA values from all indicators | ~500B |
| quote_get | Get latest price, OHLC, volume | ~200B |
| data_get_ohlcv | Get price bars. Use summary: true for compact stats | 500B (summary) / 8KB (100 bars) |
| data_get_indicator | Get a study's input values/config (skip for encrypted commercial indicators) | varies |
| depth_get | Read order book / DOM (Depth of Market) | ~1KB |
Custom Indicator Data (Pine Drawings)
Read line.new(), label.new(), table.new(), box.new() output from any visible Pine indicator.
| Tool | When to use | Output size |
|------|------------|-------------|
| data_get_pine_lines | Read horizontal price levels (support/resistance, session levels) | ~1-3KB |
| data_get_pine_labels | Read text annotations + prices ("PDH 24550", "Bias Long") | ~2-5KB |
| data_get_pine_tables | Read data tables (session stats, analytics dashboards) | ~1-4KB |
| data_get_pine_boxes | Read price zones / ranges as {high, low} pairs | ~1-2KB |
Always use study_filter to target a specific indicator: study_filter: "Profiler".
Strategy Tester
Read backtest output from a strategy script loaded on the chart.
| Tool | When to use |
|------|------------|
| data_get_strategy_results | Performance metrics (net profit, win rate, drawdown, profit factor) |
| data_get_trades | Trade list from the Strategy Tester (capped at 20 per request) |
| data_get_equity | Equity-curve data points |
Chart Control
| Tool | What it does |
|------|-------------|
| chart_set_symbol | Change ticker (BTCUSD, AAPL, ES1!, NYMEX:CL1!) |
| chart_set_timeframe | Change resolution (1, 5, 15, 60, D, W, M) |
| chart_set_type | Change style (Candles, HeikinAshi, Line, Area, Renko) |
| chart_manage_indicator | Add/remove indicators. Use full names: "Relative Strength Index" not "RSI" |
| chart_scroll_to_date | Jump to a date (ISO: "2025-01-15") |
| chart_get_visible_range / chart_set_visible_range | Read / zoom to exact range (unix timestamps) |
| symbol_info / symbol_search | Symbol metadata and search |
| indicator_set_inputs / indicator_toggle_visibility | Change indicator settings, show/hide |
Multi-Pane Layouts
| Tool | What it does |
|------|-------------|
| pane_list | List all panes with symbols and active state |
| pane_set_layout | Change grid: s, 2h, 2v, 2x2, 4, 6, 8 |
| pane_focus | Focus a specific pane by index |
| pane_set_symbol | Set symbol on any pane |
Tab Management
| Tool | What it does |
|------|-------------|
| tab_list | List open chart tabs |
| tab_new / tab_close | Open/close tabs |
| tab_switch | Switch to a tab by index |
Pine Script Development
| Tool | Step |
|------|------|
| pine_set_source | 1. Inject code into editor |
| pine_smart_compile | 2. Compile with auto-detection + error check (preferred) |
| pine_compile | Raw compile/add-to-chart (no auto-detection or error summary) |
| pine_get_errors | 3. Read compilation errors if any |
| pine_get_console | 4. Read log.info() output |
| pine_save | 5. Save to TradingView cloud |
| pine_get_source | Read current script (warning: can be 200KB+ for complex scripts) |
| pine_new | Create blank indicator/strategy/library |
| pine_open / pine_list_scripts | Open or list saved scripts |
| pine_analyze | Offline static analysis (no chart needed) |
| pine_check | Server-side compile check (no chart needed) |
Replay Mode
| Tool | Step |
|------|------|
| replay_start | Enter replay at a date |
| replay_step | Advance one bar |
| replay_autoplay | Auto-advance (set speed in ms) |
| replay_trade | Buy/sell/close positions |
| replay_status | Check position, P&L, date |
| replay_stop | Return to realtime |
Drawing & Alerts
| Tool | What it does |
|------|-------------|
| draw_shape | Draw horizontal_line, trend_line, rectangle, text |
| draw_list / draw_remove_one / draw_clear | List, remove one, or clear all drawings |
| draw_get_properties | Read a drawing's points and properties by entity ID |
| alert_create / alert_list / alert_delete | Manage price alerts |
Screenshots, Batch & Watchlist
| Tool | What it does |
|------|-------------|
| capture_screenshot | Screenshot (regions: full, chart, strategy_tester) |
| batch_run | Run an action (screenshot, get_ohlcv) across multiple symbols/timeframes |
| watchlist_get / watchlist_add | Read / add to the watchlist |
| layout_list / layout_switch | List / switch saved chart layouts |
UI Automation
Generic DOM/keyboard/mouse control for actions without a purpose-built tool.
| Tool | What it does |
|------|-------------|
| ui_open_panel | Open/close/toggle panels (pine-editor, strategy-tester, watchlist, alerts, trading) |
| ui_click | Click an element by aria-label, data-name, text, or class substring |
| ui_find_element | Locate elements and return their on-screen positions |
| ui_hover | Hover over an element |
| ui_scroll | Scroll the chart/page up/down/left/right |
| ui_keyboard | Press keys/shortcuts (Enter, Escape, Alt+S, Ctrl+Z) |
| ui_type_text | Type into the focused input/textarea |
| ui_mouse_click | Click at raw x,y coordinates |
| ui_fullscreen | Toggle fullscreen |
| ui_evaluate | Escape hatch — run raw JS in the page (bypasses all input sanitization; full DOM/account access) |
Connection & Diagnostics
| Tool | What it does |
|------|-------------|
| tv_launch | Auto-detect and launch TradingView Desktop with CDP enabled (Mac/Win/Linux) |
| tv_health_check | Verify CDP connection and return chart state |
| tv_discover | Report which known TradingView API paths are available |
| tv_ui_state | Report which panels are open and which buttons are visible/enabled |
Context Management
Tools return compact output by default to minimize context usage. For a typical "analyze my chart" workflow, total context is ~5-10KB instead of ~80KB.
| Feature | How it saves context |
|---------|---------------------|
| Pine lines | Returns deduplicated price levels only, not every line object |
| Pine labels | Capped at 50 per study, text+price only |
| Pine tables | Pre-formatted row strings, no cell metadata |
| Pine boxes | Deduplicated {high, low} zones only |
| OHLCV summary mode | Stats + last 5 bars instead of all bars |
| Indicator inputs | Encrypted/encoded blobs auto-filtered |
| verbose: true | Pass on any pine tool to get raw data with IDs/colors when needed |
| study_filter | Target one indicator instead of scanning all |
Finding TradingView on Your System
Launch scripts and tv_launch auto-detect TradingView. If auto-detection fails:
| Platform | Common Locations |
|----------|-----------------|
| Mac | /Applications/TradingView.app/Contents/MacOS/TradingView |
| Windows | %LOCALAPPDATA%\TradingView\TradingView.exe, %PROGRAMFILES%\WindowsApps\TradingView*\TradingView.exe |
| Linux | /opt/TradingView/tradingview, ~/.local/share/TradingView/TradingView, /snap/tradingview/current/tradingview |
The key flag: --remote-debugging-port=9222
Testing
# Requires TradingView running with --remote-debugging-port=9222
npm test29 tests covering: Pine Script static analysis, server-side compilation, and CLI routing.
Architecture
Claude Code ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)- Transport: MCP over stdio (78 tools) + CLI (
tvcommand, 28 commands with 69 subcommands) - Connection: Chrome DevTools Protocol on localhost:9222
- Streaming: Poll-and-diff loop with deduplication, JSONL output to stdout
- No dependencies beyond
@modelcontextprotocol/sdkandchrome-remote-interface
Attributions
This project is not affiliated with, endorsed by, or associated with:
- TradingView Inc. — TradingView is a trademark of TradingView Inc.
- Anthropic — Claude and Claude Code are trademarks of Anthropic, PBC.
This tool is an independent MCP server that connects to Claude Code via the standard MCP protocol. It does not contain or modify any Anthropic software.
Disclaimer
This project is provided for personal, educational, and research purposes only.
How this tool works: This tool uses the Chrome DevTools Protocol (CDP), a standard debugging interface built into all Chromium-based applications by Google. It does not reverse engineer any proprietary TradingView protocol, connect to TradingView's servers, or bypass any access controls. The debug port must be explicitly enabled by the user via a standard Chromium command-line flag (--remote-debugging-port=9222).
By using this software, you acknowledge and agree that:
- You are solely responsible for ensuring your use of this tool complies with TradingView's Terms of Use and all applicable laws.
- TradingView's Terms of Use restrict automated data collection, scraping, and non-display usage of their platform and data. This tool uses Chrome DevTools Protocol to programmatically interact with the TradingView Desktop app, which may conflict with those terms.
- You assume all risk associated with using this tool. The authors are not responsible for any account bans, suspensions, legal actions, or other consequences resulting from its use.
- This tool must not be used for, including but not limited to:
- Redistributing, reselling, or commercially exploiting TradingView's market data
- Circumventing TradingView's access controls or subscription restrictions
- Performing automated trading or algorithmic decision-making using extracted data
- Violating the intellectual property rights of Pine Script indicator authors
- Connecting to TradingView's servers or infrastructure (all access is via the locally running Desktop app)
- The streaming functionality monitors your locally running TradingView Desktop instance only. It does not connect to TradingView's servers or extract data from TradingView's infrastructure.
- Market data accessed through this tool remains subject to exchange and data provider licensing terms. Do not redistribute, store, or commercially exploit any data obtained through this tool.
- This tool accesses internal, undocumented TradingView application interfaces that may change or break at any time without notice.
Use at your own risk. If you are unsure whether your intended use complies with TradingView's terms, do not use this tool.
License
MIT — see LICENSE for details.
The MIT license applies to the source code of this project only. It does not grant any rights to TradingView's software, data, trademarks, or intellectual property.
