Skip to main content
Glama
bhavuk1409

Silver Price MCP Server

by bhavuk1409
README.md
# Silver Price MCP Server

A **Model Context Protocol (MCP) server** that fetches live **MCX India
silver prices** — plus a chart image — straight from Groww.in. No API key
required; the data is scraped in real time and handed to any MCP-compatible
client as structured JSON and a PNG chart.

![python](https://img.shields.io/badge/python-3.10%2B-3776ab) ![scraping](https://img.shields.io/badge/scraping-Selenium-43B02A) ![data](https://img.shields.io/badge/data-Groww.in%20(MCX)-00d09c) ![license](https://img.shields.io/badge/license-MIT-green)

---

## What it does

- **Live silver price** — current price, open, previous close, and % / ₹
  change, pulled straight from MCX India via Groww.in.
- **52-week range** — high/low over the trailing year.
- **Volume & open interest** — lot size and OI lots included.
- **Trend detection** — flags the move as `UP` or `DOWN`.
- **Chart image included** — a full-page screenshot of the price chart,
  returned as a base64-encoded PNG alongside the JSON.
- **No API key needed** — works out of the box; the data comes from a
  headless Chrome scrape, not a paid feed.

---

## Repository layout

```
├── src/                  # MCP server implementation (tool + scraper)
├── requirements.txt      # Python dependencies
├── pyproject.toml        # Project configuration
└── README.md             # This file
```

---

## Requirements

- Python 3.10+
- Chrome browser (runs headless via Selenium)
- Dependencies: `mcp`, `selenium`, `webdriver-manager`

---

## Quickstart

### 1. Install

```bash
git clone https://github.com/bhavuk1409/silver-mcx-mcp-server.git
cd silver-mcx-mcp-server

pip install -r requirements.txt
```

### 2. Test it directly

```bash
python test.py
```

### 3. Connect to Claude Desktop

Add to your Claude Desktop config
(`~/Library/Application Support/Claude/claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "silver-price": {
      "command": "python",
      "args": ["-m", "mcp_metal_price"],
      "cwd": "/path/to/silver-mcx-mcp-server"
    }
  }
}
```

Restart Claude Desktop and ask: **"Get the current silver price."**

---

## Tool

| Name | Parameters | Returns |
| --- | --- | --- |
| `get_silver_price` | none | JSON price metrics + a base64-encoded PNG chart |

**Example response:**

```json
{
  "metal": "Silver",
  "symbol": "XAG",
  "currency": "INR",
  "current_price": "2,42,798.00",
  "price_formatted": "₹2,42,798.00",
  "open": "2,42,775.00",
  "previous_close": "2,40,277.00",
  "52w_low": "1,09,741.00",
  "52w_high": "2,59,692.00",
  "oi_lots": "12,394",
  "lot_size": "30",
  "change": "+2521.00",
  "percent_change": "+1.05%",
  "trend": "UP"
}
```

---

## How it works

1. Opens the Groww.in silver page in a headless Chrome instance via Selenium.
2. Waits ~8 seconds for the page content to fully load.
3. Extracts price data from the page using regex.
4. Captures a full-page screenshot of the chart.
5. Returns the parsed JSON plus the chart image to the MCP client.

---

## Notes

- Scraping takes roughly 8–10 seconds per call.
- Chrome runs headless — no visible window.
- Chart image is PNG format, base64-encoded.
- Data source is MCX India via Groww.in and can change format if the site
  changes its layout.

---

## License

MIT

Maintenance

ActivitySlowing
ResponsivenessNo issues