TradingView MCP
Enables automated control of TradingView Desktop via Chrome DevTools Protocol with 78+ tools for chart manipulation, Pine Script development, and indicator analysis. Supports automated morning briefs for session bias generation, replay trading practice, and multi-pane layouts with secure local-only data processing.
README
TradingView MCP
MCP server for TradingView Desktop — 78 tools to read, control, and automate charts via Chrome DevTools Protocol. Works with Claude Code, Codex, and Claude Desktop.
Built on top of tradingview-mcp by @tradesdontlie and the Jackson fork by @LewisWJackson. This fork adds security hardening, input sanitization, bug fixes, Codex compatibility, and code quality improvements.
[!WARNING] Not affiliated with TradingView Inc. or Anthropic. This tool connects to your locally running TradingView Desktop app via Chrome DevTools Protocol. Review the Disclaimer before use.
[!IMPORTANT] Requires a valid TradingView subscription. This tool does not bypass any TradingView paywall. It reads from and controls the TradingView Desktop app already running on your machine.
[!NOTE] All data processing happens locally. Nothing is sent anywhere. No TradingView data leaves your machine.
What's New in This Fork
| Feature | What it does |
|---|---|
| Security hardening | Input sanitization via escapeJsString() / validateNumber() — fixes JS injection vulnerabilities in 8 core modules |
| Bug fixes | Protected JSON.parse calls, missing await fixes, negative index validation, graceful shutdown |
morning_brief |
One command that scans your watchlist, reads all your indicators, and returns structured data for Claude to generate your session bias |
session_save / session_get |
Saves your daily brief to ~/.tradingview-mcp/sessions/ so you can compare today vs yesterday |
rules.json |
Write your trading rules once — bias criteria, risk rules, watchlist. The morning brief applies them automatically every day |
| Codex support | Full compatibility with Codex Desktop — auto-configured via config.toml with MCP server registration |
| Launch bug fix | Fixed tv_launch compatibility with TradingView Desktop v2.14+ |
tv brief CLI |
Run your morning brief from the terminal in one word |
One-Shot Setup
Paste this into Claude Code and it will handle everything:
Set up TradingView MCP for me.
Clone https://github.com/ulianbass/tradingview-mcp.git to ~/tradingview-mcp, 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 MCP": { "command": "node", "args": ["/Users/YOUR_USERNAME/tradingview-mcp/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.
Or follow the manual steps below.
Prerequisites
- TradingView Desktop app (paid subscription required for real-time data)
- Node.js 18+
- Claude Code (for MCP tools) or any terminal (for CLI)
- macOS, Windows, or Linux
Quick Start
1. Clone and install
git clone https://github.com/ulianbass/tradingview-mcp.git ~/tradingview-mcp
cd ~/tradingview-mcp
npm install
2. Set up your rules
cp rules.example.json rules.json
Open rules.json and fill in:
- Your watchlist (symbols to scan each morning)
- Your bias criteria (what makes something bullish/bearish/neutral for you)
- Your risk rules (the rules you want Claude to check before every session)
3. Launch TradingView with CDP
TradingView must be running with the debug port enabled.
Mac:
./scripts/launch_tv_debug_mac.sh
Windows:
scripts\launch_tv_debug.bat
Linux:
./scripts/launch_tv_debug_linux.sh
Or use the MCP tool after setup: "Use tv_launch to start TradingView in debug mode"
4. Add to your AI tools
Works with Claude Code, Claude Desktop, and Codex. Add to whichever you use:
Claude Code
Add to ~/.claude/mcp.json:
{
"mcpServers": {
"TradingView MCP": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/tradingview-mcp/src/server.js"]
}
}
}
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) inside the mcpServers object:
"TradingView MCP": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/tradingview-mcp/src/server.js"]
}
Codex
Add to ~/.codex/config.toml:
[mcp_servers.tradingview]
command = "node"
args = ["/Users/YOUR_USERNAME/tradingview-mcp/src/server.js"]
[mcp_servers.tradingview.tools.tv_health_check]
approval_mode = "approve"
[mcp_servers.tradingview.tools.chart_get_state]
approval_mode = "approve"
[mcp_servers.tradingview.tools.quote_get]
approval_mode = "approve"
[mcp_servers.tradingview.tools.data_get_ohlcv]
approval_mode = "approve"
[mcp_servers.tradingview.tools.data_get_study_values]
approval_mode = "approve"
[mcp_servers.tradingview.tools.data_get_pine_lines]
approval_mode = "approve"
[mcp_servers.tradingview.tools.data_get_pine_labels]
approval_mode = "approve"
[mcp_servers.tradingview.tools.data_get_pine_tables]
approval_mode = "approve"
[mcp_servers.tradingview.tools.chart_set_symbol]
approval_mode = "approve"
[mcp_servers.tradingview.tools.chart_set_timeframe]
approval_mode = "approve"
[mcp_servers.tradingview.tools.capture_screenshot]
approval_mode = "approve"
[mcp_servers.tradingview.tools.morning_brief]
approval_mode = "approve"
Note for Codex: Each tool must have
approval_modedeclared or Codex won't load it. The list above covers the most common tools. Add more as needed.
Replace YOUR_USERNAME with your actual username. On Mac: echo $USER to check.
5. Verify
Restart your AI tool, then ask: "Use tv_health_check to verify TradingView is connected"
6. Run your first morning brief
Ask Claude: "Run morning_brief and give me my session bias"
Or from the terminal:
npm link # install tv CLI globally (one time)
tv brief
Morning Brief Workflow
This is the feature that turns this from a toolkit into a daily habit.
Before every session:
- TradingView is open (launched with debug port)
- Run:
tv briefin your terminal (or ask Claude: "run morning_brief") - Claude scans every symbol in your watchlist, reads your indicator values, applies your
rules.jsoncriteria, and prints:
BTCUSD | BIAS: Bearish | KEY LEVEL: 94,200 | WATCH: RSI crossing 50 on 4H
ETHUSD | BIAS: Neutral | KEY LEVEL: 3,180 | WATCH: Ribbon direction on daily
SOLUSD | BIAS: Bullish | KEY LEVEL: 178.50 | WATCH: Hold above 20 EMA
Overall: Cautious session. BTC leading bearish, SOL the exception — watch for divergence.
- Save it: "save this brief" (uses
session_save) - Next morning, compare: "get yesterday's session" (uses
session_get)
What This Tool Does
- Morning brief — scan watchlist, read indicators, apply your rules, print session bias
- Pine Script development — write, inject, compile, debug scripts with AI
- Chart navigation — change symbols, timeframes, zoom to dates, add/remove indicators
- Visual analysis — read indicator values, price levels, drawn levels from custom indicators
- Draw on charts — trend lines, horizontal levels, rectangles, text
- Manage alerts — create, list, delete price alerts
- Replay practice — step through historical bars, practice entries and exits with P&L tracking
- Screenshots — capture chart state
- Multi-pane layouts — 2x2, 3x1 grids with different symbols per pane
- Stream data — JSONL output from your live chart for monitoring scripts
- CLI access — every tool is also a
tvcommand, pipe-friendly JSON output
How Claude Knows Which Tool to Use
Claude reads CLAUDE.md automatically when working in this project. It contains the full decision tree.
| You say... | Claude uses... |
|---|---|
| "Run my morning brief" | morning_brief → apply rules → session_save |
| "What was my bias yesterday?" | session_get |
| "What's on my chart?" | chart_get_state → data_get_study_values → quote_get |
| "Give me a full analysis" | quote_get → data_get_study_values → data_get_pine_lines → data_get_pine_labels → capture_screenshot |
| "Switch to BTCUSD 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 |
| "Draw a level at 94200" | draw_shape (horizontal_line) |
Tool Reference (81 MCP tools)
Morning Brief (new in this fork)
| Tool | What it does |
|---|---|
morning_brief |
Scan watchlist, read indicators, return structured data for session bias. Reads rules.json automatically. |
session_save |
Save the generated brief to ~/.tradingview-mcp/sessions/YYYY-MM-DD.json |
session_get |
Retrieve today's brief (or yesterday's if today not saved yet) |
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) |
Custom Indicator Data (Pine Drawings)
Read line.new(), label.new(), table.new(), box.new() output from any visible Pine indicator.
| Tool | When to use |
|---|---|
data_get_pine_lines |
Horizontal price levels (support/resistance, session levels) |
data_get_pine_labels |
Text annotations + prices ("PDH 24550", "Bias Long") |
data_get_pine_tables |
Data tables (session stats, analytics dashboards) |
data_get_pine_boxes |
Price zones as {high, low} pairs |
Always use study_filter to target a specific indicator: study_filter: "MyIndicator".
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") |
indicator_set_inputs / indicator_toggle_visibility |
Change indicator settings, show/hide |
Pine Script Development
| Tool | Step |
|---|---|
pine_set_source |
1. Inject code into editor |
pine_smart_compile |
2. Compile with auto-detection + error check |
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_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 |
Multi-Pane, Alerts, Drawings, UI
| Tool | What it does |
|---|---|
pane_set_layout |
Change grid: s, 2h, 2v, 2x2, 4, 6, 8 |
pane_set_symbol |
Set symbol on any pane |
draw_shape |
Draw horizontal_line, trend_line, rectangle, text |
alert_create / alert_list / alert_delete |
Manage price alerts |
batch_run |
Run action across multiple symbols/timeframes |
watchlist_get / watchlist_add |
Read/modify watchlist |
capture_screenshot |
Screenshot (regions: full, chart, strategy_tester) |
tv_launch / tv_health_check |
Launch TradingView and verify connection |
CLI Commands
tv brief # run morning brief
tv session get # get today's saved brief
tv session save --brief "..." # save a brief
tv status # check connection
tv quote # current price
tv symbol BTCUSD # 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 stream quote | jq '.close' # monitor price ticks
Full command list: tv --help
Troubleshooting
| Problem | Solution |
|---|---|
cdp_connected: false |
TradingView isn't running with --remote-debugging-port=9222. Use the launch script. |
ECONNREFUSED |
TradingView isn't running or port 9222 is blocked |
| MCP server not showing in Claude Code | Check ~/.claude/.mcp.json syntax, restart Claude Code |
tv command not found |
Run npm link from the project directory |
morning_brief — "No rules.json found" |
Run cp rules.example.json rules.json and fill it in |
morning_brief — watchlist empty |
Add symbols to the watchlist array in rules.json |
| Tools return stale data | TradingView still loading — wait a few seconds |
| Pine Editor tools fail | Open Pine Editor panel first: ui_open_panel pine-editor open |
Architecture
Claude Code / Claude Desktop / Codex ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)
- 78 original tools + 3 morning brief tools = 81 MCP tools total
- Transport: MCP over stdio + CLI (
tvcommand) - Connection: Chrome DevTools Protocol on localhost:9222
- Compatible with: Claude Code, Claude Desktop, Codex (any MCP-capable AI tool)
- Security: All user inputs sanitized via
escapeJsString()/validateNumber()before CDP evaluation - No external network calls — everything runs locally
- Zero extra dependencies beyond the original
Credits
- Original tradingview-mcp by @tradesdontlie — the foundation
- Jackson fork by @LewisWJackson — morning brief, rules config, launch fix
- Security hardening and bug fixes by @ulianbass
Disclaimer
This project is provided for personal, educational, and research purposes only.
This tool uses the Chrome DevTools Protocol (CDP), a standard debugging interface built into all Chromium-based applications. 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.
By using this software you agree that:
- You are solely responsible for ensuring your use complies with TradingView's Terms of Use and all applicable laws.
- This tool accesses undocumented internal TradingView APIs that may change at any time.
- This tool must not be used to redistribute, resell, or commercially exploit TradingView's market data.
- The authors are not responsible for any account bans, suspensions, or other consequences.
Use at your own risk.
License
MIT — see LICENSE. Applies to source code only, not to TradingView's software, data, or trademarks.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。