TradingView MCP

TradingView MCP

A local-first MCP server providing market data, deterministic technical analysis, chart rendering, and optional TradingView Supercharts browser workflows via stdio and a loopback REST API.

Category
访问服务器

README

TradingView MCP

CI License: MIT Node.js 22+

A local-first Model Context Protocol server and loopback REST API for market data, deterministic technical analysis, chart rendering, and optional TradingView Supercharts browser workflows.

The server runs over stdio and starts its local viewer and Playwright browsers only when a tool needs them. High-level history and analysis tools close the managed browser automatically by default.

[!IMPORTANT] This is an independent open-source project. It is not affiliated with, sponsored by, or endorsed by TradingView. TradingView and Lightweight Charts are trademarks of TradingView, Inc. Users are responsible for complying with TradingView's terms, account permissions, exchange entitlements, and applicable data licenses.

Features

  • MCP tools for market discovery, quotes, OHLCV, analysis, and chart state
  • One-call official TradingView screenshots for an exact symbol, interval, and date range
  • One-call historical-date context with OHLCV, gaps, changes, volume, exported indicator fields, rolling performance, and technical analysis
  • Deterministic SMA, EMA, RSI, MACD, Bollinger Bands, ATR, trend, signal, and support/resistance calculations
  • Local Lightweight Charts viewer with PNG capture
  • CSV, inline OHLCV, demo data, and optional configured upstream support
  • Atomic indicator, level, custom-series, price-zone, and marker overlays
  • Opt-in Playwright workflows for account-authorized TradingView Supercharts navigation, CSV export, indicators, and screenshots
  • Compact MCP results by default so large OHLCV arrays do not consume model context unnecessarily
  • Loopback-only HTTP binding, path containment, input validation, credential filtering, and fail-closed browser checks

Architecture

MCP client -- stdio --+-- deterministic analysis and chart state
                      +-- on-demand local viewer / PNG capture
                      +-- optional on-demand TradingView browser

REST client -- loopback HTTP -- local viewer and compatible JSON endpoints

The local viewer is a deterministic rendering surface; it is not a clone of proprietary TradingView charting features. See the compatibility boundary.

Requirements

  • Node.js 22 or newer
  • npm
  • Chromium installed through Playwright when screenshot or browser tools are used

Install from source

git clone https://github.com/moeuu/tradingview-mcp.git
cd tradingview-mcp
npm ci
npx playwright install chromium
npm run build

For Linux CI or a machine without Chromium system dependencies:

npx playwright install --with-deps chromium

Connect an MCP client

TradingView MCP is client-independent. It uses the standard MCP stdio transport and does not call client-specific APIs. Any MCP client that can launch a local process can use:

node /absolute/path/to/tradingview-mcp/dist/mcp.js

Many desktop and editor clients use this common configuration shape:

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["/absolute/path/to/tradingview-mcp/dist/mcp.js"],
      "env": {
        "MARKET_CHART_PORT": "0",
        "MARKET_CHART_DATA_ROOT": "/absolute/path/to/tradingview-mcp/data"
      }
    }
  }
}

Adapt the outer configuration keys to your client if needed; the command, arguments, environment, and MCP protocol remain the same. Restart the client after changing its configuration. MARKET_CHART_PORT=0 selects an ephemeral viewer port and avoids a permanently listening service.

See MCP client setup and compatibility for transport behavior, lifecycle, and troubleshooting.

Recommended MCP workflow

  1. Call market_get_capabilities when provider availability is unclear.
  2. Use tradingview_get_day for comprehensive information about a symbol on a specific date.
  3. Use tradingview_capture_period for an official Supercharts PNG covering exact calendar dates.
  4. Use tradingview_analyze_symbol for one-call recent history plus deterministic analysis.
  5. Use tradingview_get_history when only recent history is needed.
  6. Use chart_import_csv or chart_set_data for local/user-provided data.
  7. Use chart_analyze, chart_apply_overlays, and chart_snapshot for local analysis and visualization.

Example calls:

{
  "name": "tradingview_capture_period",
  "arguments": {
    "symbol": "NASDAQ:AAPL",
    "interval": "D",
    "from": "2024-01-02",
    "to": "2024-03-28"
  }
}
{
  "name": "tradingview_get_day",
  "arguments": {
    "symbol": "NASDAQ:AAPL",
    "date": "2024-01-03",
    "interval": "D",
    "timezone": "America/New_York"
  }
}

tradingview_get_day returns an explicit no_session_bar status for weekends, holidays, and unavailable dates rather than silently substituting a nearby session. On a matching date it returns session OHLCV, previous and next bars when loaded, prior-close and open-gap changes, intraday range, rolling 5/20/50/200-period performance, deterministic indicators and signals, and every additional indicator column present in the official TradingView chart export. Set an intraday interval and includeBars:true to receive all exported bars assigned to that date. Day aggregation accepts daily bars and intraday intervals from 9 seconds through 24 hours; shorter seconds intervals could exceed the complete-session safety limit.

High-level TradingView tools close the browser by default. Set includeBars: true only when raw bars are required in the MCP response, and keepBrowserOpen: true only for immediate follow-up browser tools.

The server exposes both high-level and granular tools. Clients that support an enabled_tools allowlist can expose only the tools needed for a given workflow.

Optional TradingView browser workflow

