Skip to main content
Glama
README.md
# India Agriculture MCP Server

A Python MCP server for Indian agriculture workflows, built with FastMCP for Claude Desktop and other MCP-compatible clients.

## Overview

This project exposes practical agriculture tools through the Model Context Protocol (MCP), so an AI client can call real functions instead of relying only on built-in knowledge.

The current server is focused on three common agriculture workflows:

- Farming weather lookup for Indian locations
- Crop advisory for common crops
- Mandi price reference lookup by crop and state

It is designed for local use with Claude Desktop through the `stdio` transport pattern supported by FastMCP.

## Current tools

The server currently exposes these three MCP tools:

### 1. `weather_for_farming(location: str)`

Returns current weather conditions for a location and adds basic farming suitability guidance.

**Example input**
- `Nagpur`
- `Pune,IN`
- `Delhi`

**What it includes**
- Weather condition
- Temperature
- Feels-like temperature
- Humidity
- Wind speed
- Rain status if available
- Simple farming suitability notes

### 2. `crop_advisory(crop: str, state: str = "")`

Returns reference agronomy guidance for a crop.

**Example input**
- `crop="soybean", state="Maharashtra"`
- `crop="cotton", state="Gujarat"`
- `crop="wheat", state="Punjab"`

**What it includes**
- Season
- Soil type
- Water requirement
- Fertilizer guidance
- Common pests or diseases
- Practical cultivation tips

### 3. `mandi_prices(crop: str, state: str)`

Returns reference mandi price information for a crop in a specific Indian state.

**Example input**
- `crop="soybean", state="Maharashtra"`
- `crop="cotton", state="Maharashtra"`

**What it includes**
- Minimum price
- Maximum price
- Modal price
- Example market names

## Current behavior and limitations

This server currently mixes live and reference-style outputs.

- **Weather** is a live current-weather snapshot.
- **Crop advisory** is reference agronomy guidance, not a field-specific expert bulletin.
- **Mandi prices** should be treated as reference market information unless explicitly connected to a verified live official source.

That means the project is useful for AI-assisted agriculture workflows, demos, and portfolio use, but important farm decisions should still be verified with local agronomy experts, soil tests, and official market data.

## Tech stack

| Layer | Technology | Purpose |
|---|---|---|
| Language | Python | Core implementation |
| MCP framework | FastMCP | Tool registration and MCP server runtime |
| Transport | `stdio` | Local MCP communication |
| HTTP client | `httpx` | External API requests |
| Configuration | `python-dotenv` | Load environment variables from `.env` |
| Client | Claude Desktop | Local MCP client integration |

## Project structure

```text
mcp-india-server/
├── .env.example
├── .gitignore
├── README.md
├── requirements.txt
├── run_server.py
├── src/
│   ├── __init__.py
│   ├── server.py
│   └── tools/
│       ├── __init__.py
│       ├── crops.py
│       └── weather.py
```

## Setup

### 1. Clone the repository

```bash
git clone https://github.com/Parikshit2005/-mcp-india-server.git
cd mcp-india-server
```

If your local folder name is different, use that folder name instead.

### 2. Create a virtual environment

```bash
python -m venv venv
```

### 3. Activate the virtual environment

**Windows CMD**
```bat
venv\Scripts\activate
```

If your project is on another drive, open CMD and run:

```bat
cd /d F:\mcp-india-server
venv\Scripts\activate
```

### 4. Install dependencies

```bash
pip install -r requirements.txt
```

### 5. Create the environment file

```bat
copy .env.example .env
```

Then add the required API keys and configuration values to `.env`.

### 6. Run the server

```bash
python run_server.py
```

## Claude Desktop integration

Claude Desktop can connect to local MCP servers by launching them as subprocesses. FastMCP supports this pattern over `stdio`, which makes it a good fit for local tool usage.

Add an entry like this to your Claude Desktop MCP configuration:

```json
{
  "mcpServers": {
    "india-mcp-server": {
      "command": "F:\\mcp-india-server\\venv\\Scripts\\python.exe",
      "args": ["F:\\mcp-india-server\\run_server.py"]
    }
  }
}
```

After saving the config:

1. Fully close Claude Desktop.
2. Reopen it.
3. Test prompts that should trigger the server tools.

## Example prompts

Try prompts like these inside Claude Desktop:

- Give crop advisory for soybean in Maharashtra.
- Show mandi price for soybean in Maharashtra.
- Give farming weather for Nagpur,IN.
- What is the weather in Pune for farming today?
- Give crop advisory for cotton in Gujarat.

## Implementation notes

The server is built with FastMCP and registers tools using the `@mcp.tool()` decorator. The current server code exposes:

- `weather_for_farming`
- `crop_advisory`
- `mandi_prices`

The server runs locally with:

```python
mcp.run(transport="stdio")
```

This keeps the setup simple for local MCP client use.

## Security

- Store secrets in `.env`, not in source files.
- Keep `.env` out of version control.
- Commit only `.env.example` with placeholder values.
- Review logs and debug output before sharing screenshots or demos.

## Roadmap

Planned improvements:

- Add weather freshness display using API timestamp fields
- Improve mandi pricing with clearer official-source support
- Expand crop coverage and regional advisory detail
- Add tests for tool handlers and edge cases
- Add screenshots or demo recordings from Claude Desktop
- Add hosted deployment instructions for remote MCP usage

## Use cases

This project is a good fit for:

- MCP learning and experimentation
- Claude Desktop custom tool integration
- Agriculture-focused assistant workflows
- Student and portfolio projects around AI tooling
- Rapid prototyping of India-specific utility assistants

## Two tiny things to verify before using it:

If your repo folder is literally -mcp-india-server, keep that exact name in the clone and cd commands; otherwise use mcp-india-server.

If run_server.py actually imports src.server:mcp, your current wording is still fine, but the file path in Claude Desktop must exactly match your machine path.

## License

Add a license before public release so reuse terms are clear.