Skip to main content
Glama
KNithin1976
by KNithin1976

agri-mcp

An MCP (Model Context Protocol) server that gives Claude access to live agricultural weather data via the OpenWeather API. Designed to run as a local tool server for Claude Desktop.

Features

  • get_weather — Get current weather conditions (temperature, description, humidity) for any city

  • get_forecast — Get a multi-day weather forecast for any city

Related MCP server: Weather MCP Server

Requirements

Setup

1. Clone / create the project folder

mkdir agri-mcp
cd agri-mcp

2. (Optional) Create a virtual environment

python -m venv venv
venv\Scripts\activate

3. Install dependencies

pip install mcp httpx python-dotenv

4. Add your OpenWeather API key

Create a .env file in the project root (only needed for local/standalone testing — Claude Desktop passes env vars directly from its config):

OPENWEATHER_API_KEY=your_api_key_here

5. Test the server standalone

python main.py

The server communicates over stdio, so it won't print anything visible — if it doesn't immediately crash, it's working. Press Ctrl+C to stop it.

Connecting to Claude Desktop

Edit your Claude Desktop config file:

notepad "%APPDATA%\Claude\claude_desktop_config.json"

Add the following (adjust the path to match where main.py actually lives on your machine):

{
  "mcpServers": {
    "agri-data": {
      "command": "python",
      "args": [
        "C:\\Users\\YOUR_USERNAME\\PycharmProjects\\PythonProject\\agri-mcp\\main.py"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "your_api_key_here"
      }
    }
  }
}

Then fully quit Claude Desktop (not just close the window — end the process from Task Manager or system tray) and reopen it. Check Settings → Developer (or the MCP servers panel) to confirm agri-data shows as connected.

Project Structure

agri-mcp/
├── main.py          # MCP server entry point and tool definitions
├── .env             # Local environment variables (not committed)
└── README.md

Troubleshooting

Issue

Fix

Server disconnected in Claude Desktop

Check the config JSON structure — command, args, and env must be nested inside mcpServers.agri-data, not at the top level

python not recognized

Disable the Python App Execution Alias in Windows Settings, or use the full path to python.exe

Old config still showing after edit

Fully quit Claude Desktop (Task Manager → End Task) and reopen — closing the window alone doesn't reload the config

OPENWEATHER_API_KEY is not set error

Confirm the key is present in both the config's env block and/or your local .env file

Security Note

Do not commit your .env file or claude_desktop_config.json with a real API key to version control. If a key is ever accidentally exposed (e.g. shared in a screenshot or chat), regenerate it from your OpenWeather account dashboard.

License

MIT

Related MCP Connectors

Related MCP Servers