Skip to main content
Glama
tradingview-mcp

tradingview-mcp

by Miha21222

tradingview-mcp

为 AI 智能体提供以 TradingView 为核心的交易工具包的 MCP 服务器:筛选器查询、历史外汇数据,以及——随着里程碑落地——SMC/ICT 形态扫描、带标记的图表渲染、回测、Pine 工具,以及一整套配套的 Agent Skills。

与 TradingView, Inc. 无关联。"TradingView"、"Pine Script" 和 "Lightweight Charts" 是 TradingView, Inc. 的商标。

状态

M0-M5 已完成:服务器以 public/data 默认值启动;可选工具集包括 SMC 扫描、图表渲染、回测、FX Replay 日志同步、TradingView 账户数据(session)、Pine 编译、Desktop CDP(截图、导航、在实时图表上绘制、读取用户自己的指标——绘图值和 Pine 绘制的 FVG/OB 区域),以及声明式策略。附带一个 tv CLI(每个工具 = 一个输出 JSON 的子命令)、10 个配套技能,以及一个经过验证的 Claude Code 插件清单。未完成事项:M1 的信任门仍在等待所有者真实的手工标注 SMC 设置;webhook 接收器、MCP Apps 和沙箱化 Python 策略逃生通道被推迟。路线图:docs/PLAN.md。

Related MCP server: TradingView MCP Jackson

作为 Claude Code 插件安装

/plugin marketplace add Miha21222/tradingview-mcp
/plugin install tradingview-mcp@tradingview-mcp-marketplace

安装时会提示输入可选凭据(OANDA 练习密钥、TradingView sessionid)和操作员设置(TV_TOOLSETS、TV_READ_ONLY 等)——默认的 public,data 界面不需要任何内容,无需 TradingView 账户即可使用。需要 PATH 上有 uv。

快速开始

uv sync
uv run python -m tvmcp --check    # list registered tools
uv run python -m tvmcp            # run on stdio
uv run tv --check                 # CLI: list tools
uv run tv tv_data_get_bars '{"symbol":"EURUSD","count":10}'   # CLI: call any tool -> JSON

可选的 chart 工具集通过无头 Chromium 渲染;如果启用,请运行一次 uv run playwright install chromium。通过 TV_TOOLSETS=default,scan,chart,backtest,journal 启用可选工具集。

Claude Code:当你信任该项目时,仓库的 .mcp.json 会自动注册服务器。

配置(环境变量)

变量

默认值

含义

TV_TOOLSETS

default (= public,data)

逗号分隔列表;all 启用所有功能。可选:scan(SMC 扫描)、chart(PNG 渲染)、backtest、journal、pine(编译/类型检查)、strategy(声明式 YAML 规范)、session(TV 账户数据,有 ToS 风险)、desktop(通过 CDP 连接 TradingView Desktop,有 ToS 风险)

TV_READ_ONLY

off

1 = 可写入的工具永远不会注册(优先于一切)

TV_CACHE_DIR

~/.tvmcp/cache

Parquet OHLCV 缓存

TV_CHART_DIR

~/.tvmcp/charts

渲染的 PNG 输出(受管理、防冲突的文件名)

TV_JOURNAL_DIR

~/.tvmcp/journal

用于 tv_journal_scan / tv_journal_parse 的 FX Replay CSV 监视文件夹

TV_STRATEGY_DIR

~/.tvmcp/strategies

用于 tv_strategy_list / tv_strategy_run 的 YAML 策略规范

TV_SESSIONID

—

你的 TradingView sessionid cookie 是可选 session 工具集的门槛(有 ToS 风险;见下文)。实时获取可用:cookie 会交换为 websocket JWT 并馈送给 tvdatafeed-enhanced

TV_CDP_URL

http://127.0.0.1:9222

可选 desktop 工具集的 TradingView Desktop CDP 地址(通过 scripts/start-tv-desktop.ps1 启动,默认端口为 9223——请将此变量设置为匹配值;另一个 CDP 应用可能占用 9222)

TV_MAX_BARS

5000

每次响应的 K 线数量硬上限

OANDA_API_KEY

—

免费的练习账户密钥可启用 OANDA 提供商

OANDA_ENV

practice

practice 或 live

