Skip to main content
Glama
rajmaurya0904

TradingView MCP Bridge

TradingView MCP Bridge

Gives Claude Code eyes and hands on your own TradingView Desktop chart — 78 MCP tools (and a tv CLI) over the Chrome DevTools Protocol, all on localhost.

Describing a chart to an AI is the slow part: you screenshot it, type out the levels your Pine indicator drew, paste the compile error, repeat. This bridge removes that loop. Claude reads the real chart state — symbol, timeframe, indicator values, line.new() levels, label.new() text, table.new() rows — and can change symbols, draw, inject and compile Pine Script, step through replay bars and screenshot the result. Nothing leaves your machine.

IMPORTANT

Not affiliated with, endorsed by, or associated with TradingView Inc. It drives the TradingView Desktop app already running on your machine, needs a valid TradingView subscription, bypasses no paywall, and transmits no data anywhere. It also leans on undocumented internal TradingView APIs, which can break in any update — pin your Desktop version if stability matters. Read the Disclaimer before use.

Real output

Static Pine analysis runs without TradingView open, so this one you can reproduce right after npm install:

$ tv pine analyze --file session-levels.pine
{
  "success": true,
  "issue_count": 2,
  "diagnostics": [
    {
      "line": 4,
      "column": 1,
      "message": "array.set(levels, 3) — index 3 out of bounds (array size is 3)",
      "severity": "error"
    },
    {
      "line": 6,
      "column": 1,
      "message": "strategy.entry/close used but no strategy() declaration found — did you mean to use indicator()?",
      "severity": "error"
    }
  ]
}

Every command prints JSON, so it pipes: tv stream quote | jq '.close'.

With TradingView running, the same capabilities arrive as MCP tools and you just ask. "What levels are showing?" becomes data_get_pine_lines → data_get_pine_labels; "give me a full analysis" chains quote, study values, Pine lines, labels, tables, an OHLCV summary and a screenshot — about 5–10KB of context instead of 80KB, because every tool returns compact output by default.

Related MCP server: TradingView MCP Bridge

Install

Prerequisites: TradingView Desktop with a paid subscription, Node.js 18+, and Claude Code (for the MCP tools) or any terminal (for the CLI). Mac, Windows and Linux.

git clone https://github.com/rajmaurya0904/tradingview-mcp.git
cd tradingview-mcp
npm install
npm link            # optional: puts `tv` on your PATH

1. Launch TradingView with the debug port. CDP must be enabled on port 9222 — it is off by default and only you can turn it on.

./scripts/launch_tv_debug_mac.sh        # Mac
start.bat                               # Windows (runs launch-tv.ps1)
./scripts/launch_tv_debug_linux.sh      # Linux
/path/to/TradingView --remote-debugging-port=9222   # manual, any platform

On Windows the Store build is a UWP app, so plain CDP is blocked until a loopback exemption exists. launch-tv.ps1 (what start.bat runs) adds the exemption, restarts TradingView in your user session and attaches the debug port. There is also the tv_launch MCP tool, which auto-detects your install: "Use tv_launch to start TradingView in debug mode".

2. Register the MCP server in ~/.claude/.mcp.json or a project .mcp.json:

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["/path/to/tradingview-mcp/src/server.js"]
    }
  }
}

3. Verify. Ask Claude "Use tv_health_check to verify TradingView is connected", or run tv status.

If auto-detection cannot find the app, the install usually lives at one of these; the flag that matters is --remote-debugging-port=9222.

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

Usage

Every MCP tool is also a tv subcommand (28 commands, 69 subcommands), and all output is JSON.

tv status                          # check the CDP connection
tv quote                           # current price
tv symbol AAPL                     # change symbol
tv ohlcv --summary                 # compact price stats instead of every bar
tv values                          # current indicator values
tv screenshot -r chart             # capture the chart region
tv pine compile                    # find the compile button, compile, report errors
tv pane layout 2x2                 # 4-chart grid
tv pane symbol 1 ES1!              # set the symbol on pane 1
tv stream quote | jq '.close'      # JSONL tick monitoring

Full surface:

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/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 / scroll

tv stream * polls your local chart over CDP and emits JSONL, deduplicated — useful for a local monitoring script:

tv stream bars                           # bar-by-bar updates
tv stream lines --filter "NY Levels"     # one indicator's price levels
tv stream tables --filter Profiler       # table data only
tv stream all                            # every pane at once
WARNING

