Thank you for your interest in contributing to the PostgreSQL MCP Server! This document provides guidelines for contributing to the project.
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code.
Before creating bug reports, please check the existing issues to avoid duplicates. When creating a bug report, include:
- Use a clear and descriptive title
- Describe the exact steps to reproduce the problem
- Provide specific examples with code snippets if applicable
- Describe the behavior you observed and what you expected
- Include environment details (OS, Python version, PostgreSQL version)
Enhancement suggestions are welcome! Please provide:
- A clear and descriptive title
- A detailed description of the proposed enhancement
- Use cases that would benefit from this enhancement
- Examples of how the enhancement would be used
Do not report security vulnerabilities through public GitHub issues. Please follow our Security Policy for responsible disclosure.
-
Fork and clone the repository
git clone https://github.com/neverinfamous/postgres-mcp.git cd postgres-mcp -
Set up Python environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install -e .
-
Install development dependencies
pip install -r requirements-dev.txt
-
Set up PostgreSQL for testing
# Using Docker (recommended) docker run --name postgres-test -e POSTGRES_PASSWORD=test -p 5432:5432 -d postgres:latest
# Run all tests
python -m pytest tests/
# Run security tests
python run_security_test.py
# Run specific test file
python -m pytest tests/test_specific.py
# Run with coverage
python -m pytest --cov=src tests/We follow Python best practices:
- PEP 8 for code style
- Type hints for function signatures
- Docstrings for all public functions and classes
- Black for code formatting
- isort for import sorting
# Format code
black src/ tests/
isort src/ tests/
# Check formatting
black --check src/ tests/
isort --check-only src/ tests/- Use clear and meaningful commit messages
- Follow conventional commit format when possible:
feat:for new featuresfix:for bug fixesdocs:for documentation changestest:for test additions/changesrefactor:for code refactoringsecurity:for security-related changes
Example:
feat: add parameter binding support to execute_sql
- Adds params parameter for SQL injection prevention
- Maintains backward compatibility
- Includes comprehensive tests
-
Create a feature branch from
maingit checkout -b feature/your-feature-name
-
Make your changes following the development guidelines
-
Add or update tests for your changes
-
Run the test suite to ensure everything passes
-
Update documentation if needed
-
Create a pull request with:
- Clear title and description
- Reference to related issues
- List of changes made
- Screenshots/examples if applicable
- All tests must pass
- Code coverage should not decrease
- Security tests must pass
- Documentation must be updated for new features
- Commit messages should be clear and descriptive
When adding new MCP tools:
- Define the tool in
src/postgres_mcp/server.py - Add comprehensive tests in
tests/ - Update documentation with examples
- Consider security implications and add appropriate validation
- Test with both restricted and unrestricted modes
- Always use parameter binding for user input
- Validate SQL queries in restricted mode
- Sanitize error messages to prevent information disclosure
- Add security tests for new functionality
- Follow the principle of least privilege
- Write tests for both success and failure cases
- Include edge cases and boundary conditions
- Test security implications thoroughly
- Use descriptive test names and docstrings
- Mock external dependencies appropriately
- Update README.md for significant changes
- Add docstrings for all new functions and classes
- Include examples in docstrings
- Update security documentation for security-related changes
- Keep CHANGELOG.md updated
- Be respectful and inclusive
- Help others learn and contribute
- Share knowledge and best practices
- Provide constructive feedback
- Follow the Code of Conduct
If you have questions about contributing, please:
- Check existing documentation and issues
- Ask in GitHub Discussions
- Contact the maintainers at admin@adamic.tech
Thank you for contributing to PostgreSQL MCP Server!