This guide is for someone brand-new to coding, Cursor, and DHIS2. Follow the steps exactly. Copy and paste where told. If anything feels confusing, don’t worry—just do the next step.
- Use Cursor (an AI coding editor) + this DHIS2 MCP “helper” to build a DHIS2 app with almost no code knowledge.
- Click buttons → MCP runs specialized DHIS2 tools → You get ready-to-use app snippets.
- A Mac with internet
- Node.js 18 or newer
- Git
# Install Homebrew if you don’t have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Node.js 18
brew install node@18
# Make sure Node is on 18+
node -v# Pick a folder you like and open Terminal
cd ~/Documents
# Download the project
git clone https://github.com/yourusername/dhis2-mcp.git
cd dhis2-mcp
# Install and build (first time takes a bit)
npm install
npm run buildYou have two easy options. Either one is fine.
- Open Cursor
- Go to Settings → MCP (Model Context Protocol) → Add Server (or “Custom Server”)
- Fill it in:
- Name:
dhis2-mcp - Command:
node - Args:
dist/index.js - Working directory: the folder you cloned, e.g.
/Users/yourname/Documents/dhis2-mcp
- Name:
- Save. You should see
dhis2-mcpin Cursor’s Tools list for your chats.
# In the project folder
npm startLeave that Terminal window open. In Cursor, open a chat and make sure the tool dhis2-mcp is available.
We’ll use the public demo server so you don’t need to set up anything.
- Base URL:
https://play.dhis2.org/2.40.4 - Username:
admin - Password:
district
In Cursor:
- Open a chat
- Make sure the tool
dhis2-mcpis enabled for that chat - Run the tool named
dhis2_configure - Fill the boxes:
baseUrl:https://play.dhis2.org/2.40.4username:adminpassword:district
- Run it. You should get “Successfully connected …”
If it fails, check your internet, then try again.
We’ll scaffold a DHIS2 app using official tooling.
In Terminal (not in Cursor):
# In a separate folder where you keep projects
cd ~/Documents
# Create a new DHIS2 app (you’ll be asked a few simple questions)
npx @dhis2/cli-app-scripts init my-health-app
cd my-health-app
# Start the dev server
yarn install
yarn startThis opens a browser tab at your local app. Keep it running.
Now, we’ll ask the MCP to generate ready-to-copy UI components and configuration that match DHIS2 best practices.
In Cursor (chat with dhis2-mcp tools):
- Generate a form (names, dates, file upload, validation):
- Run:
dhis2_generate_ui_form_patterns - Example options to fill:
componentName:DataElementFormincludeValidation:trueincludeDatePicker:trueincludeFileUpload:trueincludeMultiSelect:true
- Run:
- Generate a data table + cards + modal (with loading and empty states):
- Run:
dhis2_generate_ui_data_display - Example:
componentName:DataElementDisplayincludeTable:trueincludePagination:trueincludeCards:trueincludeModal:true
- Run:
- Generate navigation layout (header, sidebar, breadcrumbs, tabs):
- Run:
dhis2_generate_ui_navigation_layout - Example:
componentName:AppLayoutincludeHeaderBar:trueincludeSidebar:trueincludeBreadcrumbs:trueincludeTabs:true
- Run:
- Generate design-system tokens (colors, fonts, spacing, dark mode):
- Run:
dhis2_generate_design_system - Example:
theme:defaultenableDarkMode:true
- Run:
Each tool returns a Markdown page. Copy the code blocks into your app:
- Components: put in
src/components/YourName.jsx(x) - Styles/tokens: keep in a
src/theme/or similar - Then import them into
src/App.jsx(x)and render them
Your app should use @dhis2/app-runtime queries.
Ask the MCP to generate an example for you:
- Run:
dhis2_generate_app_runtime_config - Paste the example provider + queries into your app (follow the instructions it prints)
- Keep dev server running (
yarn start) and check your UI
If you also want an Android app UI (using Compose):
- Run:
android_generate_material_form(form with validation/date/multi-select) - Run:
android_generate_list_adapter(lists) - Run:
android_generate_navigation_drawer(drawer layout) - Run:
android_generate_bottom_sheet(bottom sheet) These output Kotlin/Compose snippets you copy into your Android project.
- “Generate a DHIS2 form for creating data elements with name, value type, and validation.”
- “Give me a data table with pagination and loading states.”
- “Add a design system with dark mode and compact spacing.”
- “Help connect my app to DHIS2 Play server and render data elements.”
You don’t need fancy words. Be literal and specific.
- Can’t connect to DHIS2: Check the URL. Try the demo
https://play.dhis2.org/2.40.4+admin/district. - Dev server shows errors: Stop it and
yarn startagain. - CORS/auth errors in browser: Ask the MCP tool
dhis2_diagnose_cors_issuesordhis2_debug_authenticationwith your details. It prints fixes. - Stuck? Ask the AI: “Explain this error in plain English, and fix it.”
- Build your app:
yarn build - Talk to your DHIS2 admin to install your app package or use DHIS2 App Hub docs for publishing.
- DHIS2: A platform for health data apps.
- MCP: A helper that gives Cursor superpowers (special tools for DHIS2).
- Tool: A button you click in Cursor that runs something useful (like “make a form”).
- Scaffold: A starter app the computer creates for you.
You can make more screens by running more tools and pasting the code into your app. If you get lost, say: “Walk me through the next step like I’m new.”