Skip to main content
Glama
README.md
# Sri Lanka Data MCP Server

An MCP (Model Context Protocol) server that gives AI assistants like Claude Desktop, Claude Code, Cursor and VS Code Copilot tools to answer questions with real Sri Lankan public data: dengue cases and a 4-week dengue forecast, weather, and food prices.

Instead of the AI guessing, it calls a tool, gets the real numbers and tells you where they came from.

![Agent trajectories](assets/trajectories.png)

## Why I made this

MCP is the new standard way to connect AI assistants to tools and data, and almost every AI app supports it now. I had already built a dengue forecasting model and a text-to-SQL agent on this data, so I turned them into tools any assistant can use, and then tested how well an AI actually uses them.

## Tools

| Tool | What it does |
|---|---|
| `dengue_cases` | Dengue cases for a district or the whole country, by year, month or district (2006 to Sept 2026) |
| `dengue_forecast` | My model's forecast for the next 4 weeks per district, with a risk level |
| `rank_districts` | Rank districts by dengue cases, rainfall or temperature for a year |
| `food_price_trend` | Average retail food prices per year, for a loose name like "rice" or "coconut" |
| `list_commodities` | Which foods have prices and for which years |
| `get_data_guide` | Tables, columns, periods and sources |
| `run_sql` | Read-only SQL for anything the other tools don't cover |

It also has a `district_briefing` prompt and a `srilanka://data-guide` resource.

A few design choices that turned out to matter:

- **Every tool is marked read-only** with MCP tool annotations, so apps know it can't change anything.
- **District names are forgiving.** "colombo", "Moneragala" and "NuwaraEliya" all work.
- **Errors tell the AI how to fix the call.** An unknown district returns the list of valid districts, and an unknown food points to `list_commodities`. In the evaluation this is how the AI recovered when it guessed a wrong column name (right side of the picture above).
- **`run_sql` is locked down:** one SELECT only, blocked keywords, read-only database, no file or internet access, a 10 second timeout and 200 rows max.

## Evaluation

I connected Gemini (`gemini-3.5-flash-lite`, free tier) to the server over MCP, exactly like an assistant would, and asked it 30 questions with known answers. Every tool call was recorded, so I could check the whole trajectory and not just the final answer. I compared two designs:

| Design | Correct answers | Right tool on first call | Tool calls per question | Seconds |
|---|---|---|---|---|
| **7 specialised tools** | **30/30 (100%)** | **100%** | **1.4** | 12.1 |
| SQL tool only (`run_sql` + `get_data_guide`) | 26/30 (87%) | n/a | 2.2 | 13.5 |

![Evaluation results](assets/eval_results.png)

What I learned:

- **Good tools beat one generic tool.** With specialised tools the AI picked the right tool first every time and needed fewer calls.
- **Some answers need a tool, not a database.** The SQL-only design failed all 4 forecast questions because the forecast comes from a model, not a table. It did say "the database has no forecast" instead of inventing numbers, which is the right behaviour.
- **Helpful errors make agents recover.** In one question the AI wrote SQL with a wrong column (`district_name`), got an error, read the data guide and fixed it on the next call.
- **I found a bug in my own scoring.** One SQL-only answer said there was no forecast but mentioned "Matale" while talking about past cases, and my scorer counted it as correct. I changed that question to also require the forecast number (452) and re-scored everything. The table above is after the fix.

`tests/test_server.py` also checks the server directly over MCP (20 checks, no API key needed): correct numbers, name aliases, read-only annotations, helpful errors, blocked SQL and that the data is unchanged afterwards.

## Use it

```bash
git clone https://github.com/pamithudulwan892-max/srilanka-mcp-server.git
cd srilanka-mcp-server
python -m venv .venv
.venv\Scripts\pip install -r requirements.txt      # Windows
# .venv/bin/pip install -r requirements.txt        # Mac / Linux
```

Then add it to your AI app. Replace `PATH` with the folder you cloned into.

**Claude Desktop** (Settings > Developer > Edit Config, `claude_desktop_config.json`):
```json
{
  "mcpServers": {
    "srilanka-data": {
      "command": "PATH\\.venv\\Scripts\\python.exe",
      "args": ["PATH\\server.py"]
    }
  }
}
```

**Claude Code:**
```bash
claude mcp add srilanka-data -- PATH/.venv/Scripts/python.exe PATH/server.py
```

**Cursor** (`.cursor/mcp.json`) and **VS Code** (`.vscode/mcp.json`, use `"servers"` instead of `"mcpServers"`) take the same `command` and `args`.

Then ask things like "Which district has the highest dengue forecast?" or "How did coconut prices change from 2021 to 2025?".

To run it as a web server instead: `python server.py --http` (streamable HTTP on port 8000).

## Run the tests and evaluation

```bash
python tests/test_server.py     # 20 checks over MCP, no key needed
cp .env.example .env            # add a free Gemini key from aistudio.google.com
python evaluate.py              # 60 runs, about 20 minutes on the free tier
```

## Data

| Data | Period | Source |
|---|---|---|
| Weekly dengue cases, 26 health districts | late 2006 to Sept 2026 | Epidemiology Unit weekly reports, via [denguedatahub](https://github.com/thiyangt/denguedatahub) (GPL-3) |
| Weekly rainfall, temperature, humidity | same weeks | [Open-Meteo](https://open-meteo.com) (CC BY 4.0) |
| Monthly food prices, 44 markets | 2004 to Sept 2025 | [World Food Programme via HDX](https://data.humdata.org/dataset/wfp-food-prices-for-sri-lanka) (CC BY-IGO) |
| 4-week dengue forecast | after 13 Sept 2026 | my [Dengue Early Warning](https://github.com/pamithudulwan892-max/dengue-early-warning) model |

The database is built in my [text-to-SQL agent](https://github.com/pamithudulwan892-max/text-to-sql-agent) project.

## Limitations

- 30 questions is a small evaluation and I wrote the questions myself.
- The forecast is a snapshot from Sept 2026 data, not live.
- Results can vary a little between runs because the model is not fully deterministic.

## Author

Pamithu Dulwan - [GitHub](https://github.com/pamithudulwan892-max) | [LinkedIn](https://www.linkedin.com/in/pamithu-dulwan/)