
MCP server for TradingView
概览
A Model Context Protocol (MCP) server that lets AI assistants interact with TradingView — real-time quotes, historical OHLCV data, screener, alerts, watchlists, news, chart layouts, Pine scripts, and more. Connect it to Claude Desktop, Cursor, or any MCP-compatible client and interact with TradingView using natural language. This project uses TradingView's internal, undocumented web API. It is not affiliated with or endorsed by TradingView. API endpoints may change without notice. Use in accordance with TradingView's Terms of Service. TradingView's web app communicates with its backend over a private REST API and a proprietary WebSocket protocol. This server: 1. using a headless Chromium browser (via Playwright) to replicate the normal login flow and obtain valid session cookies. 2. those cookies to disk so re-authentication only happens when the session expires (~25 days). 3.
README
以下为原文 README 节选,完整内容请查看原文。
tradingview-mcp
A Model Context Protocol (MCP) server that lets AI assistants interact with TradingView — real-time quotes, historical OHLCV data, screener, alerts, watchlists, news, chart layouts, Pine scripts, and more. Connect it to Claude Desktop, Cursor, or any MCP-compatible client and interact with TradingView using natural language.
Disclaimer: This project uses TradingView’s internal, undocumented web API. It is not affiliated with or endorsed by TradingView. API endpoints may change without notice. Use in accordance with TradingView’s Terms of Service.
How It Works
TradingView’s web app communicates with its backend over a private REST API and a proprietary WebSocket protocol. This server:
- Authenticates using a headless Chromium browser (via Playwright) to replicate the normal login flow and obtain valid session cookies.
- Persists those cookies to disk so re-authentication only happens when the session expires (~25 days).
- Exposes MCP tools that make authenticated HTTP requests to TradingView’s internal endpoints, plus a WebSocket connection for historical OHLCV data.
MCP Client (Claude, Cursor…)
│ MCP protocol (stdio)
▼
tradingview-mcp
│ HTTPS + session cookies WebSocket (OHLCV)
▼ ▼
tradingview.com REST API prodata.tradingview.com
Features
- Market Data — real-time quotes and detailed symbol info (P/E, EPS, beta, sector, 52-week range, etc.)
- Historical Data — OHLCV candles via TradingView’s WebSocket protocol
- Screener — filter stocks, crypto, and forex by price, fundamentals, and technicals
- Alerts — list and inspect price alerts
- Watchlists — list, create, rename, add/remove symbols, and delete watchlists
- News & Ideas — latest headlines per symbol, community ideas search, trending ideas
- Chart Layouts — list and inspect saved chart layouts
- Pine Scripts — list and retrieve source code for saved indicators and strategies
- Account — account details
- Session persistence — logs in once via headless browser, reuses cookies for subsequent runs
Installation
Option A — Docker (recommended)
No Node.js required. Uses the published multi-platform image (linux/amd64 + linux/arm64).
1. Authenticate once
docker run --rm \
-v tradingview-mcp-session:/data \
-e [email protected] \
-e TV_PASSWORD=yourpassword \
-e TV_SESSION_FILE=/data/.tv_session.json \
mikeh1975/tradingview-mcp:login
This runs a headless Chromium browser, logs into TradingView, and saves the session cookies to a named Docker volume. You only need to redo this when the session expires (~25 days).
2. Configure Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
安装
docker run --rm -i -v tradingview-mcp-session:/data -e TV_SESSION_FILE=/data/.tv_session.json mikeh1975/tradingview-mcp:latest配置
{
"mcpServers": {
"tradingview": {
"command": "docker",
"args": [
"run", "--rm", "-i",
"-v", "tradingview-mcp-session:/data",
"-e", "TV_SESSION_FILE=/data/.tv_session.json",
"mikeh1975/tradingview-mcp:latest"
]
}
}
}