Metadata-Version: 2.5
Name: ilostat-mcp
Version: 0.1.0
Summary: MCP server exposing ILOSTAT employment and wage data to AI agents
Project-URL: Homepage, https://github.com/mrakelinggar/ilostat-mcp
Project-URL: Repository, https://github.com/mrakelinggar/ilostat-mcp
Project-URL: Issues, https://github.com/mrakelinggar/ilostat-mcp/issues
Author-email: Rake Anggoro <rake.linggar@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: employment,ilo,ilostat,labour-statistics,mcp,sdmx,wages
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.11
Requires-Dist: beautifulsoup4<5.0,>=4.12
Requires-Dist: cloudscraper<2.0,>=1.2
Requires-Dist: fastmcp<4.0,>=2.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http<3.0,>=1.20
Requires-Dist: opentelemetry-sdk<3.0,>=1.20
Requires-Dist: pandas<4.0,>=2.0
Requires-Dist: python-dotenv<2.0,>=1.0
Requires-Dist: sdmx1<3.0,>=2.0
Requires-Dist: structlog<26.0,>=23.0
Provides-Extra: dev
Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# ilostat-mcp

MCP server giving AI agents access to ILOSTAT employment and wage data, with automatic methodology-break detection.

## Installation

Requires [uv](https://docs.astral.sh/uv/getting-started/installation/). Add this to your MCP client config. For Claude Desktop, edit `claude_desktop_config.json` (Settings → Developer → Edit Config):

```json
{
  "mcpServers": {
    "ilostat-mcp": {
      "command": "uvx",
      "args": ["ilostat-mcp"]
    }
  }
}
```

Restart Claude Desktop. `uvx` downloads the package from PyPI and runs it — no separate install step. Confirm **ilostat-mcp** appears in the tools panel before running queries.

If Claude Desktop reports that `uvx` cannot be found, replace `"uvx"` with its full path (run `which uvx` on macOS/Linux or `where uvx` on Windows). Desktop apps do not always see the same PATH as your terminal.

### Alternative — pip

```bash
pip install ilostat-mcp
```

Then use `"command": "ilostat-mcp"` (no `args`) in the config above.

## Tools

| Tool | Purpose |
|---|---|
| `search_indicators(keyword)` | Find ILOSTAT dataflows by keyword. Dataflow IDs act as filters (per country, age, sex) rather than a flat indicator list, so this searches titles and descriptions. |
| `get_countries()` | List valid country codes from the `CL_AREA` codelist. |
| `get_indicator_metadata(dataflow_id)` | Definition, units, source, and last-updated date for a dataflow. |
| `get_time_series(dataflow_id, country, start, end)` | Raw data pull. Always includes a `_breaks` field — every series comes with its break status. |
| `get_yoy_change(dataflow_id, country, year)` | Year-over-year % change. |
| `get_cagr(dataflow_id, country, start, end)` | Compound annual growth rate. Warns or refuses if the range spans a detected methodology break. |
| `get_trend(dataflow_id, country, start, end)` | Linear trend and slope. Same break-spanning rule as `get_cagr`. |

## Methodology-break detection

Every `get_time_series` call automatically checks two signals: ILOSTAT's own break flag (`obs_status = "B"`, which catches survey redesigns that keep the same name) and changes in the survey source. Each break lists which signal found it. When a break falls inside the range of `get_yoy_change`, `get_cagr` or `get_trend`, the result carries a `_break_warning` — a trend line through a methodology break is a wrong number that looks right.

Example — `get_cagr("DF_UNE_DEAP_SEX_AGE_RT", "AUS", "2015", "2020")`. ILOSTAT flags a break in Australia's series in 2018, but the survey name is the same on both sides, so a source comparison alone would miss it:

```json
"_breaks": [{"year": "2018",
             "source_before": "LFS - Labour Force Survey",
             "source_after": "LFS - Labour Force Survey",
             "reasons": ["ilostat_break_flag"]}],
"_break_warning": "Methodology break within 2015-2020 at 2018 (ILOSTAT flags a break in series). Values across a methodology break are not directly comparable — interpret this result with caution."
```

## Data freshness

Everything comes from ILOSTAT's live SDMX API and is kept in memory for up to 24 hours, so repeated questions don't re-download the same data. An answer can therefore be up to 24 hours behind the live site; restarting the server always fetches fresh. Nothing is stored on disk.

## Benchmark

A hallucination benchmark comparing bare-LLM vs. MCP-equipped agent answers across 30+ questions with ground truth pulled from the live ILOSTAT API. Results in [`benchmark/`](https://github.com/mrakelinggar/ilostat-mcp/tree/main/benchmark).

## Development

```bash
uv sync
uv run pytest                       # live API tests
uv run ruff check src/ tests/       # lint
uv run ruff format src/ tests/      # format
uv run mypy src/                    # type check
```

CI runs on every push: lint → type check → tests.

## Acknowledgements

Benchmark ground truth verified against live ILOSTAT data by Kanza Nabeela Puteri.

## License

MIT — see [LICENSE](https://github.com/mrakelinggar/ilostat-mcp/blob/main/LICENSE).
