Skip to main content
Glama

dhis2_configure_cors_allowlist

Configure CORS allowlist settings for DHIS2 to enable secure cross-origin resource sharing with specified domains.

Instructions

Generate instructions and configuration for DHIS2 CORS allowlist setup

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allowedOriginsYesURLs to add to CORS allowlist (e.g., ["http://localhost:3000", "https://myapp.example.com"])
dhis2VersionNoDHIS2 version (e.g., "2.40.4")
includeStepsNoInclude step-by-step configuration instructions

Implementation Reference

  • The primary handler for the 'dhis2_configure_cors_allowlist' tool. It receives arguments, calls generateCORSConfiguration from debugging-helpers.ts, and returns the generated Markdown guide as tool response content.
    case 'dhis2_configure_cors_allowlist':
      const corsAllowlistArgs = args as any;
      const corsConfig = generateCORSConfiguration(corsAllowlistArgs);
      return {
        content: [
          {
            type: 'text',
            text: corsConfig,
          },
        ],
      };
  • Core helper function that generates comprehensive Markdown documentation for configuring DHIS2 CORS allowlist. Includes step-by-step GUI instructions, system properties config, environment-specific examples, validation curl commands, troubleshooting, and security best practices.
    export function generateCORSConfiguration(args: any): string {
      const { allowedOrigins, dhis2Version = '2.40.4', includeSteps = true } = args;
    
      return `# DHIS2 CORS Configuration Guide
    
    ## System Settings Configuration
    
    ${includeSteps ? `
    ### Step-by-Step Instructions
    1. **Login to DHIS2** as a user with system administration privileges
    2. **Navigate to System Settings**
       - Click on the Apps icon (grid icon)
       - Search for "System Settings"
       - Click on the System Settings app
    3. **Configure CORS**
       - In the left sidebar, click "Access"
       - Scroll down to find "CORS allowlist"
       - Add your development URLs
    4. **Save Changes**
       - Click "Save" at the bottom of the page
       - Wait for confirmation message
    ` : ''}
    
    ## CORS Allowlist Configuration
    
    ### URLs to Add
    ${allowedOrigins.map((url: string) => `- ${url}`).join('\n')}
    
    ### Configuration Format
    \`\`\`
    ${allowedOrigins.join('\n')}
    \`\`\`
    
    ## Advanced CORS Configuration (System Properties)
    
    For system administrators, you can also configure CORS via system properties:
    
    ### dhis.conf Configuration
    \`\`\`properties
    # CORS Configuration
    cors.allowedOrigins=${allowedOrigins.join(',')}
    cors.allowCredentials=true
    cors.allowedMethods=GET,POST,PUT,DELETE,OPTIONS,PATCH
    cors.allowedHeaders=Accept,Content-Type,Origin,X-Requested-With,Authorization
    cors.maxAge=3600
    \`\`\`
    
    ## Environment-Specific Configurations
    
    ### Development Environment
    \`\`\`
    # Local development
    http://localhost:3000
    http://localhost:3001
    http://127.0.0.1:3000
    
    # Common development ports
    http://localhost:8080
    http://localhost:9000
    \`\`\`
    
    ### Staging Environment  
    \`\`\`
    https://staging-app.yourdomain.com
    https://test-app.yourdomain.com
    \`\`\`
    
    ### Production Environment
    \`\`\`
    https://app.yourdomain.com
    https://health-dashboard.yourdomain.com
    \`\`\`
    
    ## Validation Commands
    
    ### Test CORS Configuration
    \`\`\`bash
    # Test basic CORS
    curl -H "Origin: ${allowedOrigins[0]}" \\
         ${dhis2Version ? `https://your-dhis2-instance.com/api/system/info` : 'https://your-dhis2-instance.com/api/system/info'}
    
    # Test with authentication
    curl -H "Origin: ${allowedOrigins[0]}" \\
         -H "Authorization: Basic $(echo -n 'username:password' | base64)" \\
         https://your-dhis2-instance.com/api/me
    
    # Test preflight request
    curl -H "Origin: ${allowedOrigins[0]}" \\
         -H "Access-Control-Request-Method: POST" \\
         -H "Access-Control-Request-Headers: Content-Type" \\
         -X OPTIONS \\
         https://your-dhis2-instance.com/api/dataElements
    \`\`\`
    
    ### Expected Response Headers
    \`\`\`
    Access-Control-Allow-Origin: ${allowedOrigins[0]}
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
    Access-Control-Allow-Headers: Accept, Content-Type, Origin, X-Requested-With, Authorization
    Access-Control-Max-Age: 3600
    \`\`\`
    
    ## Troubleshooting Common Issues
    
    ### Issue: "CORS allowlist not found"
    **Solution**: Update to DHIS2 2.35+ (older versions use different settings)
    
    ### Issue: "Changes not taking effect"
    **Solutions**:
    1. Clear browser cache completely
    2. Restart DHIS2 server (if self-hosted)
    3. Wait 5-10 minutes for changes to propagate
    4. Check if nginx/reverse proxy needs updating
    
    ### Issue: "Still getting CORS errors"
    **Checklist**:
    - [ ] URLs match exactly (including protocol)
    - [ ] No trailing slashes mismatch
    - [ ] Case sensitivity check
    - [ ] Wildcard not used (DHIS2 doesn't support wildcards)
    - [ ] Browser cache cleared
    
    ## Security Best Practices
    
    ### Development
    - Only add localhost URLs for development
    - Use specific ports, not wildcards
    - Remove development URLs before production
    
    ### Production
    - Only add your production domain(s)
    - Use HTTPS URLs only
    - Regularly audit allowed origins
    - Document all entries with purpose
    
    ### Monitoring
    \`\`\`bash
    # Check current CORS settings via API
    curl -u admin:password \\
      https://your-dhis2-instance.com/api/systemSettings/keyJsCorallowlist
    \`\`\`
    
    ## Version-Specific Notes
    
    ${dhis2Version >= '2.38' ? `
    ### DHIS2 ${dhis2Version}+
    - Full CORS support available
    - GUI configuration available
    - API endpoint for configuration
    ` : `
    ### DHIS2 ${dhis2Version}
    - Limited CORS support
    - May require manual configuration
    - Check documentation for version-specific settings
    `}
    `;
    }
  • Tool permission registration in TOOL_PERMISSIONS Map. Associates 'dhis2_configure_cors_allowlist' with 'canDebugApplications' permission, enabling permission-based filtering of available tools.
    ['dhis2_configure_cors_allowlist', 'canDebugApplications'],
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 instructions and configuration, implying a read-only or advisory role, but doesn't clarify if it modifies files, requires specific permissions, or has side effects like overwriting existing settings. For a configuration tool with zero annotation coverage, this leaves significant gaps in understanding its operational 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, clear sentence: 'Generate instructions and configuration for DHIS2 CORS allowlist setup.' It is front-loaded with the core purpose, has zero redundant words, and efficiently communicates the tool's function without unnecessary elaboration. Every word earns its place.

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

Completeness3/5

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

Given the tool's complexity (configuration generation for a specific system), the description is minimally adequate. It lacks output schema, so return values aren't documented, and with no annotations, behavioral traits like safety or permissions are unspecified. The 100% schema coverage helps, but for a tool that likely involves system changes, more context on what 'generate' entails (e.g., file creation, CLI commands) would improve completeness.

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 100% schema description coverage, the schema already documents all three parameters (allowedOrigins, dhis2Version, includeSteps) with examples and purposes. The baseline score of 3 is appropriate as the schema does the heavy lifting, and the description doesn't compensate with additional context like format details or usage tips.

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 instructions and configuration for DHIS2 CORS allowlist setup.' It specifies the action ('generate instructions and configuration'), the resource ('DHIS2 CORS allowlist setup'), and the domain (DHIS2). However, it doesn't explicitly differentiate from sibling tools like 'dhis2_diagnose_cors_issues' or 'dhis2_fix_proxy_configuration', which might have overlapping concerns with CORS.

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, such as needing access to DHIS2 configuration files or administrative permissions, nor does it contrast with related tools like 'dhis2_diagnose_cors_issues' for troubleshooting. Usage is implied by the purpose but lacks explicit context or exclusions.

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