dhis2_setup_dev_environment
Configure a local development environment for DHIS2 applications with proxy setup and hot reload functionality to streamline app testing and debugging.
Instructions
Set up development environment for DHIS2 app with proper proxy and hot reload
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dhis2Instance | Yes | DHIS2 instance URL for development proxy | |
| username | Yes | DHIS2 username for development | |
| password | Yes | DHIS2 password for development | |
| port | No | Local development server port (default: 3000) | |
| https | No | Use HTTPS for local development | |
| envFile | No | Path to environment file (default: .env.local) |
Implementation Reference
- src/index.ts:997-1007 (handler)Handler for 'dhis2_setup_dev_environment' tool: extracts arguments, calls generateDevEnvironmentConfig, and returns markdown configuration as text content.case 'dhis2_setup_dev_environment': const devEnvArgs = args as any; const devEnvConfig = generateDevEnvironmentConfig(devEnvArgs); return { content: [ { type: 'text', text: devEnvConfig, }, ], };
- src/webapp-generators.ts:290-348 (helper)Core helper function generateDevEnvironmentConfig that generates comprehensive markdown instructions for DHIS2 dev environment setup including env vars, commands, CORS fixes, and security notes.export function generateDevEnvironmentConfig(args: any): string { const { dhis2Instance, username, password, port = 3000, https = false, envFile = '.env.local' } = args; return `# DHIS2 Development Environment Setup ## Environment File (${envFile}) \`\`\`bash # DHIS2 Instance Configuration REACT_APP_DHIS2_BASE_URL=${dhis2Instance} DHIS2_CORE_HOST=${dhis2Instance} DHIS2_CORE_USERNAME=${username} DHIS2_CORE_PASSWORD=${password} # Development Server Configuration PORT=${port} ${https ? 'HTTPS=true' : '# HTTPS=false'} # API Configuration REACT_APP_DHIS2_API_VERSION=40 GENERATE_SOURCEMAP=true \`\`\` ## Development Commands \`\`\`bash # Start with proxy yarn start --proxy # Start with specific port yarn start --port ${port} # Start with HTTPS${https ? '' : ' (if needed)'} ${https ? 'yarn start --https' : '# yarn start --https'} \`\`\` ## Browser Configuration for CORS ### Chrome (recommended for development) \`\`\`bash # Start Chrome with disabled security (development only!) google-chrome --disable-web-security --user-data-dir=/tmp/chrome-dev \`\`\` ### Firefox 1. Open about:config 2. Set \`network.cookie.sameSite.laxByDefault\` to \`false\` 3. Set \`network.cookie.sameSite.noneRequiresSecure\` to \`false\` ## Troubleshooting Tips - Clear browser cache if authentication fails - Check DHIS2 CORS allowlist settings - Verify DHIS2 instance is accessible - Use browser dev tools Network tab for debugging ## Security Notes ⚠️ **Never commit credentials to version control!** - Add ${envFile} to .gitignore - Use different credentials for development - Rotate passwords regularly `; }
- src/permission-system.ts:135-136 (registration)Permission registration in TOOL_PERMISSIONS map: requires 'canConfigureApps' permission to execute the tool.['dhis2_configure_build_system', 'canConfigureApps'], ['dhis2_setup_dev_environment', 'canConfigureApps'],