Contributing to FastAPI-MCP

First off, thank you for considering contributing to FastAPI-MCP!

Development Setup

  1. Make sure you have Python 3.10+ installed.
  2. Install uv, our recommended package manager.
  3. Fork the repository on GitHub.
  4. Clone your fork locally:

    git clone https://github.com/YOUR-USERNAME/fastapi_mcp.git
    cd fastapi-mcp
    
    # Add the original repository as the upstream remote
    git remote add upstream https://github.com/tadata-org/fastapi_mcp.git
  5. Set up the development environment:

    uv sync

    This command automatically creates a virtual environment and installs all required dependencies from uv.lock.

  6. Install pre-commit hooks:

    uv run pre-commit install
    uv run pre-commit run --all-files

    Pre-commit hooks will automatically run checks (like ruff for formatting and linting) when you make a commit, ensuring your code adheres to our style guidelines.

Running Commands

You can run commands either by activating the virtual environment first or by using uv run.

1. With the virtual environment activated:

source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Then run commands directly
pytest
mypy .
ruff check .

2. Without activating the virtual environment:

# Use the 'uv run' prefix
uv run pytest
uv run mypy .
uv run ruff check .

Development Process

  1. Create a feature branch from the main branch (git checkout -b feature/my-new-feature).
  2. Make your changes and add tests for them.
  3. Ensure all checks and tests pass:
    • Run type checking: uv run mypy .
    • Run the tests: uv run pytest
    • Ensure code is formatted: uv run ruff format . and uv run ruff check . (pre-commit hooks will handle this automatically).
  4. Commit your changes with a descriptive message (git commit -m 'feat: Add some amazing feature').
  5. Push your branch to your fork (git push origin feature/my-new-feature).
  6. Open a Pull Request against the main branch of the original tadata-org/fastapi_mcp repository.

Code Style

We use the following tools to ensure code quality:

  • Ruff: For both linting and formatting.
  • MyPy: For static type checking.

Please ensure your code passes all checks before submitting a pull request.

# Check code formatting and style
ruff check .
ruff format .

# Check types
mypy .

Testing

We use pytest for testing. Please write tests for any new features and ensure all existing tests pass.

# Run all tests
pytest

Pull Request Process

  1. Ensure your code follows the style guidelines.
  2. Update documentation (README.md, docstrings, etc.) if your changes affect it.
  3. Make sure your pull request has a clear title and description.
  4. Your pull request will be reviewed and merged once it's approved.

Thank you for your contribution!