Skip to main content
Glama

dhis2_fix_proxy_configuration

Generate and fix proxy configurations for local development to connect with DHIS2 instances, supporting webpack, React, Vite, and custom setups.

Instructions

Generate proxy configuration and fixes for local development against DHIS2 instances

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
proxyTypeYesType of proxy configuration needed
targetInstanceYesTarget DHIS2 instance URL
localPortNoLocal development port (default: 3000)
authenticationNo
sslOptionsNo

Implementation Reference

  • MCP tool handler implementation. Extracts proxy configuration arguments and calls generateProxyConfiguration helper to produce a markdown configuration guide, which is returned as tool response content.
    case 'dhis2_fix_proxy_configuration':
      const proxyArgs = args as any;
      const proxyConfig = generateProxyConfiguration(proxyArgs);
      return {
        content: [
          {
            type: 'text',
            text: proxyConfig,
          },
        ],
      };
  • Main helper function that generates detailed proxy configuration markdown for different proxy types (webpack_dev_server, create_react_app, vite, custom_express). Includes testing commands, troubleshooting, security notes, and environment variables.
    export function generateProxyConfiguration(args: any): string {
      const { proxyType, targetInstance, localPort = 3000, authentication, sslOptions = {} } = args;
    
      return `# Proxy Configuration for DHIS2 Development
    
    ## ${proxyType.replace(/_/g, ' ').toUpperCase()} Configuration
    
    ${generateProxyConfig(proxyType, targetInstance, localPort, authentication, sslOptions)}
    
    ## Testing Proxy Configuration
    
    ### Test Proxy Connection
    \`\`\`bash
    # Test direct connection to DHIS2
    curl ${targetInstance}/api/me
    
    # Test through proxy  
    curl http://localhost:${localPort}/api/me
    \`\`\`
    
    ### Browser Testing
    1. Start your application with proxy enabled
    2. Open browser dev tools Network tab
    3. Navigate to your application
    4. Check that API requests go to localhost:${localPort}
    5. Verify requests are forwarded to ${targetInstance}
    
    ## Common Proxy Issues and Solutions
    
    ### Issue: 502 Bad Gateway
    **Causes**:
    - Target DHIS2 instance is unreachable
    - Authentication credentials are incorrect
    - SSL certificate verification failing
    
    **Solutions**:
    - Verify target instance URL: ${targetInstance}
    - Check authentication credentials
    - ${sslOptions.secure === false ? 'SSL verification is disabled (good for development)' : 'Consider disabling SSL verification for development'}
    
    ### Issue: Authentication Not Working
    **Solutions**:
    - Ensure credentials are correct: ${authentication?.username || '[username]'}
    - Check if user account is locked
    - Verify proxy is forwarding auth headers
    
    ### Issue: CORS Still Occurring  
    **Solutions**:
    - Restart development server after proxy configuration
    - Clear browser cache completely
    - Check proxy configuration syntax
    
    ## Security Considerations
    
    ### Development Environment
    ✅ **Safe for development**:
    - Using proxy to avoid CORS issues
    - Credentials stored in configuration files
    ${sslOptions.secure === false ? '- SSL verification disabled for development certificates' : ''}
    
    ⚠️ **Security reminders**:
    - Never commit credentials to version control
    - Use separate development credentials
    - Enable SSL verification in production
    
    ### Production Environment
    ❌ **Not suitable for production**:
    - This proxy configuration is for development only
    - Production should use proper authentication flows
    - Enable all security features for production deployment
    
    ## Environment Variables
    
    Create a \`.env.local\` file:
    \`\`\`bash
    # Proxy configuration
    DHIS2_PROXY_TARGET=${targetInstance}
    DHIS2_PROXY_USERNAME=${authentication?.username || 'your-username'}
    DHIS2_PROXY_PASSWORD=${authentication?.password || 'your-password'}
    PROXY_PORT=${localPort}
    \`\`\`
    
    ## Alternative Solutions
    
    ### 1. DHIS2 CLI Proxy
    \`\`\`bash
    # Use built-in DHIS2 CLI proxy
    yarn start --proxy
    \`\`\`
    
    ### 2. Local DHIS2 Instance
    \`\`\`bash
    # Set up local development instance
    npx @dhis2/cli cluster init
    d2 cluster up
    \`\`\`
    
    ### 3. Browser Extension
    - Use CORS browser extensions for development
    - ⚠️ Remember to disable in production
    `;
    }
  • Permission registration mapping TOOL_PERMISSIONS that associates the tool 'dhis2_fix_proxy_configuration' with required permission 'canDebugApplications'. Used by filterToolsByPermissions to control tool visibility based on user permissions.
    private static readonly TOOL_PERMISSIONS = new Map<string, keyof UserPermissions | Array<keyof UserPermissions>>([
      // Configuration and connection
      ['dhis2_configure', 'canViewSystemInfo'],
      ['dhis2_get_system_info', 'canViewSystemInfo'],
      
      // Metadata operations - Data Elements
      ['dhis2_list_data_elements', 'canViewMetadata'],
      ['dhis2_create_data_element', 'canCreateMetadata'],
      ['dhis2_update_data_element', 'canUpdateMetadata'],
      ['dhis2_delete_data_element', 'canDeleteMetadata'],
      
      // Metadata operations - Data Sets
      ['dhis2_list_data_sets', 'canViewMetadata'],
      ['dhis2_create_data_set', 'canCreateMetadata'],
      
      // Metadata operations - Categories
      ['dhis2_list_categories', 'canViewMetadata'],
      ['dhis2_create_category', 'canCreateMetadata'],
      ['dhis2_list_category_options', 'canViewMetadata'],
      ['dhis2_create_category_option', 'canCreateMetadata'],
      ['dhis2_list_category_combos', 'canViewMetadata'],
      ['dhis2_create_category_combo', 'canCreateMetadata'],
      ['dhis2_list_category_option_combos', 'canViewMetadata'],
      
      // Organisation Units
      ['dhis2_list_org_units', 'canViewMetadata'],
      ['dhis2_list_org_unit_groups', 'canViewMetadata'],
      ['dhis2_create_org_unit_group', 'canCreateMetadata'],
      
      // Validation Rules
      ['dhis2_list_validation_rules', 'canViewMetadata'],
      ['dhis2_create_validation_rule', 'canCreateMetadata'],
      ['dhis2_run_validation', ['canViewData', 'canRunAnalytics']],
      
      // Data Values
      ['dhis2_get_data_values', 'canViewData'],
      ['dhis2_bulk_import_data_values', 'canImportData'],
      
      // Analytics
      ['dhis2_get_analytics', 'canRunAnalytics'],
      ['dhis2_get_data_statistics', 'canRunAnalytics'],
      
      // Programs (Tracker)
      ['dhis2_list_programs', 'canViewMetadata'],
      ['dhis2_create_program', 'canManagePrograms'],
      ['dhis2_list_tracked_entity_types', 'canViewMetadata'],
      ['dhis2_create_tracked_entity_type', 'canManagePrograms'],
      ['dhis2_list_tracked_entity_attributes', 'canViewMetadata'],
      ['dhis2_create_tracked_entity_attribute', 'canManagePrograms'],
      ['dhis2_list_program_stages', 'canViewMetadata'],
      ['dhis2_create_program_stage', 'canManagePrograms'],
      ['dhis2_list_program_rules', 'canViewMetadata'],
      ['dhis2_create_program_rule', 'canManagePrograms'],
      
      // Tracker Data
      ['dhis2_list_tracked_entity_instances', 'canViewTEI'],
      ['dhis2_create_tracked_entity_instance', 'canEnrollTEI'],
      ['dhis2_list_enrollments', 'canViewTEI'],
      ['dhis2_create_enrollment', 'canEnrollTEI'],
      ['dhis2_list_events', 'canViewTEI'],
      ['dhis2_create_event', 'canManageTrackerData'],
      ['dhis2_bulk_import_events', 'canImportData'],
      ['dhis2_get_event_analytics', 'canRunAnalytics'],
      ['dhis2_get_enrollment_analytics', 'canRunAnalytics'],
      
      // Dashboards and Visualizations
      ['dhis2_list_dashboards', 'canViewData'],
      ['dhis2_create_dashboard', 'canManageDashboards'],
      ['dhis2_list_visualizations', 'canViewData'],
      ['dhis2_create_visualization', 'canManageDashboards'],
      ['dhis2_list_reports', 'canViewData'],
      ['dhis2_generate_report', 'canExportData'],
      
      // Web App Platform Tools
      ['dhis2_init_webapp', 'canConfigureApps'],
      ['dhis2_configure_app_manifest', 'canConfigureApps'],
      ['dhis2_configure_build_system', 'canConfigureApps'],
      ['dhis2_setup_dev_environment', 'canConfigureApps'],
      ['dhis2_generate_app_runtime_config', 'canConfigureApps'],
      ['dhis2_create_datastore_namespace', 'canConfigureApps'],
      ['dhis2_manage_datastore_key', 'canConfigureApps'],
      ['dhis2_setup_authentication_patterns', 'canConfigureApps'],
      ['dhis2_create_ui_components', 'canUseUITools'],
      ['dhis2_generate_test_setup', 'canConfigureApps'],
      
      // Debugging Tools
      ['dhis2_diagnose_cors_issues', 'canDebugApplications'],
      ['dhis2_configure_cors_allowlist', 'canDebugApplications'],
      ['dhis2_debug_authentication', 'canDebugApplications'],
      ['dhis2_fix_proxy_configuration', 'canDebugApplications'],
      ['dhis2_resolve_build_issues', 'canDebugApplications'],
      ['dhis2_optimize_performance', 'canDebugApplications'],
      ['dhis2_validate_environment', 'canDebugApplications'],
      ['dhis2_migration_assistant', 'canDebugApplications'],
      
      // Android SDK Tools
      ['dhis2_android_init_project', 'canUseMobileFeatures'],
      ['dhis2_android_configure_gradle', 'canUseMobileFeatures'],
      ['dhis2_android_setup_sync', 'canConfigureMobile'],
      ['dhis2_android_configure_storage', 'canConfigureMobile'],
      ['dhis2_android_setup_location_services', 'canUseMobileFeatures'],
      ['dhis2_android_configure_camera', 'canUseMobileFeatures'],
      ['dhis2_android_setup_authentication', 'canConfigureMobile'],
      ['dhis2_android_generate_data_models', 'canUseMobileFeatures'],
      ['dhis2_android_setup_testing', 'canUseMobileFeatures'],
      ['dhis2_android_configure_ui_patterns', 'canUseMobileFeatures'],
      ['dhis2_android_setup_offline_analytics', 'canUseMobileFeatures'],
      ['dhis2_android_configure_notifications', 'canUseMobileFeatures'],
      ['dhis2_android_performance_optimization', 'canUseMobileFeatures'],
      
      // UI Library Tools
      ['dhis2_generate_ui_form_patterns', 'canUseUITools'],
      ['dhis2_generate_ui_data_display', 'canUseUITools'],
      ['dhis2_generate_ui_navigation_layout', 'canUseUITools'],
      ['dhis2_generate_design_system', 'canUseUITools'],
      ['android_generate_material_form', 'canUseMobileFeatures'],
      ['android_generate_list_adapter', 'canUseMobileFeatures'],
      ['android_generate_navigation_drawer', 'canUseMobileFeatures'],
      ['android_generate_bottom_sheet', 'canUseMobileFeatures'],
    ]);
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'generates' configuration and fixes, implying a read-only or advisory role, but doesn't clarify if it modifies files, requires authentication, has side effects, or provides output format. For a tool with 5 parameters and no annotations, this is insufficient to inform safe and effective usage.

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 that front-loads the core purpose without unnecessary details. It avoids redundancy and wastes no words, making it easy to parse quickly. This is an example of optimal conciseness for a tool description.

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 complexity (5 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It doesn't address behavioral aspects like what the tool outputs, how it handles errors, or authentication requirements. For a configuration-generation tool with multiple parameters, more context is needed to ensure the agent can use it correctly without guesswork.

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 description adds no parameter-specific information beyond what the input schema provides. With 60% schema description coverage, the schema documents parameters like 'proxyType' and 'targetInstance' well, but others like 'authentication' and 'sslOptions' have partial coverage. The description doesn't compensate by explaining parameter interactions or usage examples, so it meets the baseline for moderate schema coverage.

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: 'Generate proxy configuration and fixes for local development against DHIS2 instances.' It specifies the action ('generate'), resource ('proxy configuration and fixes'), and context ('local development against DHIS2 instances'), making it easy to understand. However, it doesn't explicitly differentiate from sibling tools like 'dhis2_setup_dev_environment' or 'dhis2_resolve_build_issues', which might have overlapping scopes.

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 mentions 'local development against DHIS2 instances,' but doesn't specify scenarios, prerequisites, or exclusions. Given the many sibling tools, such as 'dhis2_setup_dev_environment' or 'dhis2_diagnose_cors_issues,' the lack of differentiation leaves the agent guessing about appropriate use cases.

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