Programmatic consumption of TradingView data may conflict with their Terms of Use regardless of where the data comes from. That is on you to check.

What to say to Claude

Claude reads CLAUDE.md automatically in this project; it holds the full decision tree. The short version:

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)

Five skills in skills/ package the common workflows: chart analysis, multi-symbol scan, Pine development, replay practice, strategy report.

How it works

Claude Code  ←→  MCP Server (stdio)  ←→  CDP (port 9222)  ←→  TradingView Desktop (Electron)

It never connects to TradingView's servers, modifies no TradingView files and intercepts no network traffic. It talks only to the Desktop app on your machine over the Chrome DevTools Protocol — the standard debugging interface Google builds into every Chromium/Electron app, including VS Code, Slack and Discord. The port is disabled until you pass --remote-debugging-port=9222 yourself, so nothing happens without that deliberate step.

  • Transport: MCP over stdio, 78 tools, plus the tv CLI.

  • Streaming: poll-and-diff loop with deduplication, JSONL to stdout.

  • Dependencies: two — @modelcontextprotocol/sdk and chrome-remote-interface.

  • Context discipline: Pine lines come back as deduplicated price levels rather than line objects; labels are capped at 50 per study (text + price); tables arrive as pre-formatted row strings; boxes as {high, low} pairs; encoded indicator-input blobs are filtered out. Pass verbose: true on any Pine tool for the raw data with ids and colours, and study_filter: "Profiler" to target one indicator instead of scanning all of them.

Tool reference (78 tools)

Chart reading. chart_get_state (~500B) is the first call — symbol, timeframe, indicator names and ids. Then data_get_study_values for current RSI/MACD/BB/EMA readings (~500B), quote_get for latest price and volume (~200B), and data_get_ohlcv for bars — pass summary: true (500B) unless you really want 100 bars (8KB).

Custom indicator data. Reads the drawing calls of any visible Pine indicator: data_get_pine_lines (price levels, ~1–3KB), data_get_pine_labels (text + price, ~2–5KB), data_get_pine_tables (dashboards, ~1–4KB), data_get_pine_boxes (zones, ~1–2KB).

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_set_visible_range / chart_get_visible_range

Zoom to an exact range (unix timestamps)

symbol_info / symbol_search

Symbol metadata and search

indicator_set_inputs / indicator_toggle_visibility

Change indicator settings, show/hide

pane_list / pane_set_layout / pane_focus / pane_set_symbol

Grids: s, 2h, 2v, 2x2, 4, 6, 8, and a symbol per pane

tab_list / tab_new / tab_close / tab_switch

Chart tabs

layout_list / layout_switch

Saved layouts

Pine Script, in workflow order: pine_set_source → pine_smart_compile → pine_get_errors → pine_get_console (your log.info() output) → pine_save. Also pine_get_source (can be 200KB+ for a complex script), pine_new, pine_open, pine_list_scripts, pine_analyze (offline static analysis) and pine_check (server-side compile check, no chart needed).

Replay: replay_start at a date, replay_step a bar, replay_autoplay at a set speed, replay_trade to buy/sell/close, replay_status for position and P&L, replay_stop back to realtime.

Drawing, alerts, automation: draw_shape (horizontal_line, trend_line, rectangle, text), draw_list / draw_get_properties / draw_remove_one / draw_clear, alert_create / alert_list / alert_delete, capture_screenshot (regions: full, chart, strategy_tester), batch_run (one action across many symbols or timeframes), watchlist_get / watchlist_add, ui_open_panel / ui_click / ui_evaluate and friends, and tv_launch / tv_health_check / tv_discover / tv_ui_state.

Limitations

What it does not do, by design or by nature:

  • No real trades. Chart interaction only. replay_trade moves positions inside TradingView's replay simulator; there is no broker connection anywhere in the tree.

  • No TradingView account or server access. It cannot work without a valid subscription and the Desktop app installed and running; it bypasses no paywall and stores, transmits or redistributes no market data.

  • Brittle by construction. It drives undocumented internal Electron APIs. A TradingView update can break any tool without notice, and tv_discover exists precisely to tell you which API paths still resolve.

  • Desktop only. No web TradingView, no mobile, no headless use — a real app window has to be open with the debug port enabled.

  • Windows Store build needs a loopback exemption before CDP can connect at all; that is what launch-tv.ps1 sets up.

  • UI automation is coordinate- and selector-driven, so it is the first thing to break after a TradingView redesign.

  • The end-to-end test suite only runs against a live chart, so a fresh clone can verify static analysis and CLI routing but not the CDP layer.

