Skip to main content
Glama
Krishna-Baldwa

Agmarknet MCP Server

Agmarknet MCP Server

Model Context Protocol Python License: MIT

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? Use feat/ceda-api-migration.

Switch with git checkout main or git checkout feat/ceda-api-migration.


Related MCP server: Agricultural AI MCP Server

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):

  1. Get a free key from the CEDA Data Portal.

  2. 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:

    1. Get a free key at data.gov.in and set DATA_GOV_IN_API_KEY=<your key> in .env.

    2. In src/agmarknet_mcp/server.py, change the client to live mode:

      api_client = AgmarknetClient(use_mock=False)   # was use_mock=True

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. pydantic validates every response. The API changes shape by granularity (state-level queries omit district_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 (CedaClient on CEDA; AgmarknetClient with sample fallback on main).

  • models.pypydantic models 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

MIT

Available Tools

5 tools
compare_marketsA

Compare prices of a commodity across different markets.

Returns markets sorted by modal price (cheapest first). Great for finding the cheapest mandi.

ParametersJSON Schema
NameRequiredDescriptionDefault
commodityYes
stateNo
top_nNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations exist, so the description bears full responsibility. It discloses that results are sorted by modal price (cheapest first), which is useful. However, it does not mention whether the operation is read-only, any authentication needs, or potential side effects. The disclosure is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two short sentences plus a standalone line. Every sentence adds value, with no redundancy. It is front-loaded with the core action and then provides a key benefit.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has an output schema (existing but not shown), so return details are not required. However, the description lacks explanation for 'modal price' and does not clarify the meaning of 'top_n' or 'state'. For a relatively simple tool, it covers the primary use but misses minor contextual details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description only indirectly references the 'commodity' parameter by mentioning 'a commodity.' The 'state' and 'top_n' parameters are not explained at all. With 0% schema description coverage, the description should compensate but does not, leaving the agent to infer semantics for two of three parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Compare prices of a commodity across different markets,' specifying the action (compare), resource (prices of a commodity), and scope (across markets). It distinguishes from siblings like get_commodity_price (single price) and list_markets (just listing) by focusing on comparative pricing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'Great for finding the cheapest mandi' implies a specific use case, but there is no explicit guidance on when to use this tool versus alternatives (e.g., get_price_summary for aggregated stats). No exclusions or conditions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_commodity_priceB

Get current daily wholesale prices for a specific commodity.

Returns min, max, and modal prices from today's Agmarknet data.

ParametersJSON Schema
NameRequiredDescriptionDefault
commodityYes
stateNo
districtNo
marketNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden but only states it returns min, max, and modal prices from today's data. It does not disclose behavior if data is missing, freshness guarantees, or any rate limits. This gap leaves the agent uncertain about edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short, front-loaded sentences that efficiently communicate the tool's purpose and output. No waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite an output schema existence, the description lacks explanation of optional parameters and behavioral details. Given 4 parameters and no annotations, the description is insufficiently complete for agents to reliably invoke the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description only refers to a 'specific commodity' without explaining the state, district, or market parameters. The required commodity parameter lacks format or example, failing to add value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves current daily wholesale prices for a specific commodity, specifying returns of min, max, and modal prices from Agmarknet data. It distinguishes itself from sibling tools like compare_markets or list_commodities by focusing on price retrieval for a single commodity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for getting commodity prices but does not provide explicit guidance on when to use this tool versus alternatives like compare_markets or get_price_summary. No exclusions or conditions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_price_summaryB

Get a statistical summary of a commodity's price across all markets.

Returns average, lowest, and highest prices across matching markets.

ParametersJSON Schema
NameRequiredDescriptionDefault
commodityYes
stateNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description bears full responsibility for behavioral disclosure. It mentions the return type (summary) but omits side effects, permissions, or behavior on missing data. The tool is likely read-only, but the description does not confirm.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with purpose, and all words contribute. It is concise but could be slightly more structured (e.g., listing returned fields explicitly).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with 2 parameters and an output schema, so the description need not detail returns. However, it misses explaining that 'state' is optional and affects market filtering. Overall, it provides a minimal but adequate context for a straightforward tool, falling short on optional parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'commodity' implicitly and that results span 'all markets', but fails to clarify the 'state' parameter is optional or explain parameter formats. This adds minimal value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns a statistical summary (average, lowest, highest) of a commodity's price across all markets. It uses specific verbs and resources, and the purpose is distinguishable from sibling tools like get_commodity_price or compare_markets.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool vs alternatives. The description implies it's for aggregate statistics across markets but doesn't mention circumstances or prerequisites, leaving the agent to infer usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_commoditiesC

List available commodities in today's Agmarknet data.

ParametersJSON Schema
NameRequiredDescriptionDefault
searchNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries full burden. It does not disclose authentication needs, rate limits, or the nature of the data (e.g., live vs cached). The search parameter's effect is not explained, and the output format is not hinted, even though an output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence with no extraneous words. However, it sacrifices completeness for brevity, missing key details about parameters and behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has one optional parameter and an output schema, the description is insufficient. It does not mention the search filter, output structure (e.g., list of commodity names/objects), or temporal scope (today's data). Sibling tools are not referenced, so the agent lacks context for correct use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, and the description does not explain the purpose of the 'search' parameter. While the schema shows it is an optional string that can be null, the description adds no semantic value, such as indicating it filters commodities by name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and the resource 'available commodities in today's Agmarknet data', which distinguishes it from sibling tools like list_markets (which lists markets) and others focused on prices. However, it could be more precise about the temporal scope (e.g., 'current date's data') to avoid ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool vs alternatives like list_markets or get_commodity_price. There is no mention of prerequisites, limitations, or comparison to siblings, leaving the agent without decision support.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_marketsC

