Skip to main content
Glama

dhis2_validate_environment

Validate and troubleshoot DHIS2 development environment setup by checking components like Node.js version, CLI tools, browser settings, and network connectivity.

Instructions

Validate and troubleshoot DHIS2 development environment setup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
checkAllNoRun comprehensive environment validation
componentsNoSpecific components to validate
nodeVersionNoCurrent Node.js version
dhis2InstanceNoDHIS2 instance to test connectivity with
operatingSystemNoOperating system

Implementation Reference

  • The main handler function that executes the tool logic. It generates a comprehensive markdown report validating the DHIS2 development environment, checking Node.js version, package managers, DHIS2 CLI, browser settings, network connectivity, and CORS configuration. Includes automated scripts and troubleshooting guides.
    export function validateEnvironment(args: any): string {
      const { checkAll = false, components = [], nodeVersion, dhis2Instance, operatingSystem = 'unknown' } = args;
    
      const checks = checkAll ? [
        'node_version', 'npm_yarn', 'dhis2_cli', 'browser_settings', 'network_connectivity', 'cors_config'
      ] : components;
    
      return `# DHIS2 Development Environment Validation
    
    ## Environment Information
    - **Operating System**: ${operatingSystem.toUpperCase()}
    - **Node Version**: ${nodeVersion || 'Not provided'}
    - **DHIS2 Instance**: ${dhis2Instance || 'Not provided'}
    
    ## Validation Results
    
    ${checks.map((check: string) => generateEnvironmentCheck(check, { nodeVersion, dhis2Instance, operatingSystem })).join('\n\n')}
    
    ## Automated Validation Script
    
    \`\`\`bash
    #!/bin/bash
    # DHIS2 Environment Validator
    
    echo "🔍 DHIS2 Development Environment Validation"
    echo "============================================"
    
    # Node.js version check
    echo "📦 Checking Node.js version..."
    NODE_VERSION=$(node --version)
    echo "Node.js: $NODE_VERSION"
    
    if [[ "$NODE_VERSION" < "v16" ]]; then
      echo "❌ Node.js 16+ required"
    else
      echo "✅ Node.js version OK"
    fi
    
    # Package manager check
    echo "📦 Checking package managers..."
    if command -v npm &> /dev/null; then
      echo "✅ npm: $(npm --version)"
    else
      echo "❌ npm not found"
    fi
    
    if command -v yarn &> /dev/null; then
      echo "✅ yarn: $(yarn --version)"
    else
      echo "⚠️  yarn not found (recommended for DHIS2)"
    fi
    
    # DHIS2 CLI check
    echo "🔧 Checking DHIS2 CLI tools..."
    if command -v d2 &> /dev/null; then
      echo "✅ d2 CLI: $(d2 --version)"
    else
      echo "❌ d2 CLI not found"
      echo "Install: npm install -g @dhis2/cli"
    fi
    
    # Network connectivity check
    ${dhis2Instance ? `
    echo "🌐 Testing DHIS2 instance connectivity..."
    if curl -Is "${dhis2Instance}/api/system/info" | head -n 1 | grep -q "200 OK"; then
      echo "✅ DHIS2 instance reachable"
    else
      echo "❌ Cannot reach DHIS2 instance"
    fi
    ` : ''}
    
    echo "✅ Environment validation complete"
    \`\`\`
    
    ## Fix Common Issues
    
    ### Node.js Version Issues
    \`\`\`bash
    # Install Node Version Manager
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
    
    # Install and use Node.js 18 LTS
    nvm install 18
    nvm use 18
    nvm alias default 18
    \`\`\`
    
    ### Package Manager Issues
    \`\`\`bash
    # Install/Update yarn (recommended for DHIS2)
    npm install -g yarn
    
    # Clear package caches
    npm cache clean --force
    yarn cache clean
    \`\`\`
    
    ### DHIS2 CLI Issues
    \`\`\`bash
    # Install DHIS2 CLI tools
    npm install -g @dhis2/cli
    
    # Verify installation
    d2 --version
    d2 --help
    \`\`\`
    
    ## Development Environment Setup
    
    ### Complete Setup Script
    \`\`\`bash
    #!/bin/bash
    # Complete DHIS2 development environment setup
    
    echo "🚀 Setting up DHIS2 development environment..."
    
    # Install Node.js 18 LTS (if using nvm)
    nvm install 18
    nvm use 18
    
    # Install global tools
    npm install -g @dhis2/cli yarn
    
    # Verify installations
    echo "Node.js: $(node --version)"
    echo "npm: $(npm --version)"
    echo "yarn: $(yarn --version)"
    echo "DHIS2 CLI: $(d2 --version)"
    
    # Create development project
    mkdir my-dhis2-app
    cd my-dhis2-app
    
    # Initialize DHIS2 app
    d2 app scripts init my-app
    cd my-app
    
    # Install dependencies
    yarn install
    
    echo "✅ DHIS2 development environment ready!"
    echo "Run 'yarn start' to begin development"
    \`\`\`
    
    ## IDE Configuration
    
    ### VS Code Extensions
    \`\`\`json
    {
      "recommendations": [
        "ms-vscode.vscode-typescript-next",
        "bradlc.vscode-tailwindcss",
        "esbenp.prettier-vscode",
        "ms-vscode.vscode-eslint",
        "formulahendry.auto-rename-tag",
        "christian-kohler.path-intellisense"
      ]
    }
    \`\`\`
    
    ### VS Code Settings
    \`\`\`json
    {
      "editor.formatOnSave": true,
      "editor.defaultFormatter": "esbenp.prettier-vscode",
      "typescript.preferences.importModuleSpecifier": "relative",
      "emmet.includeLanguages": {
        "javascript": "javascriptreact"
      }
    }
    \`\`\`
    
    ## Troubleshooting Common Environment Issues
    
    ### Permission Issues (macOS/Linux)
    \`\`\`bash
    # Fix npm permissions
    sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
    
    # Alternative: Use nvm to avoid sudo
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
    \`\`\`
    
    ### Windows-Specific Issues
    \`\`\`powershell
    # Set execution policy (Windows PowerShell as Administrator)
    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
    
    # Install Node.js via Chocolatey
    choco install nodejs
    
    # Install yarn
    choco install yarn
    \`\`\`
    
    ### Network/Corporate Firewall Issues
    \`\`\`bash
    # Configure npm proxy (if behind corporate firewall)
    npm config set proxy http://proxy.company.com:8080
    npm config set https-proxy http://proxy.company.com:8080
    
    # Configure yarn proxy
    yarn config set proxy http://proxy.company.com:8080
    yarn config set https-proxy http://proxy.company.com:8080
    \`\`\`
    `;
  • src/index.ts:1212-1222 (registration)
    The tool dispatch/registration in the main MCP server handler. Calls the validateEnvironment function from debugging-helpers.ts with user arguments and returns the markdown result.
    case 'dhis2_validate_environment':
      const envArgs = args as any;
      const envValidation = validateEnvironment(envArgs);
      return {
        content: [
          {
            type: 'text',
            text: envValidation,
          },
        ],
      };
  • Permission mapping registration. Associates the tool with 'canDebugApplications' permission in the TOOL_PERMISSIONS map.
    ['dhis2_validate_environment', 'canDebugApplications'],
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'validate and troubleshoot,' implying diagnostic and potentially corrective actions, but doesn't specify what the tool actually does (e.g., runs checks, provides reports, suggests fixes) or any behavioral traits like side effects, permissions needed, or output format. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Validate and troubleshoot DHIS2 development environment setup.' It's front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. This exemplifies conciseness and good structure.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what validation entails, what troubleshooting actions are taken, or what the output looks like. For a diagnostic tool with multiple parameters, more context is needed to guide effective use, making this inadequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so parameters like 'checkAll' and 'components' are well-documented in the schema itself. The description adds no additional semantic context about parameters beyond the schema, such as how they interact or typical use cases. Given the high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Validate and troubleshoot DHIS2 development environment setup.' It specifies the action (validate/troubleshoot) and target (DHIS2 development environment setup), which is clear and specific. However, it doesn't explicitly differentiate from sibling tools like 'dhis2_setup_dev_environment' or 'dhis2_diagnose_cors_issues,' which limits it to a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, context for validation (e.g., during setup vs. debugging), or how it differs from related tools like 'dhis2_diagnose_cors_issues' or 'dhis2_setup_dev_environment.' This lack of explicit usage instructions results in a low score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Dradebo/dhis2-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server