Thank you for your interest in contributing to the Database MCP Server! This document provides guidelines and information for contributors.
-
Prerequisites
- Go 1.25.5 or later
- Git
- Access to supported databases (MySQL, MariaDB, PostgreSQL, SQLite) for testing
-
Setup
git clone https://github.com/guyinwonder168/database-mcp-server.git cd database-mcp-server go mod download go build -o mcp-server ./cmd/server/main.go -
Running Tests
# Run all tests go test ./... # Run tests with coverage go test -cover ./... # Run live integration tests (requires database setup) DB_MCP_IT_PG_HOST=localhost DB_MCP_IT_PG_PORT=5432 DB_MCP_IT_PG_USER=test DB_MCP_IT_PG_PASS=test DB_MCP_IT_PG_DB=test go test ./internal/mcp -run TestLive -count=1
- Follow Go conventions and best practices
- Use
gofmtfor code formatting - Write meaningful commit messages with conventional commit format
- Add comprehensive tests for new features
- Update documentation for any API changes
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes:
- Write code following the existing patterns
- Add tests for new functionality
- Update documentation as needed
- Test your changes:
go test ./... go vet ./... go fmt ./... - Commit your changes:
git add . git commit -m "feat: add your feature description"
- Push to your fork:
git push origin feature/your-feature-name - Create a Pull Request with:
- Clear description of changes
- Link to relevant issues
- Test results
- Include steps to reproduce
- Add tests that cover the fix
- Update documentation if behavior changes
- Follow existing MCP tool patterns
- Add comprehensive tests
- Update API documentation
- Consider backward compatibility
- Fix typos or clarify unclear sections
- Add examples for new use cases
- Update README.md for major changes
When adding new MCP tools:
- Add tool handler in
internal/mcp/server.go - Register the tool in the tools list
- Add comprehensive tests in
internal/mcp/server_test.go - Update OpenAPI spec in
docs/mcp-openapi.yaml - Update README.md with usage examples
- Run integration tests to ensure tool discovery works
- Unit tests for all new functions
- Integration tests for MCP tools
- Database-specific testing with go-sqlmock for MySQL/PostgreSQL tests (see
server_analyze_schema_helpers_test.gofor examples) - Real SQLite testing using in-memory databases for SQLite functionality
- Live database tests when applicable
- Test error scenarios and edge cases
- MySQL/MariaDB & PostgreSQL: Use go-sqlmock for mocking database-specific queries and system catalogs (INFORMATION_SCHEMA, information_schema)
- SQLite: Use real in-memory databases (
:memory:) to test actual SQLite functionality - Live Integration: Use
DB_MCP_IT_*environment variables for testing against real database instances
- Automated checks must pass
- Manual review focuses on:
- Code quality and maintainability
- Test coverage and effectiveness
- Documentation accuracy
- Security considerations
- Approval required before merge
- Never commit secrets or credentials
- Follow secure coding practices
- Test for SQL injection vulnerabilities
- Validate all inputs properly
Releases are managed by the maintainers:
- Update version in documentation
- Update CHANGELOG.md
- Create git tag
- Build and test release binary
- Create GitHub release
- Check existing issues and documentation
- Create an issue for questions or problems
- Join discussions for feature ideas
Thank you for contributing to Database MCP Server!