TradingView MCP Server
Fetches TradingView chart snapshots as images using headless Playwright browser automation with session-cookie authentication. Exposes a tool to capture a chart for a given symbol (EXCHANGE:SYMBOL) with configurable timeframe (1m to monthly), image width/height and dark or light theme, plus tools to validate the TradingView session credentials and list the available timeframes.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
TradingView MCP Server š
A lightweight Model Context Protocol (MCP) server for fetching TradingView chart snapshots. Uses Playwright for efficient browser automation with persistent sessions and cookie-based authentication.
Note: This uses Playwright because TradingView renders charts client-side with JavaScript/Canvas. There is no pure HTTP API for chart images. This is the lightest possible working solution (~150MB RAM vs ~500MB with Selenium).
⨠Features
šŖ¶ Lightweight: Playwright in headless mode (~150MB vs ~500MB with Selenium)
š Fast: Persistent browser reuse, 3-5 seconds per chart
š Secure: Session-based authentication via cookies
šØ Customizable: Configure chart dimensions, intervals, and themes
š§ MCP Compatible: Works with any MCP-enabled client (Claude Desktop, etc.)
ā»ļø Efficient: Reuses browser instances across multiple requests
Related MCP server: tradingview-chart-mcp
š Prerequisites
Python 3.10 or higher
A TradingView account (free or paid)
TradingView session cookies
Table of Contents
š Installation
1. Clone the repository
git clone https://github.com/yourusername/tradingview-mcp.git
cd tradingview-mcp2. Create a virtual environment
# Windows
python -m venv venv
.\venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activate3. Install dependencies
pip install -r requirements.txt
# Install Playwright browsers (one-time setup, ~150MB download)
python -m playwright install chromium4. Configure credentials
Copy
.env.exampleto.env:# Windows copy .env.example .env # Linux/Mac cp .env.example .envGet your TradingView session cookies:
Log into TradingView in your browser
Press F12 to open Developer Tools
Go to Application tab (Chrome) or Storage tab (Firefox)
Navigate to Cookies >
https://www.tradingview.comFind and copy these two cookie values:
sessionidā Copy the entire valuesessionid_signā Copy the entire value
ā ļø Important: Copy the full values including any special characters (slashes, equals signs, etc.). Don't add quotes or extra spaces.
Edit
.envand paste your values:TRADINGVIEW_SESSION_ID=your_actual_session_id_here TRADINGVIEW_SESSION_ID_SIGN=your_actual_session_id_sign_hereExample (with fake values):
TRADINGVIEW_SESSION_ID=47zlhkbl2weohrhmjgufeg1o24droaod TRADINGVIEW_SESSION_ID_SIGN=v3:6S2OD9ta349/yqN0RdCeK3UKxTl/tJr4AOoPRUa0Crk=
5. Test your setup (Optional but recommended)
Create a test file test.py:
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from dotenv import load_dotenv
load_dotenv()
from tradingview_mcp.server import get_chart_snapshot
async def test():
image = await get_chart_snapshot("BINANCE:BTCUSDT", "D", 1200, 600, "dark")
if image:
Path("test_chart.png").write_bytes(image)
print(f"ā
Success! Chart saved to test_chart.png ({len(image)} bytes)")
else:
print("ā Failed to fetch chart")
asyncio.run(test())Run it:
python test.pyIf successful, you'll see test_chart.png with a Bitcoin chart!
šÆ Usage
Quick Start - Testing Locally
After installation, test the server:
python src/tradingview_mcp/server.pyThe server will start and wait for MCP client connections via stdio.
Configuration for Claude Desktop
Add this to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Option 1: Using .env file (Recommended)
{
"mcpServers": {
"tradingview": {
"command": "python",
"args": ["C:\\path\\to\\tradingview-mcp\\src\\tradingview_mcp\\server.py"],
"cwd": "C:\\path\\to\\tradingview-mcp"
}
}
}Option 2: Inline credentials
{
"mcpServers": {
"tradingview": {
"command": "python",
"args": ["C:\\path\\to\\tradingview-mcp\\src\\tradingview_mcp\\server.py"],
"env": {
"TRADINGVIEW_SESSION_ID": "your_session_id",
"TRADINGVIEW_SESSION_ID_SIGN": "your_session_id_sign"
}
}
}
}š” Tip: Use absolute paths. On Windows, use double backslashes
\\or forward slashes/.
Restart Claude Desktop and you'll see the TradingView tools available!
Example Queries in Claude
Once configured, you can ask Claude:
- "Get me a daily chart of Bitcoin"
- "Show me AAPL on 1-hour timeframe"
- "Fetch a weekly chart for NASDAQ:TSLA with light theme"
- "Get BINANCE:ETHUSDT 5-minute chart"
- "Validate my TradingView session"
- "What timeframes are available?"š ļø Available Tools
1. get_chart_snapshot
Fetch a TradingView chart snapshot.
Parameters:
symbol(required): Trading pair in TradingView formatExamples:
"BINANCE:BTCUSDT","NASDAQ:AAPL","BITSTAMP:BTCUSD"
interval(optional): Chart timeframe (default:"D")Minutes:
"1","5","15","30","60","240"Days/Weeks/Months:
"D","W","M"
width(optional): Image width in pixels (default:1200)height(optional): Image height in pixels (default:600)theme(optional):"dark"or"light"(default:"dark")
Example:
Get me a daily chart of Bitcoin on Binance2. validate_session
Check if your TradingView session credentials are valid.
Example:
Validate my TradingView session3. list_timeframes
List all available chart timeframes/intervals.
Example:
What timeframes are available?š Symbol Format
TradingView uses the format: EXCHANGE:SYMBOL
Common Examples
Symbol | Description |
| Bitcoin/USDT on Binance |
| Apple Inc. on NASDAQ |
| Tesla Inc. on NYSE |
| Bitcoin/USD on Bitstamp |
| EUR/USD forex pair |
| Ethereum/USD on Coinbase |
Finding Symbol Names
Go to TradingView
Search for your desired asset
Look at the URL or chart title for the format
EXCHANGE:SYMBOL
š§ Architecture
This MCP server uses Playwright for lightweight browser automation:
Authentication: Session cookies passed to browser context
Chart Generation: Playwright navigates to TradingView and captures screenshots
Efficiency: Persistent browser instances reused across requests
MCP Protocol: Communicates via stdio with MCP clients
Why Playwright (Not Pure HTTP)?
TradingView renders charts client-side with JavaScript/Canvas
No server-side API exists for chart image generation
Playwright is lighter than Selenium (~150MB vs ~500MB RAM)
Headless mode with optimized flags minimizes resource usage
Browser reuse makes subsequent requests very fast (1-2 seconds)
ā This is the lightest possible approach for TradingView charts
š Troubleshooting
Cookie/Authentication Issues
Problem: "Session credentials are not working" or "Invalid session"
Solutions:
Check for trailing commas or spaces: Make sure your
.envfile has no extra characters# ā Wrong (has comma) TRADINGVIEW_SESSION_ID=abc123, # ā Correct TRADINGVIEW_SESSION_ID=abc123Refresh cookies: Session cookies expire after ~30 days
Log out and back into TradingView
Get fresh cookies from Developer Tools
Update your
.envfile
Check you're logged in: Make sure you're logged into TradingView when copying cookies
Copy entire value: Include special characters (=, /, :, etc.)
Symbol Not Found
Problem: "Failed to fetch chart snapshot"
Solutions:
Use correct format:
EXCHANGE:SYMBOL(all uppercase)ā
BINANCE:BTCUSDTā
btcusdtorbinance:btcusdt
Verify symbol exists on TradingView.com
Test with a known symbol first:
BINANCE:BTCUSDTorNASDAQ:AAPL
Timeout Errors
Problem: "Timeout exceeded" or slow performance
Solutions:
Check internet connection and TradingView.com accessibility
First request takes longer (5-8s) while browser starts
Subsequent requests are faster (3-5s) due to browser reuse
If persistent, restart the MCP server
Playwright Installation Issues
Problem: "Playwright not found" or browser download fails
Solutions:
# Reinstall Playwright
pip uninstall playwright
pip install playwright
# Install browsers again
python -m playwright install chromium
# If still failing, install system dependencies (Linux)
sudo playwright install-depsClaude Desktop Not Recognizing Server
Problem: Tools don't appear in Claude Desktop
Solutions:
Check JSON syntax in config file (use a JSON validator)
Use absolute paths (not relative)
Verify Python path is correct:
# Windows where python # Mac/Linux which pythonCompletely restart Claude Desktop (not just reload)
Check Claude logs for errors:
Windows:
%APPDATA%\Claude\logs\Mac:
~/Library/Logs/Claude/
Performance Issues
Problem: High memory usage or slow responses
Tips:
Memory usage: ~150MB is normal for Playwright
First chart: 5-8 seconds (browser startup)
Subsequent charts: 3-5 seconds
Browser is reused across requests for efficiency
If memory grows over time, restart the server
ā” Performance
Metric | Value | Notes |
Memory Usage | ~150MB | Playwright headless browser |
First Request | 5-8 seconds | Browser startup + chart load |
Subsequent Requests | 3-5 seconds | Browser reuse (persistent) |
Image Size | 50-200KB | PNG format, varies by dimensions |
Browser | Chromium | ~150MB download (one-time) |
Comparison with Alternatives:
Approach | Memory | Speed | Status |
Pure HTTP | ~50MB | 1-2s | ā Impossible (no API exists) |
Selenium | ~500MB | 10-15s | ā ļø Works but heavy |
Playwright | ~150MB | 3-5s | ā Best option |
š Security Notes
ā ļø Never commit your
.envfile - it contains your session credentialsā ļø Don't share your session cookies - they provide full account access
ā ļø Rotate cookies regularly - they expire after ~30 days
ā
.envis in.gitignoreby defaultā Use environment variables or secure credential management in production
š Development
Project Structure
tradingview-mcp/
āāā src/
ā āāā tradingview_mcp/
ā āāā __init__.py
ā āāā server.py # Main MCP server
āāā .env.example # Template for credentials
āāā .gitignore
āāā README.md
āāā requirements.txt # Python dependencies
āāā pyproject.toml # Project metadataRunning Tests
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytestCode Formatting
# Format code
black src/
# Lint code
ruff check src/š¤ Contributing
Contributions are welcome! Here's how:
Fork the repository
Create a feature branch (
git checkout -b feature/amazing-feature)Make your changes
Test thoroughly
Commit your changes (
git commit -m 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Development Setup:
pip install -e ".[dev]"
black src/
ruff check src/š License
MIT License - see LICENSE file for details.
š Acknowledgments
TradingView - Excellent charting platform
Anthropic - Model Context Protocol
Playwright - Browser automation
ā ļø Disclaimer
This is an unofficial tool and is not affiliated with, endorsed by, or connected to TradingView. Use at your own risk and in accordance with TradingView's Terms of Service. Respect rate limits and be mindful of your usage.
ļæ½ Support & Issues
š Bug Reports: GitHub Issues
š¬ Questions: GitHub Discussions
š§ Email: your.email@example.com
š Project Stats
Version: 0.1.0
Python: 3.10+
Memory: ~150MB
Response Time: 3-5 seconds
License: MIT
Made with ā¤ļø by the trading community
Star ā this repo if you find it useful!
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
> TradingMCP puts a market analyst inside your AI assistant. Paste one URL into Claude, ChatGPT, Cursor, VS Code or any MCP client and ask in plain language: screen for breakouts, run a multi-timeframe analysis, backtest a strategy with walk-forward validation, scan for smart-money and volume signals, or get a one-prompt morning market brief. In clients that support MCP Apps, price charts and the Markets panel are drawn right in the chat. > 40+ tools covering crypto (real-time), stocks, ETFs, FX, futures and commodities across major global exchanges. > Hosted, nothing to install: Pro $9/month (2,500 tool calls) or Pro+ $29/month (10,000). Paid upfront with a 14-day money-back guarantee; your API key arrives right after checkout. > Built on the open-source tradingview-mcp core (MIT, ~5k GitHub stars): self-host it free, or use the hosted version with zero ops. > For research and education, not financial advice. Not affiliated with TradingView
ChartGaze is a service that connects AI assistants to live and historical market data and, with your authorization, to trading-account information and trading actions. It works with MCP-compatible AI tools and supports platforms such as MT5, MT4, cTrader, and crypto exchanges.
Create and manage trading strategies, bots, webhooks and signals from any MCP client.
Screenshots, PDFs, image editing, QR codes, email validation and more through one hosted MCP server.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables fetching TradingView chart snapshots for any ticker and timeframe, returning direct image URLs or base64 data for AI analysis. Uses browser pooling and session-based authentication to handle several concurrent chart requests with substantially reduced latency.-
- FlicenseNot gradedqualityBmaintenanceEnables users to fetch TradingView chart images for specified tickers and intervals through MCP tools, returning snapshot URLs or base64 image data. It supports browser pooling for concurrent performance, configurable intervals, TradingView authentication, and performance statistics.-
- FlicenseNot gradedqualityAmaintenanceEnables users to capture chart snapshots for specified symbols and timeframes through MCP tools, with browser pooling for concurrent performance.-
- FlicenseNot gradedqualityAmaintenanceEnables users to request chart images for specified tickers and timeframes via MCP, with optimized concurrent fetching and optional authenticated clipboard/base64 capture.-