DHIS2 MCP Server

DHIS2 MCP Server

Connects DHIS2 health information systems to AI assistants via the Model Context Protocol, enabling natural language queries for analytics, metadata, and tracker data.

Category
访问服务器

README

DHIS2 MCP Server

License: MIT Python 3.10+ MCP

Connect any DHIS2 instance to Claude and other AI assistants through the Model Context Protocol. Point it at a URL, give it credentials, and your AI client can explore the org unit hierarchy, search metadata, and pull analytics in plain language. No custom integration per instance.

DHIS2 is the world's largest health information management system, used as the national HMIS in more than 80 countries. This server turns it into a tool your AI assistant can actually query.


What it does

Ask your assistant questions like:

"Connect to our DHIS2 and show the ANC 1st visit coverage trend for Dhaka division over the last 12 months."

and it will resolve the indicator and org unit names to UIDs, run the analytics query, and explain the result. No UIDs, no API syntax, no manual exports.

Features

Capability Tools
Connection dhis2_ping, dhis2_whoami, dhis2_api_overview
Metadata search search_metadata, list_org_units, org_unit_children, list_data_sets, list_programs
Aggregate data get_analytics, get_analytics_raw, get_data_value_set
Tracker / events get_events, get_enrollments
Resources live system/info, relative-period reference
Prompts explore_instance, indicator_trend
  • Works with any instance via environment variables
  • Supports personal access tokens or basic auth
  • Resolves names to UIDs automatically, so users never touch identifiers
  • Name-resolved, tabular analytics output ready for analysis
  • Self-signed cert and API-version overrides for national deployments

Quick start

1. Install

git clone https://github.com/ahasan722/dhis2-mcp-server.git
cd dhis2-mcp-server

# with uv (recommended)
uv venv && source .venv/bin/activate
uv pip install -e .

# or with pip
python -m venv .venv && source .venv/bin/activate
pip install -e .

2. Configure

cp .env.example .env
# edit .env with your instance URL and credentials

Try it against the public DHIS2 demo first (no setup needed):

DHIS2_BASE_URL=https://play.im.dhis2.org/stable-2-41-3
DHIS2_USERNAME=admin
DHIS2_PASSWORD=district

3. Test with MCP Inspector

mcp dev src/dhis2_mcp/server.py

Open the Inspector, list the tools, and run dhis2_ping. You should see the instance version come back.

4. Connect to Claude Desktop

Add to your claude_desktop_config.json (%APPDATA%\Claude\ on Windows, ~/Library/Application Support/Claude/ on macOS):

{
  "mcpServers": {
    "dhis2": {
      "command": "dhis2-mcp",
      "env": {
        "DHIS2_BASE_URL": "https://play.im.dhis2.org/stable-2-41-3",
        "DHIS2_USERNAME": "admin",
        "DHIS2_PASSWORD": "district"
      }
    }
  }
}

Restart Claude Desktop. The DHIS2 tools appear in the tools menu.

Configuration reference

Variable Required Description
DHIS2_BASE_URL yes Instance URL, with or without /api
DHIS2_PAT one of Personal access token (d2pat_...)
DHIS2_USERNAME / DHIS2_PASSWORD one of Basic-auth credentials
DHIS2_API_VERSION no Pin an API version, e.g. 40
DHIS2_VERIFY_SSL no false for self-signed certs
DHIS2_TIMEOUT no Request timeout in seconds (default 60)

A personal access token is safer than a password and is recommended for shared or hosted deployments.

Example session

You:  Is the connection working?
AI:   [dhis2_ping] Connected to DHIS2 version 2.41.3.

You:  What's the trend of BCG doses given in Bo district last 12 months?
AI:   [search_metadata] found indicator "BCG doses given"
      [list_org_units]  found org unit "Bo"
      [get_analytics]   periods=LAST_12_MONTHS
      Here is the monthly trend ... (table + summary)

Architecture

src/dhis2_mcp/
├── config.py        # env-driven settings, URL normalisation
├── client.py        # httpx wrapper: auth, paging, error handling
├── server.py        # FastMCP instance, resources, prompts
└── tools/
    ├── system.py    # connection + instance info
    ├── metadata.py  # name → UID discovery
    ├── analytics.py # aggregate queries + raw data values
    └── tracker.py   # events + enrollments

The model never needs a UID: every data tool is paired with a metadata search tool, and the server instructions tell the assistant to resolve names first.

Security notes

  • Credentials are read from the environment, never hard-coded or sent to the model.
  • Prefer a personal access token scoped to read-only authorities.
  • .env is git-ignored. Do not commit credentials.
  • This server only reads; it defines no write/delete tools by default.

Development

pip install -e ".[dev]"
pytest          # config + import tests (no live instance needed)
ruff check .

Roadmap

  • [ ] Write tools (data value import) behind an explicit opt-in flag
  • [ ] Streamable HTTP transport for shared hosting
  • [ ] Caching layer for metadata lookups
  • [ ] Org unit GeoJSON export for mapping

Contributing

Issues and pull requests are welcome. Please open an issue describing the DHIS2 version and use case before large changes.

License

MIT. See LICENSE.

Acknowledgements

Built for the public health data community. DHIS2 is developed by the HISP Centre, University of Oslo. MCP is an open standard from Anthropic.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选