MT

moondevonyt/trading-view-mcp-for-ai-by-moon-dev

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

99 stars 56 forks 质量 72 趋势 8NOASSERTION

为AI设计的交易视图MCP,这样你可以用AI在交易视图图表中构建任何内容

概览

告诉克劳德一个交易点子。看它出现在你的TradingView图表上。 这是在Chrome中驱动真实登录的TradingView图表。Claude编写Pine Script,编译检查,粘贴到Pine编辑器,添加到图表中,然后读取结果。从想法到图表不到3秒。 有的。TradingView 自家的 AI 产品(AI Chart Copilot)是一个封闭的 Chrome 扩展,每天最多 15 个请求,无法运行你的 Pine。GitHub 上其他所有 TradingView MCP 都通过 TradingView 的私有 HTTP API 读取市场数据。它们都不能在图表上放置自定义脚本。但这个可以,因为它驱动了实际页面。 - 任何必须接触真实图表的内容。- 用于验证。这意味着脚本在浏览器看到之前就已经被证明能编译出来,所以浏览器是你查看想法的地方,而不是调试的地方。 Chrome 实例是一个独立于 ,与日常 Chrome 分开。

概述(AI 翻译)

告诉克劳德一个交易点子。看它出现在你的TradingView图表上。

这是一个模型上下文协议服务器,驱动一个真实的、已登录的TradingView Chrome中的图表。Claude编写Pine Script,编译检查,粘贴到, Pine 编辑,把它添加到图表中,然后读回结果。不到3秒从 想法到图表。

没有官方的TradingView主计算平台。TradingView自有的AI产品(AI图表 Copilot)是一个封闭的Chrome扩展,每天最多15个请求,无法运行 你的Pine。GitHub上其他所有TradingView的MCP都会读取市场数据,而非TradingView的 私有HTTP API。他们都不能在图表上写自定义脚本。这个可以, 因为它推动了页面的生成。

由月亮开发🌙建造


它是如何运作的

故意设置两个通道:

  • Chrome DevTools 协议,适用于必须接触真实图表的内容。
  • **直接HTTPS调用TradingView自有的Pine编译器进行验证。此 意味着脚本被证明能在浏览器看到之前就已经编译完成,所以 浏览器是你看一个想法的地方,而不是调试它的地方。

Chrome 实例是一个专用配置文件,与日常 Chrome 分开。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

🌙 TradingView MCP

Tell Claude a trading idea. Watch it appear on your TradingView chart.

This is a Model Context Protocol server that drives a real, logged-in TradingView chart in Chrome. Claude writes the Pine Script, compile-checks it, pastes it into the Pine Editor, adds it to the chart, and reads the result back. Under 3 seconds from idea to chart.

There is no official TradingView MCP. TradingView’s own AI product (AI Chart Copilot) is a closed Chrome extension capped at 15 requests a day and it cannot run your Pine. Every other TradingView MCP on GitHub reads market data over TradingView’s private HTTP API. None of them can put a custom script on a chart. This one can, because it drives the actual page.

Built by Moon Dev 🌙


How it works

Claude    tradingview_mcp  ──CDP──>  Chrome tab on tradingview.com
                                │
                                └──HTTPS──>  pine-facade.tradingview.com
                                             (compile-check, no browser)

Two channels, on purpose:

  • Chrome DevTools Protocol for anything that has to touch the real chart.
  • A direct HTTPS call to TradingView’s own Pine compiler for validation. This means a script is proven to compile before the browser ever sees it, so the browser is where you look at an idea, not where you debug it.

The Chrome instance is a dedicated profile, separate from your everyday Chrome. Running your main browser with remote debugging open would let any local process read your logged-in sessions. This one only ever holds TradingView.


Quick start

You need Python 3.10+, Chrome, and a TradingView account (free tier is fine).

Step 1 — Install

cd tradingview_mcp
pip install -r requirements.txt
cp .env.example .env

You do not need to edit .env. The defaults work.

Step 2 — Log into TradingView, one time

⚠️ Close any other TradingView window or tab before this. TradingView allows one active session per account. A second one kicks the first with a “Session disconnected” popup.

python -m tradingview_mcp.chrome_launcher

A new Chrome window opens on TradingView. This is a dedicated profile, separate from your everyday Chrome, so your other logins are never exposed to the debug port.

👉 Log into TradingView in that window, then leave it open. The login persists, so you only do this once.

You should see:

🌙 Moon Dev: launching dedicated Chrome → profile at /Users/you/.tradingview_mcp_chrome
🌙 Moon Dev: Chrome CDP ready on port 9222

Step 3 — Put your first indicator on the chart

Leave that Chrome window open. Open a second terminal, cd into this folder again, and run:

cd tradingview_mcp
python mount_pine.py examples/moon_dev_rainbow_ribbon_10_50.pine
🌙 Moon Dev — mounting moon_dev_rainbow_ribbon_10_50.pine (6247 bytes)
  1. compile-check (no browser)     290 ms   valid=True
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "tradingview": { "command": "python", "args": ["-m", "tradingview_mcp.server"], "cwd": "/full/path/to/tradingview_mcp" } } }