This project follows security best practices for MCP servers and API token management:
Never commit sensitive information to git:
- β
.env- Contains API tokens and database IDs (excluded from git) - β
.env.local- Local environment overrides (excluded from git) - β
.env.backup- Backup credentials (excluded from git) - β
claude_desktop_config.json- Contains credentials (user-managed)
Safe to commit:
- β
.env.example- Template with placeholders - β Source code without credentials
- β Test files with mock data
- β Configuration templates
- β Documentation files
This repository provides example configuration files:
-
.env.example - Template for environment variables
- Copy to
.env - Replace placeholders with your actual values
- Never commit the actual
.envfile
- Copy to
-
Claude Desktop Config - MCP server configuration
- Edit via Claude Desktop settings
- Stores credentials in
claude_desktop_config.json - Managed by Claude Desktop (not in this repository)
Included in repository:
- Source code (
.tsfiles) - Tests (
*.test.tsfiles) - Compiled JavaScript (
dist/folder for npm package) - Documentation (
.mdfiles) - Configuration templates (
.examplefiles) - GitHub Actions workflows
- Build configuration (
tsconfig.json,package.json)
Excluded from repository (.gitignore):
.env*- Environment variables and secretsnode_modules/- Dependenciescoverage/- Test coverage reports- Temporary files and IDE configs
When contributing:
- Never commit credentials - Use
.envfile (excluded from git) - Use example files - Provide templates, not actual configs
- Review before push - Run
git diffto check for sensitive data - Use .gitignore - Ensure secrets are excluded
- Rotate exposed secrets - If accidentally committed, rotate immediately
Cloudflare API Token Management:
- API tokens grant full access to your Cloudflare account
- Treat API tokens like passwords - never share or commit them
- Use scoped tokens with minimum required permissions:
- D1 Read access (for schema introspection)
- Limit to specific account ID
- Rotate tokens regularly (every 90 days recommended)
- Revoke tokens immediately if compromised
Database ID Security:
- Database IDs are not highly sensitive but should be kept private
- They cannot be used without a valid API token
- Separate databases for development, staging, and production
- Never expose production database IDs in examples
Model Context Protocol (MCP):
- MCP servers run locally and communicate via stdio
- Credentials stored in Claude Desktop config (user's local machine)
- No network exposure by default
- All API calls originate from local machine
Security Boundaries:
- MCP server β Cloudflare D1 REST API (HTTPS only)
- Environment isolation (dev/staging/prod databases)
- Read-only schema introspection (no data modification)
- Caching layer prevents excessive API calls
If you discover a security vulnerability:
- Do NOT open a public issue
- Email: [email protected]
- Include:
- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if any)
We will respond within 48 hours and work with you to address the issue.
This project implements:
- β TypeScript Strict Mode - Type safety prevents runtime errors
- β Input Validation - Domain entities validate all inputs
- β Error Handling - Graceful degradation without leaking sensitive info
- β
Dependency Audits -
npm auditin CI/CD pipeline - β Automated Testing - 398 tests prevent security regressions
- β
Immutable Entities -
Object.freeze()prevents mutation - β Environment Isolation - Separate dev/staging/prod configurations
- β Cache TTL - 10-minute expiration prevents stale data attacks
- β HTTPS-Only - All Cloudflare API calls use HTTPS
Before deploying to production:
-
.envfile is in.gitignoreβ (already configured) - API tokens are not in git history
- No
.envor credential files committed - All tests passing (
npm test) - No
npm auditvulnerabilities (check withnpm audit) - Secrets rotated if ever exposed
- Production database access restricted
- Claude Desktop config uses production credentials only in production
- Verify
.npmignoreexcludes source files and tests
- Go to Cloudflare Dashboard
- Navigate to My Profile β API Tokens
- Click Create Token
- Use Custom Token template
- Set permissions:
- Account β D1 β Read
- Set account restriction to your account ID
- Save token securely (shown only once!)
Rotate API tokens every 90 days:
- Create new token with same permissions
- Update
.envfile with new token - Test MCP server functionality
- Revoke old token in Cloudflare Dashboard
If your API token is compromised:
- Immediately revoke the token in Cloudflare Dashboard
- Create a new token with different permissions if possible
- Update
.envfile and Claude Desktop config - Review Cloudflare audit logs for unauthorized access
- Report the incident to [email protected]
- Weekly: Check for dependency updates
- Monthly: Update dependencies (
npm update) - Monthly: Run security audits (
npm audit) - Quarterly: Rotate API tokens
- Quarterly: Review and update access controls
β Safe to Share Publicly:
- This repository (source code, tests, documentation)
- Build artifacts (
dist/folder) - npm package (
@semanticintent/semantic-d1-mcp) - Database schema structure (no data)
- Sample queries and examples
β Never Share Publicly:
- Cloudflare API tokens
- Database IDs (especially production)
- Environment variable files (
.env) - Claude Desktop config with credentials
- Actual database data
- Logs containing credentials
- Email: [email protected]
- Response Time: Within 48 hours
- GPG Key: Available upon request
Last Updated: 2025-10-07 Security Contact: [email protected]