This document outlines security best practices for the MCP Server Development Platform.
NEVER put API keys directly in configuration files. Always use environment variables:
# β
CORRECT: Use environment variables
OPENWEATHER_API_KEY=your_actual_api_key_here
# β WRONG: Never put keys in config files
"env": {
"OPENWEATHER_API_KEY": "your_api_key_here" # This will be exposed!
}
-
Copy the template:
cp .env.example .env
-
Edit .env with your actual keys:
# Edit the .env file with your real API keys nano .env
-
Verify .env is ignored:
git status # .env should NOT appear in the list
OPENWEATHER_API_KEY
: Your OpenWeatherMap API key
UNITS
: Temperature units (imperial/metric)DEBUG
: Enable debug logging (true/false)API_TIMEOUT
: API request timeout in seconds
- Go to https://openweathermap.org/api
- Sign up for a free account
- Generate an API key
- Add to your
.env
file
- β Use .env files for secrets
- β Keep .env in .gitignore
- β Use .env.example for templates
- β Never commit .env files
- β Never put secrets in config files
- π Rotate keys regularly
- π Monitor API usage
- π« Restrict key permissions
- π Use different keys for dev/prod
- π Read-only mounts for source code
- π Writable mounts only for data
- π« No privileged containers
- π Environment variable injection
-
Revoke the exposed key immediately:
- Go to your API provider (e.g., OpenWeatherMap)
- Delete/revoke the exposed key
-
Generate a new key:
- Create a new API key
- Update your
.env
file
-
Remove from Git history (if committed):
# Remove sensitive file from Git history git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch config/mcpo.json' \ --prune-empty --tag-name-filter cat -- --all # Force push to update remote git push origin --force --all
-
Update documentation:
- Notify users about the security incident
- Update setup instructions
- β Always use .env files
- β Review commits before pushing
- β Use pre-commit hooks
- β Regular security audits
- No API keys in config files
- .env file is in .gitignore
- Secrets are in environment variables
- No sensitive data in logs
- Environment variables are set
- API keys are valid and active
- Container has minimal permissions
- Monitoring is enabled
- Rotate API keys quarterly
- Review access logs
- Update dependencies
- Security audit
Always use this template for new environments:
# Copy this template
cp .env.example .env
# Edit with your actual values
nano .env
# Verify it's ignored
git status # Should not show .env
If you discover a security issue:
- Do not create a public issue
- Email security concerns to the maintainers
- Include details about the vulnerability
- Wait for response before public disclosure
For security-related issues, please contact the maintainers privately before creating public issues.
Remember: Security is everyone's responsibility! π