TradingView MCP

🇹🇭 ภาษาไทย

tradingview-mcp — MCP server ที่ connect Claude Code กับ TradingView Desktop app ผ่าน Chrome DevTools Protocol (CDP) สำหรับ AI-assisted chart analysis, Pine Script development, และ workflow automation

  • ผู้สร้าง: tradesdontlie (github.com/tradesdontlie/tradingview-mcp)
  • License: MIT | ไม่ได้ affiliated กับ TradingView Inc. หรือ Anthropic
  • ต้องการ: TradingView subscription ที่ถูกต้อง

ข้อมูลทั้งหมดประมวลผล locally เท่านั้น ไม่ส่งออกนอกเครื่อง

สถาปัตยกรรม

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

78 MCP tools + CLI tv command (30 commands, 66 subcommands)

Setup

git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp && npm install
# Mac: launch TradingView with CDP
./scripts/launch_tv_debug_mac.sh

เพิ่มใน ~/.claude/.mcp.json:

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

Tool Categories (78 tools)

Categoryจำนวนตัวอย่าง
Chart Reading4chart_get_state, quote_get, data_get_study_values
Pine Drawings4data_get_pine_lines, data_get_pine_labels, data_get_pine_tables
Chart Control10chart_set_symbol, chart_set_timeframe, chart_manage_indicator
Pine Script Dev10pine_set_sourcepine_smart_compilepine_get_errorspine_save
Multi-Pane4pane_set_layout (s/2h/2v/2x2/4/6/8), pane_set_symbol
Replay Mode6replay_startreplay_stepreplay_tradereplay_stop
Drawing/Alerts6draw_shape, alert_create
Streaming6tv stream quote/bars/values/lines/tables/all
Utilities8+capture_screenshot, batch_run, tv_health_check

Natural Language → Tool Decision

พูดว่า…Claude ใช้…
”What’s on my chart?”chart_get_statedata_get_study_valuesquote_get
”Switch to AAPL daily”chart_set_symbolchart_set_timeframe
”Write a Pine Script for…”pine_set_sourcepine_smart_compilepine_get_errors
”Set up a 4-chart grid”pane_set_layoutpane_set_symbol
”Take a screenshot”capture_screenshot

🇬🇧 English

tradingview-mcp — an MCP server that connects Claude Code to your TradingView Desktop app via Chrome DevTools Protocol (CDP) for AI-assisted chart analysis, Pine Script development, and workflow automation.

  • Author: tradesdontlie (github.com/tradesdontlie/tradingview-mcp)
  • License: MIT | Not affiliated with TradingView Inc. or Anthropic
  • Requires: A valid TradingView subscription

All data processing is local. No TradingView data is transmitted externally.

Architecture

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

78 MCP tools exposed over stdio + a tv CLI command (30 commands, 66 subcommands). The only dependencies are @modelcontextprotocol/sdk and chrome-remote-interface.

Setup

git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp && npm install
./scripts/launch_tv_debug_mac.sh   # Mac; see scripts/ for Windows/Linux

Add to ~/.claude/.mcp.json:

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

Verify: Ask Claude to run tv_health_check.

Tool Reference (78 Tools)

Chart Reading (4 tools)

ToolUseOutput
chart_get_stateFirst call — get symbol, timeframe, all indicator names + IDs~500B
data_get_study_valuesRead RSI, MACD, BB, EMA values from all indicators~500B
quote_getLatest price, OHLC, volume~200B
data_get_ohlcvPrice bars — use summary: true for compact output500B / 8KB

Pine Drawings — Custom Indicator Data (4 tools)

ToolUse
data_get_pine_linesHorizontal price levels (support/resistance, session levels)
data_get_pine_labelsText annotations with prices (“PDH 24550”, “Bias Long”)
data_get_pine_tablesData tables (session stats, analytics dashboards)
data_get_pine_boxesPrice zones/ranges as {high, low} pairs

Always use study_filter: "Indicator Name" to target a specific indicator.

Pine Script Development (10 tools — in order)

pine_set_sourcepine_smart_compilepine_get_errorspine_get_consolepine_save Also: pine_get_source, pine_new, pine_open, pine_list_scripts, pine_analyze, pine_check

Multi-Pane Layouts: pane_list · pane_set_layout (s/2h/2v/2x2/4/6/8) · pane_focus · pane_set_symbol

Replay Mode: replay_startreplay_stepreplay_autoplayreplay_tradereplay_statusreplay_stop

Drawing & Alerts: draw_shape (horizontal_line/trend_line/rectangle/text) · draw_list · draw_remove_one · draw_clear · alert_create · alert_list · alert_delete

Streaming:

tv stream quote    # price tick monitoring
tv stream bars     # bar-by-bar updates
tv stream values   # indicator value monitoring
tv stream all      # all panes simultaneously

Natural Language Decision Tree

You say…Claude uses…
”What’s on my chart?”chart_get_statedata_get_study_valuesquote_get
”Give me a full analysis”quote_get → study values → lines → labels → tables → ohlcv → screenshot
”Switch to AAPL daily”chart_set_symbolchart_set_timeframe
”Write a Pine Script for…”pine_set_sourcepine_smart_compilepine_get_errors
”Start replay at March 1st”replay_startreplay_stepreplay_trade
”Set up a 4-chart grid”pane_set_layoutpane_set_symbol (×4)
“Draw a level at 24500”draw_shape (horizontal_line)

Context Management

Tools return compact output by default. A typical “analyze my chart” workflow uses ~5-10KB instead of ~80KB.

FeatureHow it saves context
Pine linesDeduplicated price levels only
Pine labelsCapped at 50 per study, text+price only
OHLCV summary modeStats + last 5 bars instead of all bars
study_filterTarget one indicator instead of scanning all
verbose: truePass on any pine tool to get raw data when needed

Research Context

This is an open research project investigating how LLM agents interact with professional trading interfaces: MCP as a bridge between LLMs and stateful desktop financial applications, latency/reliability constraints in live chart environments, and failure modes of LLM agents in real-time data settings. It is not a trading bot — it is an interface layer.