运行 uv run tv tv_setup_doctor 检查所有先决条件——每个失败的检查都会返回确切的修复命令。

TradingView 服务条款

默认工具集不使用 TradingView 账户:public 工具集与 TradingView 的公共筛选器端点通信,市场数据来自 Dukascopy/OANDA。TradingView 的 ToS 禁止自动数据收集和非展示性使用其数据;可选的 session 和 desktop 工具集(默认关闭)与你自己的 TradingView 账户/桌面应用交互,风险自负——启用它们是你的明确选择,可能违反 TradingView 的 ToS 并面临账户限制风险。两者在首次使用时都会向 stderr 打印 ToS/封禁警告。本项目仅用于个人研究/教育。

许可证

MIT——见 LICENSE。与 TradingView, Inc. 无关联;受保护/仅限邀请的 Pine 脚本仍归其作者所有——研究工具只读取你自己图表上指标的渲染输出,绝不读取其源代码。

Available Tools

6 tools
tv_data_get_barsA
Read-only

Fetch historical OHLCV bars. Cached in Parquet; repeat queries are instant.

Providers: dukascopy (free, deep history to ~2000s, first fetch of a range is slow) and oanda (real broker mid prices, needs OANDA_API_KEY). Bars are UTC, returned as arrays [time_iso, open, high, low, close, volume]. The provider field in the result names the feed - feeds disagree; levels are feed-specific.

Inputs: symbol (required), end, count, start, +2 more. Returns: object

tv_data_providers_statusA
Read-only

Which OHLCV data providers are usable right now, and why not if not.

Inputs: no named parameters. Returns: object

tv_screener_runA
Read-only

Run a TradingView screener query (unauthenticated scanner, ~3000 fields).

Use for: ranking/filtering instruments by indicator or fundamental values, finding oversold pairs, volume leaders, etc. US-equity quotes are 15-min delayed; forex/crypto are near-realtime. Timeframe-scoped fields take a suffix, e.g. 'RSI|15' for M15 RSI.

Inputs: limit, market, columns, filters, +1 more. Returns: object

tv_setup_doctorA
Read-only

Diagnose this install: check every prerequisite, return exact fixes.

Each check reports {name, ok, detail, optional} and - when broken - a fix holding the exact shell command to run. Run the fixes for anything with ok=false and optional=false, rerun the doctor, and the server is fully operational. Credential checks (OANDA key, TV session cookie) are optional and always require the human - never attempt to obtain credentials.

Inputs: no named parameters. Returns: object

tv_ta_summaryA
Read-only

Technical-analysis summary per symbol: overall/MA/oscillator ratings plus RSI and close.

Ratings are TradingView's precomputed Recommend.* fields mapped to STRONG_BUY..STRONG_SELL. Use for a quick bias read, not as a trade signal.

Inputs: symbols (required), market, timeframe. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool targets a distinct surface—screening, TA ratings, symbol lookup, install diagnostics, provider health, and OHLCV data—so most are unambiguous. The two diagnostic tools have some overlap around environment/credential health but are separated by install prerequisites versus current data-feed availability.

    Naming Consistency3/5

    All names share a tv_ prefix and snake_case, but the internal pattern is mixed: action-style names like tv_screener_run and tv_data_get_bars sit beside noun-style names like tv_ta_summary, tv_symbol_search, tv_setup_doctor, and tv_data_providers_status. A consistent verb_noun or noun_verb pattern would make the set more predictable.

    Tool Count5/5

    Six tools is well-scoped for a TradingView-oriented data server: screening, symbol discovery, technical summaries, historical bars, and health diagnostics each have a home. No tool feels redundant, and the count is neither thin nor bloated.

    Completeness4/5

    Core workflows are covered: find symbols, screen/filter, get TA reads, and pull OHLCV bars, plus status and diagnostic tools. Minor gaps exist—such as no direct single-symbol quote tool separate from bars/screener and no explicit indicator-value fetch beyond the TA summary—but agents can work around these.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to interact with TradingView Desktop via Chrome DevTools Protocol for automated morning briefs, chart analysis, Pine script development, and trading workflows.
      88 npm
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to read and control TradingView Desktop charts in real time, supporting chart analysis, Pine Script development, alerts, replay practice, and multi-pane automation.
      1
      MIT