Skip to main content
Glama
niketbiyani

TradingView MCP Server

by niketbiyani
README.md
# TradingView MCP Server

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![MCP Standard](https://img.shields.io/badge/MCP-Standard-green.svg)](https://modelcontextprotocol.io/)

A standalone, lightweight **Model Context Protocol (MCP) Server** powered by **TradingView Technical Analysis (`tradingview_ta`)**.

It provides AI agents (Claude Desktop, Cursor, Custom Agents) and trading microservices with real-time technical indicators, market regime classification (**CHOP vs TRENDING**), moving average summaries, and oscillator signatures for global stocks, indices, crypto, and forex.

---

## 🌟 Key Features

- 📊 **Real-Time Technical Indicators**: Instant access to RSI, ADX, MACD, Bollinger Bands, EMAs, and Moving Average summaries.
- 🎯 **Market Regime Classification**: Calculates market condition (`CHOP` vs `TRENDING`) using ADX trend strength, oscillator divergence, and Bollinger Band squeeze signatures.
- 🌐 **Multi-Asset & Multi-Exchange**: Supports Indian stock market (`NSE`, `BSE`), US equities (`NASDAQ`, `NYSE`), Crypto (`BINANCE`), and Forex.
- ⚡ **Dual Transport Support**: 
  - **stdio mode**: Standard input/output for LLM desktop integration (Claude Desktop, Cursor, etc.).
  - **SSE HTTP mode (Port 5560)**: Background streaming event server for microservices.
  - **REST API Bridge (Port 5559)**: Instant HTTP `curl` queries for trading bots.

---

## 🚀 Quick Start

### 1. Installation

```bash
# Clone the repository
git clone https://github.com/niketbiyani/tradingview-mcp-server.git
cd tradingview-mcp-server

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt
```

### 2. Run the MCP Server

```bash
# Interactive mode (stdio transport for MCP clients)
python tv_mcp_server.py
```

---

## 💻 Claude Desktop / MCP Client Integration

Add the server config to your Claude Desktop configuration file (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "tradingview": {
      "command": "/path/to/tradingview-mcp-server/venv/bin/python",
      "args": [
        "/path/to/tradingview-mcp-server/tv_mcp_server.py"
      ]
    }
  }
}
```

---

## 🛠 VPS Systemd Deployment

To run the server as a background service on your VPS (Ubuntu/Debian):

```bash
cd tradingview-mcp-server
sudo bash install_vps_service.sh
```

### Service Control Commands:
- **Check Status**: `sudo systemctl status tradingview-mcp`
- **Restart Service**: `sudo systemctl restart tradingview-mcp`
- **View Live Logs**: `tail -f tv_mcp.log`

---

## 🧰 Available Tools & REST Endpoints

### MCP Tools

1. `get_technical_analysis(symbol, exchange, screener, interval)`
   - Fetches TradingView recommendation summary, oscillators, moving averages, and detailed indicators.
   - Example: `symbol="NIFTY", exchange="NSE", interval="1m"`

2. `get_market_regime(symbol, exchange, screener, interval)`
   - Calculates market condition (`CHOP` vs `TRENDING`) and returns ADX, BBW, RSI, and detailed reason strings.

---

### REST API Endpoints (Port 5559)

* **Get Market Regime**:
  ```bash
  curl "http://127.0.0.1:5559/get_market_regime?symbol=NIFTY&exchange=NSE&interval=1m"
  ```
* **Get Full TA Analysis**:
  ```bash
  curl "http://127.0.0.1:5559/get_technical_analysis?symbol=NIFTY&exchange=NSE&interval=1m"
  ```

---

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Developed with ❤️ by [Niket Biyani](https://github.com/niketbiyani).