Kazakhstan Open Data (data.egov.kz)

v0.2.0
io.github.almatulymiras688-lgtm/kz-opendata-mcp Checked 1 day ago Published 5 days ago

Search and analyze ~4000 datasets from Kazakhstan's open government data portal data.egov.kz.

Ask AI assistants about Kazakhstan's open government data. An MCP server for data.egov.kz, Kazakhstan's official open data portal (about 4,000 government datasets: schools, hospitals, pharmacies, budgets, prices, regions and more). Connect it to Claude Desktop, Claude Code, Cursor or any other MCP client, and ask questions in plain language. The assistant finds the right dataset, reads its fields, and filters or aggregates the data itself.

Summary extracted from the README.

English · Русский · Қазақша

An MCP server for data.egov.kz, Kazakhstan's official open data portal (about 4,000 government datasets: schools, hospitals, pharmacies, budgets, prices, regions and more).

Connect it to Claude Desktop, Claude Code, Cursor or any other MCP client, and ask questions in plain language. The assistant finds the right dataset, reads its fields, and filters or aggregates the data itself.

"How many schools are there in Arys, and what types are they?"

The assistant calls search_datasets("школ"), then get_dataset_info("mektepter_tizimi"), then aggregate_dataset(group_by="name7", filters={"name": "Арыс"}), and answers: 39 schools. 22 are general secondary schools (ЖОМ), 9 are small-class primary schools (ШЖБМ), 5 are primary schools (БМ)…, with a link to the source dataset.

No API key needed. The server uses the portal's public endpoints.

Demo

Real answers from the portal, shortened (Claude Desktop with this server, November 2026):

You: Count schools in Turkestan region by type.

Claude: (search_datasets → get_dataset_info → aggregate_dataset) According to the "List of schools" dataset (1,040 rows, 2016): general secondary (ЖОМ) 729, small-class primary (ШЖБМ) 68, НОМ 64, small-class secondary (ШЖЖОМ) 55, primary (БМ) 40, ОМ 24… Note: about 14 rows are district totals mixed into the data.

You: Which district has the most kindergartens?

Claude: The Turkestan dataset on the portal is empty, but Abai region has fresh data (December 2025): 177 kindergartens, most of them in Semey (74), then Ayagoz (12) and Urzhar (5).

flowchart LR
    U["You: a question in plain language"] --> A["AI assistant<br/>Claude · Cursor · …"]
    A -- MCP --> S["kz-opendata-mcp"]
    S -- "search · meta · query" --> P[("data.egov.kz<br/>~4000 datasets")]
    P --> S --> A --> U

Tools

Tool What it does
search_datasets Searches the catalogue by keywords (in Russian, Kazakh or English). Returns dataset ids, titles, descriptions and tags.
get_dataset_info Returns the title, description, owner agency, update date, versions, row count, and field labels. Field names on the portal are often opaque (name1, name2…), and the labels explain what they mean.
query_dataset Reads rows with field filters, free-text search, paging, sorting and a field selection. Accepts a raw Elasticsearch query for advanced use, such as geo-distance.
aggregate_dataset Computes count, sum, avg, min or max, optionally grouped by a field. Numbers stored as text ("1 219", "12,5") are parsed.

Installation

You need uv (brew install uv, or pip install uv).

Claude Desktop

Open Settings → Developer → Edit Config and add the server to claude_desktop_config.json:

{
  "mcpServers": {
    "kz-opendata": {
      "command": "uvx",
      "args": ["kz-opendata-mcp"]
    }
  }
}

Until the package is on PyPI, use "args": ["--from", "git+https://github.com/almatulymiras688-lgtm/kz-opendata-mcp", "kz-opendata-mcp"].

Then restart Claude Desktop. If Claude Desktop can't find uvx, replace it with the full path from which uvx.