Browser automation is disabled by default. A cookie export is the preferred authentication source because it can contain only the required session cookies. Never paste credential values into MCP arguments, repository files, client configuration, or prompts.

chmod 600 /absolute/path/to/tradingview-cookies.txt
export TRADINGVIEW_BROWSER_ENABLED=true
export TRADINGVIEW_BROWSER_BASE_URL=https://www.tradingview.com
export TRADINGVIEW_BROWSER_COOKIE_FILE=/absolute/path/to/tradingview-cookies.txt
export TRADINGVIEW_BROWSER_AUTH_COOKIE_NAMES=sessionid,sessionid_sign,device_t
export TRADINGVIEW_BROWSER_HEADLESS=true
export TRADINGVIEW_BROWSER_TIMEOUT_MS=120000

The authentication file must remain outside the repository, be smaller than 1 MiB, and have owner-only permissions on POSIX systems. The default policy imports only sessionid, sessionid_sign, and device_t from TradingView domains. Local storage is not imported by default. Cookie values, storage values, and authentication file paths are never accepted as MCP tool arguments or returned by MCP or REST responses.

A Playwright storage-state file can be used with TRADINGVIEW_BROWSER_AUTH_STATE when a cookie export is unavailable. The same cookie allowlist applies. Set TRADINGVIEW_BROWSER_AUTH_STORAGE_KEYS only when a verified workflow requires specific local-storage keys; its default is empty.

Supercharts UI availability, selectors, exports, account plans, exchange entitlements, and delayed/live status are controlled by TradingView and can change independently of this project. The automation never attempts an account upgrade or purchase.

See TradingView browser workflows for details and limitations.

Standalone REST API and viewer

The REST API is optional and does not need to run for normal MCP use.

npm run serve

It binds to 127.0.0.1:4317 by default:

curl http://127.0.0.1:4317/api/health
curl 'http://127.0.0.1:4317/api/price/DEMO:MARKET?timeframe=60&range=20'

Set a bearer token before enabling a paid/configured upstream or exposing sensitive local chart data to another local process:

export MARKET_CHART_API_TOKEN='replace-with-a-long-random-value'
npm run serve

HTTP binding is restricted to loopback addresses. See the REST API reference.

Configuration

Copy .env.example as a reference, but load real values from your shell, process manager, or secret store. The application does not automatically read .env files.

Variable Default Purpose
MARKET_CHART_HOST 127.0.0.1 Loopback bind address only
MARKET_CHART_PORT 4317 REST/viewer port; use 0 for an ephemeral MCP viewer
MARKET_CHART_DATA_ROOT ./data Contained CSV, export, and capture root
MARKET_CHART_API_TOKEN unset Optional REST bearer token
MARKET_CHART_SCREENSHOTS true Enable local viewer PNG capture
TRADINGVIEW_BROWSER_ENABLED false Enable Supercharts browser tools
TRADINGVIEW_BROWSER_BASE_URL https://www.tradingview.com Allowed TradingView origin
TRADINGVIEW_BROWSER_AUTH_STATE unset External Playwright storage-state path
TRADINGVIEW_BROWSER_COOKIE_FILE unset External cookie-export path
TRADINGVIEW_BROWSER_AUTH_COOKIE_NAMES sessionid,sessionid_sign,device_t Cookie-name allowlist; values stay in the external file
TRADINGVIEW_BROWSER_AUTH_STORAGE_KEYS empty Opt-in local-storage key allowlist
TRADINGVIEW_BROWSER_HEADLESS true Run managed Chromium headlessly
TRADINGVIEW_BROWSER_TIMEOUT_MS 30000 Browser operation timeout, 5-120 seconds
TRADINGVIEW_RAPIDAPI_KEY unset Optional compatible upstream key
TRADINGVIEW_RAPIDAPI_HOST provider default Optional compatible upstream host

Local CSV format

CSV imports must resolve inside MARKET_CHART_DATA_ROOT, contain ascending timestamps, and stay within configured limits.

time,open,high,low,close,volume
2026-01-02T00:00:00Z,100,104,99,103,1200000
2026-01-03T00:00:00Z,103,106,101,105,1350000

timestamp or date can replace time; Unix seconds and milliseconds are also accepted.

Security model

  • No network listener is created by an idle stdio MCP process.
  • Local HTTP routes bind only to loopback and validate the Host header.
  • Imported files use real-path containment and reject symlink traversal.
  • Browser authentication is read from one external owner-only file and filtered by domain, cookie name, expiry, size, and optional local-storage key allowlists.
  • MCP and REST request schemas do not accept cookies, tokens, storage state, or authentication file paths.
  • Browser operations serialize stateful UI work and reject credential-like tool inputs.
  • Generated browser artifacts, credentials, .env files, traces, and local market data are ignored by Git.
  • Results are analytical observations, not investment advice or a guarantee of future performance.

Please report vulnerabilities according to SECURITY.md.

Development

npm ci
npx playwright install chromium
npm run check

npm run check runs public-release safety checks, repository-wide English-only text validation, strict TypeScript checking, the full Vitest suite, and the production build.

Contributions are welcome; see CONTRIBUTING.md. By participating, you agree to follow CODE_OF_CONDUCT.md.

License and attribution

The project source is available under the MIT License. The bundled viewer uses TradingView Lightweight Charts under Apache-2.0; required notices are in NOTICE, THIRD_PARTY_LICENSES.md, and licenses/Apache-2.0.txt.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选