tradingview-desktop-mcp
Controls the TradingView Desktop app via MCP, allowing AI agents to manage charts, indicators, Pine Script strategies, and optionally mirrors signals to MetaTrader 5 for automated trading.
README
tradingview-desktop-mcp
Control the TradingView Desktop app (Windows) from any MCP-compatible AI agent — Claude Code, Claude Desktop, OpenAI Codex CLI, Cursor, and others. Includes an optional MetaTrader 5 MCP server and a signal bridge that mirrors chart indicator signals as MT5 orders.
Ask your agent things like "switch the chart to BTCUSDT on 15m and show me a screenshot", "add an RSI", "write this Pine strategy and run it", or "what does the Strategy Tester report say?" — and watch it happen in the real TradingView app.
How it works
TradingView Desktop is an Electron app. Launched with --remote-debugging-port=9222, it exposes the Chrome DevTools Protocol (CDP). The chart page contains TradingView's full internal Charting Library API (window.TradingViewApi), which these servers drive over a local websocket:
┌──────────────┐ MCP (stdio) ┌─────────────┐ CDP ws://127.0.0.1:9222 ┌─────────────────┐
│ Claude/Codex │ ◄─────────────► │ server.py │ ◄─────────────────────────► │ TradingView app │
└──────────────┘ └─────────────┘ └─────────────────┘
┌──────────────┐ MCP (stdio) ┌──────────────┐ MetaTrader5 pkg ┌─────────────────┐
│ Claude/Codex │ ◄─────────────► │ mt5_server.py│ ◄────────────────────────► │ MT5 terminal │
└──────────────┘ └──────────────┘ └─────────────────┘
No TradingView account API, no scraping, no browser extension — it talks to the app you already have open, with your session and your saved charts.
Requirements
- Windows 10/11 (TradingView Desktop + the
MetaTrader5package are Windows-only) - TradingView Desktop (Microsoft Store or installer version — both auto-detected)
- Python 3.10+
- For the MT5 parts: any MT5 desktop terminal (MetaQuotes, Pepperstone, IC Markets, …) installed and logged in. The MT5 web terminal and mobile apps are not supported — they have no local API.
Install
git clone https://github.com/Unjoselo/tradingview-desktop-mcp
cd tradingview-desktop-mcp
pip install -r requirements.txt
Register the servers in your client
Claude Code
claude mcp add tradingview -- python C:/path/to/tradingview-desktop-mcp/server.py
claude mcp add mt5 -- python C:/path/to/tradingview-desktop-mcp/mt5_server.py
Claude Desktop
%APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"tradingview": {
"command": "python",
"args": ["C:/path/to/tradingview-desktop-mcp/server.py"]
},
"mt5": {
"command": "python",
"args": ["C:/path/to/tradingview-desktop-mcp/mt5_server.py"]
}
}
}
OpenAI Codex CLI
~/.codex/config.toml:
[mcp_servers.tradingview]
command = "python"
args = ["C:/path/to/tradingview-desktop-mcp/server.py"]
[mcp_servers.mt5]
command = "python"
args = ["C:/path/to/tradingview-desktop-mcp/mt5_server.py"]
Cursor
.cursor/mcp.json in your project (or ~/.cursor/mcp.json globally) — same JSON shape as Claude Desktop.
TradingView tools (server.py)
| Tool | Description |
|---|---|
tv_status |
App running? CDP connected? Current symbol/timeframe/layout |
tv_launch |
Start TradingView with the CDP port (detects the no-port case) |
tv_screenshot |
PNG of the chart (returned as image + saved file path) |
tv_get_chart |
Symbol, resolution, chart type, visible range, studies |
tv_set_symbol |
Change symbol (OANDA:XAUUSD, BINANCE:BTCUSDT, NASDAQ:AAPL…) |
tv_set_resolution |
Change timeframe (1, 5, 15, 60, 240, 1D, 1W…) |
tv_list_studies |
Indicators/strategies on the chart (id + name) |
tv_add_study / tv_remove_study |
Add built-in indicators by name / remove by id |
tv_strategy_report |
Strategy Tester report of the active strategy |
tv_pine_open_editor / tv_pine_set_script / tv_pine_add_to_chart |
Write Pine Script code and compile it onto the chart |
tv_close_popups |
Dismiss plan-limit/promo dialogs |
tv_eval_js |
Run arbitrary JS in the chart page (escape hatch — TradingViewApi is all yours) |
Environment variables: TV_CDP_PORT (default 9222), TV_EXE_PATH (default: auto-discover Store/installer paths).
MetaTrader 5 tools (mt5_server.py)
| Tool | Description |
|---|---|
mt5_status |
Server, login, demo/real, balance, equity, margin |
mt5_symbol_info |
Bid/ask, spread, contract size, lot limits |
mt5_candles |
Last N OHLCV candles (M1…MN1) — last candle is still forming |
mt5_positions |
Open positions, filterable by symbol/magic |
mt5_order_open |
Market order with optional SL/TP — demo-only by default |
mt5_close |
Close by ticket/symbol/magic (refuses to close everything blindly) |
mt5_history |
Closed deals + realized P&L for the last N days |
Environment variables: MT5_TERMINAL_PATH (default: auto-detect), MT5_ALLOW_REAL=1 to enable trading tools on real accounts (off by default, on purpose).
Signal bridge (signal_bridge.py)
Standalone daemon (not an MCP server — a trading loop should not live inside a chat session). It reads the BUY/SELL shapes any indicator paints on the chart and mirrors them in MT5 with stop-and-reverse semantics, acting on closed bars only (no intrabar repaint trades).
# 1. find your indicator's study id and shape plot indexes
python signal_bridge.py --list-studies
# 2. dry-run: print the signals it would read
python signal_bridge.py --study Dl3pBC --once
# 3. verify the full pipeline with a tiny demo round-trip (opens & closes 0.01)
python signal_bridge.py --study Dl3pBC --test
# 4. run it
python signal_bridge.py --study Dl3pBC --symbol XAUUSD --lot 0.01
Every action is logged to bridge_trades.csv. The bridge tags its positions with its own magic number (--magic) and never touches anything else.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
403 Forbidden on the CDP websocket |
Chrome rejects the Origin header. Already handled (suppress_origin); if you connect with your own tooling, strip the Origin header or launch with --remote-allow-origins=* |
tv_launch says the app runs without the port |
Electron's single-instance lock ignores flags on a second launch. Close TradingView fully, then tv_launch again |
| Studies vanish from the chart | TradingView's free (Basic) plan enforces an indicator limit per chart and may remove extras. The gopro popup announces it; tv_close_popups dismisses it |
exportData is not supported |
The desktop build disables OHLC export. Use mt5_candles or any other data source |
| Study ids change | Ids are regenerated when an indicator is re-added. Re-run --list-studies and update --study |
mt5.initialize failed |
Terminal not running/logged in, or auto-detect picked the wrong one — set MT5_TERMINAL_PATH |
Security notes
- The CDP port gives full control of the TradingView app and its logged-in session to any local process. The servers bind to
127.0.0.1only; don't expose the port beyond localhost. - MT5 trading tools are demo-only by default. Enabling
MT5_ALLOW_REAL=1is your decision and your risk. - This project is not affiliated with TradingView or MetaQuotes. It drives undocumented internal APIs that may break with any app update.
- Nothing here is financial advice. Signals mirrored by the bridge are only as good as the indicator that paints them — backtest before you trust anything with money, even demo money.
Quickstart en español
pip install -r requirements.txt- Registrá los servers en tu cliente (ver arriba — Claude Code, Claude Desktop, Codex CLI o Cursor).
- Pedile a tu agente: "lanzá TradingView" (usa
tv_launch), "mostrame el chart", "cambiá a XAUUSD en 5m", "agregá un RSI", "escribí esta estrategia en Pine". - Para el puente de señales a MT5:
python signal_bridge.py --list-studiespara encontrar el id de tu indicador, después--once(leer),--test(prueba en demo) y sin flags (daemon). Solo opera cuentas demo salvo--allow-real.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。