List available markets (mandis) in today's Agmarknet data.

ParametersJSON Schema
NameRequiredDescriptionDefault
stateNo
commodityNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description does not disclose important behavioral traits such as filtering behavior (despite parameters), data freshness (today only), or any limitations. No annotations are present, so the description should compensate but fails.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short and to the point, but it omits crucial details about parameters and usage context. It is concise but not sufficiently informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is too brief. It does not cover the filtering functionality hinted by the parameters, nor does it differentiate from sibling tools. The output schema exists but is not mentioned. Overall, it lacks completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description does not describe or even mention the parameters (state, commodity). Since schema coverage is 0%, the description should explain what these parameters do, but it does not.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (list), the resource (markets/mandis), and the data context (today's Agmarknet data). It is distinct from sibling tools like list_commodities and get_commodity_price.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage context or comparison to alternatives is provided. The description does not help the agent decide when to choose list_markets over its siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 5 tool updatesv0.1.0
    • First observedcompare_markets
    • First observedget_commodity_price
    • First observedget_price_summary
    • First observedlist_commodities
    • First observedlist_markets

TDQS

A3.5/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: listing commodities/markets, fetching prices, comparing across markets, and summarizing prices. No overlaps.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (e.g., list_commodities, get_commodity_price).

Tool Count5/5

Five tools is appropriate for the domain of agricultural market price lookups, covering listing, retrieval, comparison, and summary without excess.

Completeness5/5

The tools cover the core operations for daily wholesale prices: listing available data points, retrieving individual prices, comparing markets, and getting statistical summaries. No obvious gaps for the stated scope.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides access to real-time and historical Indian stock data via Yahoo Finance API, enabling local LLMs to retrieve stock information through MCP-compatible agents like Claude Desktop and Cursor.
    2
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time crop price data from Indian government sources and agricultural web search capabilities. Enables AI chatbots to access comprehensive agricultural market information and news for farming-related queries.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time and historical Indian stock market data from NSE and BSE exchanges with 66 tools covering quotes, options chains, corporate actions, IPOs, and market analytics for LLM-powered financial analysis.
    42 npm
    12
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables plain English queries about US agricultural data, including historical crop statistics from NASS QuickStats and current cash grain prices from AMS Market News.
    -