Skip to content

EPFLiGHT/talk2yourdata

Repository files navigation

Talk2YourData MCP - DHIS2 Conversational Analytics

Talk2YourData MCP is a production-ready AI orchestrator that enables natural language querying of DHIS2 health data. It combines LangGraph workflow orchestration with the Model Context Protocol (MCP) to provide an intelligent, conversational interface for health data analysts to explore DHIS2 analytics without needing to know the API.

Overview

Talk2YourData transforms natural language questions into DHIS2 analytics queries through a 4-part AI workflow:

  • Part A: Query understanding and decomposition
  • Part B: Parameter discovery (organization units, data elements, periods)
  • Part C: Validation and DHIS2 data retrieval
  • Part D: Answer generation with iterative refinement

For detailed architectural design and workflow patterns, see docs/ARCHITECTURE.md.

Workflow Implementation

The system is built on:

  • LangGraph: State machine orchestration with conditional routing and parallel execution
  • Model Context Protocol (MCP): Standardized interface between LLMs and DHIS2 API tools
  • LangChain: LLM abstractions, structured outputs, and message handling

The workflow uses parallel subgraph execution for parameter discovery, automatic ambiguity detection with human-in-the-loop clarification, and iterative answer refinement. For implementation details, see src/talk2yourdata_mcp/README.md.

Running the Application

Talk2YourData can be used through two interfaces:

Command-Line Interface (CLI)

Interactive terminal application with real-time progress tracking, session management, and debug capabilities.

Quick start:

uv run talk2yourdata-mcp

See src/talk2yourdata_mcp/cli/README.md for complete CLI documentation.

Web Interface

FastAPI backend with React frontend, featuring Server-Sent Events (SSE) streaming, visual parameter discovery, and chat history.

Quick start:

# Backend
uv run uvicorn src.talk2yourdata_mcp.webapp.main:app --port 8000

# Frontend (separate terminal)
cd src/webapp/frontend && npm run dev

See src/webapp/README.md for complete web interface documentation.

Prerequisites

  • Python 3.11+ (tested with Python 3.13.7)
  • uv package manager (or pip)
  • DHIS2 instance with API access
  • OpenAI API access (or compatible LLM API)

Installation

  1. Clone the repository:
git clone <repository-url>
cd dhis2-mcp-project
  1. Install dependencies:
# Basic installation
uv sync

# Development installation (includes testing tools)
uv sync --all-extras

# Or using pip
pip install -e .

Configuration

Configuration is managed through environment variables. Create a .env file in the project root:

# DHIS2 Configuration
DHIS2_API_URL=https://your-dhis2-instance.org/api
DHIS2_API_TOKEN=your_dhis2_api_token

# LLM Configuration
LLM_API_URL=https://api.openai.com/v1
LLM_API_KEY=your_openai_api_key
LLM_MODEL_NAME=gpt-4o
LLM_TEMPERATURE=0.2

# Workflow Configuration
MAX_REFINEMENT_LOOPS=3
MAX_STEPS=20

See docs/CONFIGURATION.md for all configuration options.

Testing

The project uses a comprehensive testing strategy:

  • Health checks: Verify LLM, MCP, and DHIS2 connectivity
  • Node tests: Test individual workflow components
  • Workflow tests: Test multi-node interactions
  • End-to-end tests: Test complete workflow with real DHIS2 queries
# Run health checks first
uv run pytest tests/health -v

# Run all tests
uv run pytest

For detailed testing documentation, see tests/README.md.

Documentation

About

Talk2YourData MCP is a production-ready AI orchestrator that enables natural language querying of DHIS2 health data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors