TradingView图表图像
STDIO获取TradingView图表图像的工具
获取TradingView图表图像的工具
This MCP server provides tools to fetch TradingView chart images based on ticker and interval.
Create Virtual Environment:
# Navigate to the project directory cd tradingview-chart-mcp # Create the venv (use python3 if python is not linked) python3 -m venv .venv
Activate Virtual Environment:
source .venv/bin/activate
source .venv/Scripts/activate
.venv\\Scripts\\activate.bat
(Note: You might need to adjust PowerShell execution policy:.venv\\Scripts\\Activate.ps1
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
)Your terminal prompt should now indicate you are in the (.venv)
.
Install Dependencies (inside venv):
pip install -r requirements.txt
Configure Environment (for Local Testing):
.env.example
to .env
.TRADINGVIEW_SESSION_ID
and TRADINGVIEW_SESSION_ID_SIGN
in the .env
file. You can obtain these from your browser's cookies after logging into TradingView..env
file is used when running the server directly (e.g., python main.py
) for local testing.MCP_SCRAPER_HEADLESS
, etc.) in .env
if needed for local runs.Ensure ChromeDriver: Make sure chromedriver
is installed and accessible in your system's PATH, or configure the tview-scraper.py
accordingly if it allows specifying a path.
Ensure your virtual environment is activated (source .venv/bin/activate
or equivalent).
python main.py
When you are finished, you can deactivate the environment:
deactivate
Once the server is running (within the activated venv), you can interact with it using an MCP client, targeting the TradingView Chart Image
server name.
Available Tools:
get_tradingview_chart_image(ticker: str, interval: str)
: Fetches the direct image URL for a TradingView chart.Example Prompts:
This server supports two ways of providing configuration:
.env
file (for local testing): When running python main.py
directly, the server will load credentials and settings from a .env
file in the project directory..env
file.Open your Claude Desktop configuration file:
%APPDATA%\\Claude\\claude_desktop_config.json
~/Library/Application\ Support/Claude/claude_desktop_config.json
Add or merge the following within the mcpServers
object. Provide your credentials in the env
block:
{ "mcpServers": { "tradingview-chart-mcp": { "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3", "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"], "env": { "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE", "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE" // Optional: Add MCP_SCRAPER_* variables here too if needed // "MCP_SCRAPER_HEADLESS": "False" } } // ... other servers if any ... } }
Replace the placeholder paths (command
, args
) with your actual absolute paths.
Replace YOUR_SESSION_ID_HERE
and YOUR_SESSION_ID_SIGN_HERE
with your actual TradingView credentials.
Restart Claude Desktop.
Go to: Settings -> Cursor Settings -> MCP -> Edit User MCP Config (~/.cursor/mcp.json)
.
Add or merge the following within the mcpServers
object. Provide your credentials in the env
block:
{ "mcpServers": { "tradingview-chart-mcp": { "command": "/absolute/path/to/your/tradingview-chart-mcp/.venv/bin/python3", "args": ["/absolute/path/to/your/tradingview-chart-mcp/main.py"], "env": { "TRADINGVIEW_SESSION_ID": "YOUR_SESSION_ID_HERE", "TRADINGVIEW_SESSION_ID_SIGN": "YOUR_SESSION_ID_SIGN_HERE" // Optional: Add MCP_SCRAPER_* variables here too if needed // "MCP_SCRAPER_HEADLESS": "False" } } // ... other servers if any ... } }
Replace the placeholder paths (command
, args
) with your actual absolute paths.
Replace YOUR_SESSION_ID_HERE
and YOUR_SESSION_ID_SIGN_HERE
with your actual TradingView credentials.
Restart Cursor.
To install TradingView Chart Image Scraper for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @ertugrul59/tradingview-chart-mcp --client claude
The following environment variables can be set to configure the scraper:
TRADINGVIEW_SESSION_ID
: Your TradingView session ID (required)TRADINGVIEW_SESSION_ID_SIGN
: Your TradingView session ID signature (required)MCP_SCRAPER_HEADLESS
: Run browser in headless mode (default: True
)MCP_SCRAPER_WINDOW_WIDTH
: Browser window width (default: 1920
)MCP_SCRAPER_WINDOW_HEIGHT
: Browser window height (default: 1080
)MCP_SCRAPER_USE_SAVE_SHORTCUT
: Use clipboard image capture instead of screenshot links (default: True
)MCP_SCRAPER_CHART_PAGE_ID
: Custom chart page ID (optional)The MCP_SCRAPER_USE_SAVE_SHORTCUT
feature allows you to capture chart images directly to the clipboard as base64 data URLs instead of getting screenshot links. This eliminates the need to download images from URLs.
Benefits:
How it works:
True
): Uses Shift+Ctrl+S
(or Shift+Cmd+S
on Mac) to capture chart image directly to clipboardFalse
): Uses traditional Alt+S
to get screenshot links, then converts to image URLsConfiguration:
# Enable clipboard image capture (DEFAULT) MCP_SCRAPER_USE_SAVE_SHORTCUT=True # Disable and use traditional screenshot links MCP_SCRAPER_USE_SAVE_SHORTCUT=False