TradingView MCP
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.
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.
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.
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 |
Bug fixes | Protected JSON.parse calls, missing await fixes, negative index validation, graceful shutdown |
| One command that scans your watchlist, reads all your indicators, and returns structured data for Claude to generate your session bias |
| Saves your daily brief to |
| 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 |
Launch bug fix | Fixed |
| 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 install2. Set up your rules
cp rules.example.json rules.jsonOpen 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.shWindows:
scripts\launch_tv_debug.batLinux:
./scripts/launch_tv_debug_linux.shOr 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 briefMorning 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, Fibonacci, pitchforks, channels
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
Trade execution (consent-gated) — place/cancel/close orders in Trading Panel (paper or broker)
CLI access — every tool is also a
tvcommand, pipe-friendly JSON output
Trade Execution — Consent Model
This fork supports placing orders through the TradingView Trading Panel, for both paper trading and live broker integrations. Execution is gated behind an explicit consent parameter to prevent accidental triggering.
How the gate works
Every order-execution tool (trading_submit_order, trading_cancel_order, trading_close_position) requires consent: true as a parameter. The gate uses strict equality — 'true' (string), 1 (number), false, or a missing field will all be rejected with INVALID_INPUT before the tool touches CDP.
// ❌ REJECTED — no consent field
trading_submit_order({ side: 'buy', order_type: 'market', quantity: 0.1 })
// ❌ REJECTED — wrong type
trading_submit_order({ consent: 'true', side: 'buy', order_type: 'market', quantity: 0.1 })
// ✅ ALLOWED — explicit boolean true
trading_submit_order({ consent: true, side: 'buy', order_type: 'market', quantity: 0.1 })The gate applies equally to paper and live
There is no "paper trading is free pass" exemption. The reasoning: building the habit of explicit consent on paper trades means live trades aren't a new pattern — they're the same pattern against a different backend. The tool reports the active mode (paper, broker, not_connected, or unknown) in its response so you can verify before trusting the execution.
Use trading_detect_mode (no consent needed — it's read-only) to check which mode is active before submitting.
AI assistant behavior note
Some AI assistants have their own built-in policies against executing trades on a user's behalf, and may refuse to call these tools even with explicit consent. That's the assistant's prerogative — the tool itself is permission-granted by virtue of the consent parameter. If you hit that refusal, you can:
Use a different AI tool (Codex, a custom client) that is fine with it
Call the tool directly yourself
Review each order and execute manually via the Trading Panel
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" |
|
"What was my bias yesterday?" |
|
"What's on my chart?" |
|
"Give me a full analysis" |
|
"Switch to BTCUSD daily" |
|
"Write a Pine Script for..." |
|
"Start replay at March 1st" |
|
"Set up a 4-chart grid" |
|
"Draw a level at 94200" |
|
Tool Reference (81 MCP tools)
Morning Brief (new in this fork)
Tool | What it does |
| Scan watchlist, read indicators, return structured data for session bias. Reads |
| Save the generated brief to |
| Retrieve today's brief (or yesterday's if today not saved yet) |
Chart Reading
Tool | When to use | Output size |
| First call — get symbol, timeframe, all indicator names + IDs | ~500B |
| Read current RSI, MACD, BB, EMA values from all indicators | ~500B |
| Get latest price, OHLC, volume | ~200B |
| Get price bars. 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 |
| Horizontal price levels (support/resistance, session levels) |
| Text annotations + prices ("PDH 24550", "Bias Long") |
| Data tables (session stats, analytics dashboards) |
| Price zones as {high, low} pairs |
Always use study_filter to target a specific indicator: study_filter: "MyIndicator".
Chart Control
Tool | What it does |
| Change ticker (BTCUSD, AAPL, ES1!, NYMEX:CL1!) |
| Change resolution (1, 5, 15, 60, D, W, M) |
| Change style (Candles, HeikinAshi, Line, Area, Renko) |
| Add/remove indicators. Use full names: "Relative Strength Index" not "RSI" |
| Jump to a date (ISO: "2025-01-15") |
| Change indicator settings, show/hide |
Pine Script Development
Tool | Step |
| 1. Inject code into editor |
| 2. Compile with auto-detection + error check |
| 3. Read compilation errors if any |
| 4. Read log.info() output |
| 5. Save to TradingView cloud |
| Offline static analysis (no chart needed) |
| Server-side compile check (no chart needed) |
Replay Mode
Tool | Step |
| Enter replay at a date |
| Advance one bar |
| Auto-advance (set speed in ms) |
| Buy/sell/close positions |
| Check position, P&L, date |
| Return to realtime |
Multi-Pane, Alerts, Drawings, UI
Tool | What it does |
| Change grid: |
| Set symbol on any pane |
| Draw horizontal_line, trend_line, rectangle, text |
| Manage price alerts |
| Run action across multiple symbols/timeframes |
| Read/modify watchlist |
| Screenshot (regions: full, chart, strategy_tester) |
| 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 ticksFull command list: tv --help
Troubleshooting
Problem | Solution |
| TradingView isn't running with |
| TradingView isn't running or port 9222 is blocked |
MCP server not showing in Claude Code | Check |
| Run |
| Run |
| Add symbols to the |
Tools return stale data | TradingView still loading — wait a few seconds |
Pine Editor tools fail | Open Pine Editor panel first: |
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 evaluationNo 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.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ulianbass/tradingview-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server