Development

npm run test:unit   # 29 tests, 5 suites — Pine static analysis + CLI routing, no chart needed
npm test            # adds the E2E suite: needs TradingView running on port 9222

The E2E suite covers all tool modules against a live chart, so expect failures without one. See CONTRIBUTING.md, SETUP_GUIDE.md for a longer install walkthrough, and SECURITY.md.

Research context

This project explores an open question: how can LLM-based agents interact with professional trading interfaces to support human decision-making? Specifically:

  • 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 — interpreting Pine Script output, reading indicator tables

  • Whether natural language is an effective interface for chart navigation and Pine development

  • The failure modes of LLM agents in real-time data environments

This is not a trading bot. It is an interface layer that makes a trading application legible to an agent, so human-AI collaboration in financial workflows can be studied. Open questions, findings and related work are in RESEARCH.md.

Architecture

Claude Code  <->  MCP Server (stdio)  <->  CDP (port 9222)  <->  TradingView Desktop (Electron)
  • Transport: MCP over stdio (78 tools) plus the tv CLI (28 commands, 69 subcommands)

  • Connection: Chrome DevTools Protocol on localhost:9222

  • Streaming: poll-and-diff loop with deduplication, JSONL to stdout

  • Dependencies: just @modelcontextprotocol/sdk and chrome-remote-interface

Attributions

Not affiliated with, endorsed by or associated with TradingView Inc. (TradingView is their trademark) or Anthropic, PBC. (Claude and Claude Code are theirs). This is an independent MCP server that connects to Claude Code over the standard MCP protocol; it contains and modifies no Anthropic software. The MCP server and CLI build on the earlier work in tradesdontlie/tradingview-mcp.

Disclaimer

For personal, educational and research purposes only. It uses the Chrome DevTools Protocol, a standard debugging interface built into Chromium-based applications; it reverse engineers no proprietary TradingView protocol, connects to none of their servers and bypasses no access control, and the debug port must be enabled by you.

By using this software you accept that:

  1. You are solely responsible for complying with TradingView's Terms of Use and all applicable law.

  2. Those terms restrict automated data collection, scraping and non-display usage. This tool interacts with the Desktop app programmatically, which may conflict with them.

  3. You assume all risk — account bans, suspensions, legal action or any other consequence. The authors are not responsible.

  4. It must not be used to redistribute, resell or commercially exploit TradingView's market data; to circumvent access controls or subscription restrictions; for automated trading or algorithmic decision-making on extracted data; to violate Pine Script authors' intellectual property; or to connect to TradingView's own infrastructure.

  5. Streaming monitors your local Desktop instance only.

  6. Market data remains subject to exchange and data-provider licensing. Do not redistribute, store or commercially exploit it.

  7. Internal, undocumented interfaces can change or break at any time.

Nothing here is financial advice. 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. The licence covers this project's source only; it grants no rights to TradingView's software, data, trademarks or intellectual property.

Related MCP Connectors

  • Evidence-gated quant research for TradingView Pine Script strategies, run from your AI client.

  • > TradingMCP puts a market analyst inside your AI assistant. Paste one URL into Claude, ChatGPT, Cursor, VS Code or any MCP client and ask in plain language: screen for breakouts, run a multi-timeframe analysis, backtest a strategy with walk-forward validation, scan for smart-money and volume signals, or get a one-prompt morning market brief. In clients that support MCP Apps, price charts and the Markets panel are drawn right in the chat. > 40+ tools covering crypto (real-time), stocks, ETFs, FX, futures and commodities across major global exchanges. > Hosted, nothing to install: Pro $9/month (2,500 tool calls) or Pro+ $29/month (10,000). Paid upfront with a 14-day money-back guarantee; your API key arrives right after checkout. > Built on the open-source tradingview-mcp core (MIT, ~5k GitHub stars): self-host it free, or use the hosted version with zero ops. > For research and education, not financial advice. Not affiliated with TradingView

  • AI-powered Pine Script v6 strategy generator built for prop-firm futures traders.

  • Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.

Related MCP Servers