Agmarknet MCP Server
Provides LLMs with real-time access to Indian agricultural commodity prices across 3,000+ markets via the government's Agmarknet database.
README
Agmarknet MCP Server
A Model Context Protocol (MCP) server that gives LLMs (like Claude) access to Indian agricultural commodity prices — daily wholesale min/max/modal rates across thousands of mandis (regulated markets) and hundreds of commodities.
Ask a model "Where were tomatoes cheapest in Pune last month?" and it answers from real market data.
Pick your implementation
The project lives on two branches with different data sources. They expose the same kind of tools; choose by your data needs.
main |
feat/ceda-api-migration |
|
|---|---|---|
| Data source | data.gov.in Agmarknet | CEDA Agri Market API (Ashoka University) |
| API key | DATA_GOV_IN_API_KEY (free) |
CEDA_API_KEY (free) |
| Without a key | Serves a small sample dataset so the tools work out of the box — for flavour only, not live prices | Will not run — a key is required |
| To use real data | Add the key to .env and set use_mock=False in server.py |
Add the key to .env |
| Data coverage | Current day only (when the live API is reachable) | Historical, 2000–present (lags ~a few months) |
| Price trends | ✗ | ✅ get_price_trend over a date range |
| Reliability | data.gov.in is frequently down / WAF-blocked | Stable |
| Tools | 5 | 6 |
| Best for | Trying the tools instantly on sample data | Real analysis — trends and accurate prices |
TL;DR: Want to see the server work with no live API? Use
main(it ships with sample data). Want real, reliable commodity data and trends? Usefeat/ceda-api-migration.
Switch with git checkout main or git checkout feat/ceda-api-migration.
Setup
Install (same for both branches)
git clone https://github.com/Krishna-Baldwa/agmarket-mcp.git
cd agmarknet-mcp
git checkout feat/ceda-api-migration # or: git checkout main
python -m venv .venv
source .venv/bin/activate
pip install -e .
Configure the API key
cp .env.example .env
On feat/ceda-api-migration (CEDA):
- Get a free key from the CEDA Data Portal.
- Set
CEDA_API_KEY=<your key>in.env. Done — the server uses real data.
On main (data.gov.in):
- Out of the box it serves a small sample dataset (no key needed) so you can see the tools respond.
- To switch to real data.gov.in data:
- Get a free key at data.gov.in and set
DATA_GOV_IN_API_KEY=<your key>in.env. - In
src/agmarknet_mcp/server.py, change the client to live mode:api_client = AgmarknetClient(use_mock=False) # was use_mock=True
- Get a free key at data.gov.in and set
Connect to Claude Desktop
Add this to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; The easiest way to get to it is from inside the app rather than hunting through folders: open Claude Desktop → Settings → Developer tab → click Edit Config. That opens the file directly (and creates it if it doesn't exist yet).), using the env var for your branch:
{
"mcpServers": {
"agmarknet": {
"command": "/absolute/path/to/agmarknet-mcp/.venv/bin/python",
"args": ["-m", "agmarknet_mcp.server"],
"env": {
"CEDA_API_KEY": "your_api_key_here"
}
}
}
}
(On main, use "DATA_GOV_IN_API_KEY" instead — or omit env to run on sample data.)
Restart Claude Desktop and ask:
- "Compare tomato prices across mandis in Pune district."
- "What's the 60-day onion price trend in Maharashtra?" (CEDA branch)
Test without an LLM
npx @modelcontextprotocol/inspector python -m agmarknet_mcp.server
Tools
feat/ceda-api-migration (CEDA — real historical data)
| Tool | What it does |
|---|---|
get_commodity_price(commodity, state, district?, date?) |
Min/max/modal prices — latest available date, or a specific YYYY-MM-DD. |
compare_markets(commodity, state, district, top_n=10) |
Rank a district's mandis cheapest-first. |
get_price_summary(commodity, state, district?) |
Average / cheapest / dearest on the latest date. |
get_price_trend(commodity, state, district?, days=30) |
Daily-average price, window average, high/low, and % change over N days. |
list_commodities(search?) |
List tracked commodities, optionally filtered. |
list_markets(commodity, state, district) |
List the mandis reporting a commodity in a district. |
Tools accept names, not numeric ids (see Design). state is required; district narrows to individual mandis (omit for a state-wide aggregate).
main (data.gov.in + sample fallback)
| Tool | What it does |
|---|---|
get_commodity_price(commodity, state?, district?, market?) |
Daily min/max/modal price for a commodity. |
compare_markets(commodity, state?, top_n=10) |
Rank markets cheapest-first. |
get_price_summary(commodity, state?) |
Average / cheapest / dearest across markets. |
list_commodities(search?) |
List commodities in the current dataset. |
list_markets(state?, commodity?) |
List reporting mandis. |
Design (CEDA branch)
The CEDA API is id-based: commodities, states, districts, and markets are all numeric ids, and /prices returns ids, not names. LLMs and humans think in names, so the server's core job is translation:
- Name → ID resolution. Tools accept
"Tomato","Maharashtra","Pune"; the client resolves them to ids (case-insensitive, unique-substring matching) before calling the API, and raises a clear error for unknown/ambiguous names so the model can self-correct. - ID → name enrichment. Raw price rows (which carry only
market_id) are translated back into readable records before reaching the model. - Cached reference data. Commodities, geographies, and markets are fetched once and reused.
- Tolerant validation.
pydanticvalidates every response. The API changes shape by granularity (state-level queries omitdistrict_id/market_id), which the models handle explicitly.
Module layout
server.py— FastMCP server: defines the tools and handles the stdio/JSON-RPC lifecycle.api.py— the API client (CedaClienton CEDA;AgmarknetClientwith sample fallback onmain).models.py—pydanticmodels for the API's raw shapes and the domain objects the tools return.
Data sources
main: Directorate of Marketing & Inspection (DMI), Govt. of India, via data.gov.in.- CEDA branch: CEDA Agri Market Data, "Centre for Economic Data & Analysis, Ashoka University" — built on the same Agmarknet data, 2000–present. Free to download, display or include the data in other products for non-commercial purposes.
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。