tradesdontlie / tradingview-mcp
TradingView MCP Bridge
TradingView MCP Bridge is a personal AI assistant for your TradingView Desktop charts. It connects Claude Code to your locally running TradingView app via the Chrome DevTools Protocol, enabling AI-assisted chart analysis, Pine Script development, and workflow automation. TradingView MCP Bridge 是您 TradingView 桌面版图表的个人 AI 助手。它通过 Chrome DevTools 协议将 Claude Code 连接到您本地运行的 TradingView 应用程序,从而实现 AI 辅助的图表分析、Pine Script 开发和工作流自动化。
Warning: This tool is not affiliated with, endorsed by, or associated with TradingView Inc. It interacts with your locally running TradingView Desktop application via Chrome DevTools Protocol. Review the Disclaimer before use. 警告: 本工具与 TradingView Inc. 无关,未获得其认可或关联。它通过 Chrome DevTools 协议与您本地运行的 TradingView 桌面应用程序进行交互。使用前请阅读免责声明。
Important: Requires a valid TradingView subscription. This tool does not bypass or circumvent any TradingView paywall or access control. It reads from and controls the TradingView Desktop app already running on your machine. 重要提示: 需要有效的 TradingView 订阅。本工具不会绕过或规避任何 TradingView 的付费墙或访问控制。它仅读取并控制您机器上已运行的 TradingView 桌面应用程序。
Note: All data processing occurs locally on your machine. No TradingView data is transmitted, stored, or redistributed externally by this tool. 注意: 所有数据处理均在您的本地机器上进行。本工具不会向外部传输、存储或重新分发任何 TradingView 数据。
Caution: This tool accesses undocumented internal TradingView APIs via the Electron debug interface. These can change or break without notice in any TradingView update. Pin your TradingView Desktop version if stability matters to you. 谨慎: 本工具通过 Electron 调试接口访问未公开的 TradingView 内部 API。这些 API 可能会在任何 TradingView 更新中发生变化或失效。如果您对稳定性有要求,请锁定您的 TradingView 桌面版版本。
How It Works (and why it’s safe to run)
工作原理(以及为什么它是安全的)
This tool does not connect to TradingView’s servers, modify any TradingView files, or intercept any network traffic. It communicates exclusively with your locally running TradingView Desktop instance via Chrome DevTools Protocol (CDP) — a standard debugging interface built into all Chromium/Electron applications by Google, including VS Code, Slack, and Discord. The debug port is disabled by default and must be explicitly enabled by you using a standard Chromium flag (--remote-debugging-port=9222). Nothing happens without that deliberate step.
本工具不会连接到 TradingView 的服务器,不会修改任何 TradingView 文件,也不会拦截任何网络流量。它仅通过 Chrome DevTools 协议 (CDP) 与您本地运行的 TradingView 桌面实例通信——这是 Google 内置于所有 Chromium/Electron 应用程序(包括 VS Code、Slack 和 Discord)中的标准调试接口。调试端口默认是禁用的,必须由您使用标准的 Chromium 标志 (--remote-debugging-port=9222) 显式启用。如果不执行这一刻意步骤,将不会发生任何操作。
What This Tool Does Not Do
本工具不具备的功能
- Connect to TradingView’s servers or APIs
- Store, transmit, or redistribute any market data
- Work without a valid TradingView subscription and installed Desktop app
- Bypass any TradingView paywall or access restriction
- Execute real trades (chart interaction only)
- Work if TradingView changes their internal Electron structure
- 连接到 TradingView 的服务器或 API
- 存储、传输或重新分发任何市场数据
- 在没有有效 TradingView 订阅和已安装桌面应用的情况下工作
- 绕过任何 TradingView 付费墙或访问限制
- 执行真实交易(仅限图表交互)
- 在 TradingView 更改其内部 Electron 结构时工作
Research Context
研究背景
This project explores an open research question: how can LLM-based agents interact with professional trading interfaces to support human decision-making? Specifically it investigates: 本项目旨在探索一个开放的研究课题:基于 LLM 的智能体如何与专业交易界面交互以支持人类决策?具体研究内容包括:
- 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 (e.g. interpreting Pine Script output, reading indicator tables)
- Whether natural language is an effective interface for chart navigation and Pine Script development
- The failure modes of LLM agents operating in real-time data environments
- 结构化工具 API (MCP) 如何连接 LLM 与有状态的桌面金融应用程序
- 当智能体在实时图表数据上操作时,会出现哪些延迟、上下文和可靠性限制
- 智能体如何处理模糊的金融 UI 状态(例如解释 Pine Script 输出、读取指标表格)
- 自然语言是否是图表导航和 Pine Script 开发的有效界面
- LLM 智能体在实时数据环境中运行时的故障模式
This is not a trading bot. It is an interface layer that makes a trading application legible to an LLM agent, allowing researchers and developers to study human-AI collaboration in financial workflows. See RESEARCH.md for open questions, findings, and related work.
这不是一个交易机器人。它是一个接口层,使交易应用程序能够被 LLM 智能体识别,从而允许研究人员和开发人员研究金融工作流中的人机协作。有关开放问题、发现和相关工作,请参阅 RESEARCH.md。
Prerequisites
前置条件
- TradingView Desktop app (paid subscription required for real-time data)
- Node.js 18+
- Claude Code with MCP support (for MCP tools) or any terminal (for CLI)
- macOS, Windows, or Linux
- TradingView 桌面应用程序(实时数据需要付费订阅)
- Node.js 18+
- 支持 MCP 的 Claude Code(用于 MCP 工具)或任何终端(用于 CLI)
- macOS, Windows 或 Linux
What It Does
功能概览
- Pine Script development — write, inject, compile, debug, and iterate on scripts with AI assistance
- Chart navigation — change symbols, timeframes, zoom to dates, add/remove indicators
- Visual analysis — read your chart’s indicator values, price levels, and annotations
- Draw on charts — trend lines, horizontal lines, rectangles, text annotations
- Manage alerts — create, list, and delete price alerts
- Replay practice — step through historical bars, practice entries/exits
- Screenshots — capture chart state for AI visual analysis
- Multi-pane layouts — set up 2x2, 3x1, etc. grids with different symbols per pane
- Monitor your chart — stream JSONL from your locally running chart for local monitoring scripts
- CLI access — every MCP tool is also a
tvCLI command, pipe-friendly with JSON output - Launch TradingView — auto-detect and launch with debug mode from any platform
- Pine Script 开发 — 在 AI 辅助下编写、注入、编译、调试和迭代脚本
- 图表导航 — 更改交易品种、时间周期、缩放至特定日期、添加/删除指标
- 视觉分析 — 读取图表的指标值、价格水平和注释
- 图表绘图 — 趋势线、水平线、矩形、文本注释
- 管理警报 — 创建、列出和删除价格警报
- 回放练习 — 逐步查看历史 K 线,练习入场/出场
- 截图 — 捕获图表状态以供 AI 进行视觉分析
- 多窗格布局 — 设置 2x2、3x1 等网格,每个窗格显示不同品种
- 监控图表 — 从本地运行的图表流式传输 JSONL,用于本地监控脚本
- CLI 访问 — 每个 MCP 工具也是一个
tvCLI 命令,支持管道操作和 JSON 输出 - 启动 TradingView — 在任何平台上自动检测并以调试模式启动
Install with Claude Code
使用 Claude Code 安装
Paste this into Claude Code and it will handle the rest: 将此内容粘贴到 Claude Code 中,它将处理其余步骤:
Install the TradingView MCP server. Clone
https://github.com/tradesdontlie/tradingview-mcp.git, runnpm install, add it to my MCP config at~/.claude/.mcp.json, and launch TradingView with the debug port. Then verify the connection withtv_health_check. Or follow the manual steps below. 安装 TradingView MCP 服务器。克隆https://github.com/tradesdontlie/tradingview-mcp.git,运行npm install,将其添加到我的~/.claude/.mcp.jsonMCP 配置中,并使用调试端口启动 TradingView。然后使用tv_health_check验证连接。或者按照下面的手动步骤操作。
Quick Start
快速开始
1. Install 1. 安装
git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp
npm install
2. Launch TradingView with CDP 2. 使用 CDP 启动 TradingView
TradingView Desktop must be running with Chrome DevTools Protocol enabled on port 9222. TradingView 桌面版必须在启用 Chrome DevTools 协议且端口为 9222 的情况下运行。
- Mac:
./scripts/launch_tv_debug_mac.sh - Windows:
scripts\launch_tv_debug.bat - Linux:
./scripts/launch_tv_debug_linux.sh
Or launch manually on any platform:
或者在任何平台上手动启动:
/path/to/TradingView --remote-debugging-port=9222
Or use the MCP tool (auto-detects your install):
或者使用 MCP 工具(自动检测您的安装):
"Use tv_launch to start TradingView in debug mode"
3. Add to Claude Code 3. 添加到 Claude Code
Add to your Claude Code MCP config (~/.claude/.mcp.json or project .mcp.json):
添加到您的 Claude Code MCP 配置 (~/.claude/.mcp.json 或项目 .mcp.json):
{
"mcpServers": {
"tradingview": {
"command": "node",
"args": ["/path/to/tradingview-mcp/src/server.js"]
}
}
}
Replace /path/to/tradingview-mcp with your actual path.
将 /path/to/tradingview-mcp 替换为您实际的路径。
4. Verify 4. 验证
Ask Claude: “Use tv_health_check to verify TradingView is connected” 询问 Claude:“Use tv_health_check to verify TradingView is connected”
CLI
命令行界面
Every MCP tool is also accessible as a tv CLI command. All output is JSON for piping with jq.
每个 MCP 工具也可以作为 tv CLI 命令访问。所有输出均为 JSON 格式,方便使用 jq 进行管道处理。
# Install globally (optional)
npm link
# Or run directly
node src/cli/index.js <command>
Quick Examples 快速示例
tv status# check connection / 检查连接tv quote# current price / 当前价格tv symbol AAPL# change symbol / 更改品种tv ohlcv --summary# price summary / 价格摘要tv screenshot -r chart# capture chart / 捕获图表tv pine compile# compile Pine Script / 编译 Pine Scripttv pane layout 2x2# 4-chart grid / 4 图表网格tv pane symbol 1 ES1!# set pane symbol / 设置窗格品种tv stream quote | jq '.close'# monitor price changes / 监控价格变化
All Commands 所有命令
tv status / launch / state / symbol / timeframe / type / info / search
tv quote / ohlcv / values
tv data lines/label