tradingview-mcp-py
MCP server for stock analysis providing 30 tools across technical analysis, Yahoo Finance, IDX/BEI, backtesting, news sentiment, and trade math, with no TradingView Desktop required and VPS compatibility.
README
J-SQUAD TradingView MCP โ Python (tradingview-mcp-py)
30 tools ยท 5 modules โ MCP server for stock analysis (TradingView Screener API, Yahoo Finance, IDX/BEI, backtesting, news sentiment, trade math). Lean edition, no CDP โ no TradingView Desktop / Chrome required, so it's VPS-compatible.
Built by CenblueOne as part of the J-SQUAD system (IDX trading bot).
๐ค For AI agents / harnesses (Claude Code, Hermes, opencode, Cursor, Grok, etc.): read
AGENTS.mdโ architecture, how to run/test, tool inventory, and mandatory rules (never upgrademcp, never use"command": "python", etc.).
โจ Highlights
- โ No TradingView Desktop โ uses TradingView public Screener API + Yahoo Finance (runs headless on servers/VPS)
- โ
IDX-ready โ
idx_*tools auto-append.JK(BBRI โ BBRI.JK) - โ Graceful degradation โ if a library is missing, only that module's tools are disabled
- โ
Tested โ
pytest13 tests passed (helpers + server import + market_cap mocked) - โ Multi-agent ready โ one shared venv across many agents; per-agent config files; stdio (no port conflicts)
โ ๏ธ Agent / AI Guide โ Check FIRST Before Installing / Configuring
Read this section every time an agent (Claude Code, Hermes, opencode, Grok, etc.) wants to install / configure / upgrade this server. This server can be shared by MANY agents on one machine โ the most common mistakes come from unnecessary re-installs or using
"command": "python".
Mandatory checklist:
-
Check whether it's already installed โ don't blindly reinstall:
# venv exists? Test-Path "<REPO_DIR>\venv\Scripts\python.exe" # mcp 1.x installed? (MUST be < 2.0.0) & "<REPO_DIR>\venv\Scripts\python.exe" -c "import importlib.metadata as m; print(m.version('mcp'))"If it exists and mcp is
1.xโ STOP, don't install anything. -
NEVER upgrade / reinstall
mcp. The server uses themcp.server.fastmcp.FastMCPAPI which only exists in mcp 1.x. mcp 2.x completely reworked the API โ the server fails to start.requirements.txtalready pinsmcp>=1.2.0,<2.0.0. -
NEVER use
"command": "python"/"command": "python3". Always point to the venv python with an absolute path โ PATH differs per agent (e.g. store-alias on Windows, orpythonpointing to a different interpreter without dependencies). Venv path:<REPO_DIR>\venv\Scripts\python.exe -
NEVER reinstall / upgrade while another agent is running. The single
venvis shared.pip install/pip upgradein the middle mutates the dependencies used by all agents โ other agents break (real case: mcp bumped to 2.x removedFastMCP). Install ONCE viainstall.bat. -
One venv + one server.py โ many separate config files. Each agent has its own MCP config file; paste the same entry (see
mcp-config.example.json) into each file. Don't overwrite another agent's config. -
Verify after configuring โ test 1 tool from EACH agent before using together:
# import must succeed without errors (run from the project folder) cd "<REPO_DIR>" & "<REPO_DIR>\venv\Scripts\python.exe" -c "import server; print('server OK')"Or call a tool directly from each agent's chat (
idx_price BBRI). Don't continue if any agent still errors.
๐ฆ Modules & Tools (30 total)
Technical Analysis โ 6 tools (tradingview-ta)
| Tool | Description |
|---|---|
get_ta |
Full TA: RSI, MACD, BB, EMA, ADX, Stoch, CCI |
get_ta_bulk |
TA for many symbols (max 25, rate-limited) |
get_mtf |
Multi-timeframe: 1h + 4h + 1d + 1w alignment |
get_candlestick |
Detect 15 candlestick patterns |
get_bollinger |
Bollinger Band: position, bandwidth, squeeze |
screen_stocks |
Screen stocks by TA signal + RSI filter |
Yahoo Finance โ 4 tools (yfinance)
| Tool | Description |
|---|---|
yf_price |
Realtime price (AAPL, BTC-USD, BBRI.JK, ^JKSE) |
get_market_cap |
Market cap + 52w high/low + TA context |
market_snapshot |
Global snapshot: S&P500, NASDAQ, VIX, IHSG, BTC, ETH, GOLD, OIL, DXY |
yf_ohlcv |
Historical OHLCV (configurable period + interval) |
IDX / BEI โ 11 tools
| Tool | Description |
|---|---|
idx_price |
BEI stock price (auto .JK) |
idx_ta |
BEI stock TA via TradingView Screener |
idx_mtf |
BEI stock MTF |
idx_market |
IHSG snapshot + top 10 LQ45 + gainers/losers |
idx_screener |
Screen BEI stocks by movement & volume |
idx_signals |
BUY/SELL/HOLD signals for a BEI stock list |
idx_backtest |
Backtest strategies on BEI stocks |
idx_deep_analysis |
100pt stock score (trend/momentum/volatility) |
morning_brief_idx |
Morning brief: scan BEI watchlist, rank TA + price |
combined_analysis |
TA + Price + Sentiment โ STRONG BUY/SELL |
financial_news |
Live headlines (Yahoo, CNBC, MarketWatch) |
Backtesting โ 3 tools (services/backtest_service.py)
| Tool | Description |
|---|---|
backtest_strategy |
1 strategy, institutional metrics |
compare_strategies |
Compare 9 strategies, ranked by total return |
walk_forward_backtest |
Walk-forward, overfitting detection |
Trading Utilities & Sentiment โ 6 tools
| Tool | Description |
|---|---|
market_sentiment |
Sentiment from Yahoo News for a symbol |
position_size |
Lot size by risk management |
rr_calc |
Risk:Reward ratio from entry/SL/TP |
journal_add |
Log a trade to the local journal |
journal_list |
Trade journal history |
market_sessions |
Global trading sessions (WIB / UTC+7) |
๐ง Requirements
Python >= 3.11 (tested on 3.11)
mcp >= 1.2.0, < 2.0.0 (MUST be 1.x โ server uses mcp.server.fastmcp.FastMCP)
tradingview-ta >= 3.3.0
yfinance >= 0.2.40
pandas >= 2.0.0
numpy >= 1.24.0
feedparser >= 6.0.0
requests >= 2.31.0
Not needed
websocket-client/ Chrome โ the CDP module (TradingView Desktop) was removed on 03 Jul 2026.
๐ Installation
install.bat(Windows) or the manual commands below โ run ONCE. After installation, replace every<REPO_DIR>in the config examples with the absolute path where you cloned this repo on your machine.
Windows
install.bat
Linux / macOS (VPS-compatible)
python3 -m venv venv
venv/bin/pip install -r requirements.txt
Verify (all OS)
venv/Scripts/python server.py # Windows
venv/bin/python server.py # Linux/macOS โ MCP stdio server, waits for JSON-RPC on stdin
NEVER run a bare
pip install mcp/ upgrade mcp.requirements.txtpinsmcp>=1.2.0,<2.0.0โ mcp 2.x completely reworked the API and is incompatible.
Quick smoke test (no network)
venv/Scripts/pip install pytest # Windows
venv/bin/pip install pytest # Linux/macOS
venv/Scripts/python -m pytest # Windows โ 13 passed
venv/bin/python -m pytest # Linux/macOS โ 13 passed
๐ค Per-Agent Configuration (Universal โ stdio)
IMPORTANT: each agent has its own config file. Don't merge multiple agents into one file, and don't overwrite another agent's config.
Claude Code / Grok
~/.claude.json (global) or .mcp.json (project root) โ mcpServers:
{
"mcpServers": {
"tradingview-mcp-py": {
"command": "<REPO_DIR>\\venv\\Scripts\\python.exe",
"args": ["<REPO_DIR>\\server.py"],
"env": {}
}
}
}
Hermes Agent
~/.hermes/config.yaml โ mcp_servers:
mcp_servers:
tradingview-mcp-py:
command: "<REPO_DIR>\\venv\\Scripts\\python.exe"
args: ["<REPO_DIR>\\server.py"]
type: stdio
opencode
opencode.json (project root) โ mcp:
{
"mcp": {
"tradingview-mcp-py": {
"type": "local",
"command": ["<REPO_DIR>\\venv\\Scripts\\python.exe", "<REPO_DIR>\\server.py"]
}
}
}
Absolute path is MANDATORY for
command(venv python) andargs(server.py). Don't use"command": "python". Ready-to-use example:mcp-config.example.json.
Verify
After registering, call a tool from each agent's chat, e.g.:
get_ta BBRI exchange=IDX screener=indonesia
idx_deep_analysis TLKM
morning_brief_idx
๐ฅ Multi-Agent โ Several Agents on 1 Machine
Same pattern as other MCP servers in this workspace (yfinance-mcp-final, invezgo-mcp):
| Rule | Explanation |
|---|---|
| 1 venv + 1 server.py โ N separate configs | All agents use the same venv & server, but each agent has its own config |
| stdio | Each agent spawns its own Python process โ no port conflicts, no stdout contention |
| Absolute path | command โ venv\Scripts\python.exe; args โ absolute path to server.py |
| mcp pinned to 1.x | requirements.txt pins mcp>=1.2.0,<2.0.0. Don't run bare pip install mcp / upgrade |
| Install once | Don't reinstall while another agent is running โ it mutates shared dependencies |
| Check first | Before installing, run the checklist at the top of this README |
Most common error scenarios:
- All tools error "unknown function" / import fails โ venv was upgraded to mcp 2.x
or system python was used. Check:
venv\Scripts\python -c "import importlib.metadata as m; print(m.version('mcp'))"โ must be1.x. - "python: can't open file 'server.py'" โ use an absolute path, not relative.
- Agent A works, agent B errors โ usually agent B uses
"command": "python"pointing to a different Python / one without dependencies. Point all agents to the same venv. - Yahoo rate limit (429) across 4 agents at once โ expected; raise the
requests.Sessionretry inserver.pyor limit polling frequency.
๐ All AI Clients (Model-Agnostic)
This server uses MCP stdio transport โ usable by any AI model / client that supports MCP, not just one vendor:
| Client | How to register |
|---|---|
| Claude Code / Grok | mcpServers in .mcp.json (project) / ~/.claude.json (global) โ absolute path to venv\Scripts\python.exe |
| Claude Desktop | Add the block to claude_desktop_config.json (see mcp-config.example.json) |
| Hermes Agent | mcp_servers in ~/.hermes/config.yaml โ absolute path to venv python |
| opencode | mcp in opencode.json โ absolute path to venv python |
| Cursor / VS Code | Add to mcp.json / MCP settings โ absolute path to venv python |
| ChatGPT / others | If the client supports MCP stdio, point it to venv\Scripts\python.exe server.py |
All clients above call the same tools (get_ta, idx_deep_analysis,
morning_brief_idx, etc.). Nothing is hardcoded to a specific model.
Multi-agent golden rule: one shared venv, but separate config per agent + absolute path. Don't merge all agents into a single config file.
๐ก Usage Examples
Analyze BBRI:
Analyze BBRI on IDX โ TA + sentiment + price
โ combined_analysis(symbol="BBRI", exchange="IDX", screener="indonesia")
Morning scan IDX:
Run morning brief for IDX
โ morning_brief_idx()
Backtest:
Backtest TLKM with supertrend strategy for 1 year
โ idx_backtest(symbol="TLKM", strategy="supertrend", period="1y")
Position sizing:
Balance 10k, risk 1%, SL 50 pips, gold
โ position_size(balance=10000, risk_pct=1, sl_pips=50, instrument="gold")
๐งฉ Module Dependency Map
TA tools โ tradingview-ta
YF tools โ yfinance
IDX tools โ tradingview-ta + yfinance
News/Sentiment โ feedparser + yfinance
Backtest โ services/backtest_service.py (pandas/numpy)
All modules degrade gracefully โ missing library โ only that module's tools are off.
๐งช Testing
venv\Scripts\pip install pytest
venv\Scripts\python -m pytest # 13 passed (helpers, server import, market_cap mocked)
Tests don't need network (mock yfinance / tradingview_ta).
๐ Part of J-SQUAD
The J-SQUAD IDX bot system:
- ARA Hunter โ ARA detection
- Bandar Hunter โ institutional accumulation detection
- Signal Aggregator โ signal aggregation
- KINARA ENGINE โ TradingView webhook โ Telegram
๐ License
See the LICENSE file โ MIT. Free to use, fork, and
develop. For security policy, see SECURITY.md.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.