macOS: Claude Desktop can't read files in ~/Documents, ~/Desktop or ~/Downloads (privacy protection), so a server installed there fails with PermissionError: Operation not permitted. Keep the source anywhere you like, but install it as a tool with uv tool install --python 3.12 /path/to/kz-opendata-mcp and use ~/.local/bin/kz-opendata-mcp (as a full path) as the command.

Claude Code

claude mcp add kz-opendata -- uvx kz-opendata-mcp

Cursor

Add the same block as for Claude Desktop to ~/.cursor/mcp.json.

Remote server (HTTP)

Public instance: https://kz-opendata-mcp.onrender.com/mcp. Add it in claude.ai under Settings → Connectors → Add custom connector (no installation needed), or in ChatGPT with developer mode. It runs on Render's free plan, so the first request after a quiet period can take about a minute.

The same server can run as a web service, so it can be used without installing anything: in claude.ai (Settings → Connectors → Add custom connector), ChatGPT developer mode, or any client that supports remote MCP.

kz-opendata-mcp --transport http --host 0.0.0.0 --port 8000   # endpoint: http://HOST:8000/mcp
docker build -t kz-opendata-mcp . && docker run -p 8000:8000 kz-opendata-mcp

Free hosting: the repository has a render.yaml, so on Render choose New → Blueprint, pick this repository, and you get https://<name>.onrender.com/mcp (the free plan sleeps after 15 minutes without requests and takes about a minute to wake up). GET /health returns the server status.

From source

git clone https://github.com/almatulymiras688-lgtm/kz-opendata-mcp
cd kz-opendata-mcp
uv venv && uv pip install -e ".[dev]"
.venv/bin/kz-opendata-mcp            # stdio server
npx @modelcontextprotocol/inspector .venv/bin/kz-opendata-mcp   # try it in the browser

Example questions

  • "Find datasets about pharmacies in Astana and show me 10 of them."
  • "Which districts of Turkistan region have the most schools?"
  • "What is the average number of pupils per school in Arys?"
  • "Find datasets about the state budget. Which agency publishes them, and when were they last updated?"
  • "Мектептер туралы деректер жинағын тауып, аудандар бойынша санын көрсет."

Configuration

Variable Default Meaning
EGOV_BASE_URL https://data.egov.kz Portal address
EGOV_TIMEOUT 30 HTTP timeout in seconds
MCP_TRANSPORT stdio stdio or http (same as --transport)
HOST, PORT 127.0.0.1, 8000 Address for the HTTP mode

How it works

The server uses four public parts of the portal:

  • /datasets/search?text=…: the catalogue search page (HTML)
  • /datasets/view?index=…: the dataset page, which lists the available versions (HTML)
  • /meta/{dataset}/{version}: metadata and field labels in Kazakh, Russian and English (JSON)
  • /api/detailed/{dataset}/{version}?source={…}: rows, using an Elasticsearch 1.x query (JSON)

/api/v4/… requires a personal API key, and the server doesn't need it.

Limitations:

  • The portal stores most values as text, so the portal itself can't compute sums or averages. aggregate_dataset pages through up to 20,000 matching rows and computes the result locally. It reports truncated: true if there were more.
  • Many datasets haven't been updated for years. The modified field in get_dataset_info shows when each was last changed.
  • Field filters use full-text matching, so {"name": "Арыс"} also matches "Арыс қаласы".

Development

uv venv && uv pip install -e ".[dev]"
pytest              # offline tests (HTTP is mocked)
pytest -m live      # smoke test against the real portal
ruff check . && ruff format --check .

Ideas for the roadmap

  • Publish to PyPI so uvx kz-opendata-mcp works
  • Remote HTTP mode for claude.ai, ChatGPT and other web clients
  • MCP resources for categories and government agencies
  • Results cache
  • Geo-search helper ("pharmacies within 1 km of a point")
  • Optional /api/v4 support with an API key
  • Integration with other KZ sources (stat.gov.kz, adilet.zan.kz)

License

MIT. The data belongs to its publishers on data.egov.kz. This project is not affiliated with the Government of the Republic of Kazakhstan.