-
Notifications
You must be signed in to change notification settings - Fork 8
Development Setup
This guide will help you set up a local development environment for contributing to mcpbr.
Before you begin, ensure you have:
- β Python 3.11+ installed
- β Git for version control
- β Docker for running tests
- β A text editor or IDE (VS Code, PyCharm, etc.)
# 1. Fork and clone
git clone https://github.com/YOUR_USERNAME/mcpbr.git
cd mcpbr
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# 3. Install in development mode
pip install -e ".[dev]"
# 4. Verify setup
pytest -m "not integration"- Navigate to https://github.com/greynewell/mcpbr
- Click the "Fork" button in the top right
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/mcpbr.git cd mcpbr
git remote add upstream https://github.com/greynewell/mcpbr.git
git fetch upstreamThis allows you to sync with the main repository.
Using venv:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateUsing uv (faster):
pip install uv
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activateUsing conda:
conda create -n mcpbr python=3.11
conda activate mcpbrStandard installation:
pip install -e ".[dev]"Using uv (faster):
uv pip install -e ".[dev]"This installs:
- mcpbr in editable mode (
-e) - All development dependencies (
[dev])
Development dependencies include:
-
pytest- Testing framework -
pytest-cov- Coverage reporting -
pytest-asyncio- Async test support -
ruff- Linting and formatting -
mypy- Type checking -
pre-commit- Git hooks
# Check installation
mcpbr --version
# Run unit tests
pytest -m "not integration"
# Check linting
ruff check src/
# Check types
mypy src/Recommended extensions:
{
"recommendations": [
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"ms-azuretools.vscode-docker"
]
}Settings (.vscode/settings.json):
{
"python.linting.enabled": true,
"python.linting.ruffEnabled": true,
"python.formatting.provider": "ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
}- Set Python Interpreter: Settings β Project β Python Interpreter β Add β Virtualenv
- Enable ruff: Settings β Tools β External Tools β Add ruff
- Configure pytest: Settings β Tools β Python Integrated Tools β Testing β pytest
Install pre-commit hooks to automatically check code before commits:
pre-commit installThis runs on every commit:
- Code formatting (ruff)
- Linting (ruff)
- Type checking (mypy)
- Test execution (pytest)
Manual run:
pre-commit run --all-filesCheck for issues:
ruff check src/ tests/Auto-fix issues:
ruff check --fix src/ tests/Format code:
ruff format src/ tests/Configuration (already in pyproject.toml):
[tool.ruff]
line-length = 100
target-version = "py311"Run type checker:
mypy src/Configuration (already in pyproject.toml):
[tool.mypy]
python_version = "3.11"
strict = true
warn_return_any = true
warn_unused_configs = trueAll tests:
pytestOnly unit tests (fast):
pytest -m "not integration"Only integration tests:
pytest -m integrationWith coverage:
pytest --cov=src/mcpbr --cov-report=html
open htmlcov/index.html # View coverage reportVerbose output:
pytest -vStop on first failure:
pytest -xRun specific test:
pytest tests/test_config.py::test_load_config@pytest.mark.unit # Fast, no external dependencies
@pytest.mark.integration # Requires Docker, API keys
@pytest.mark.slow # Takes >10 seconds
@pytest.mark.benchmark # Benchmark-specific testsTest file structure:
# tests/test_feature.py
import pytest
from mcpbr.feature import my_function
class TestMyFunction:
"""Tests for my_function."""
def test_happy_path(self):
"""Test normal operation."""
result = my_function(input="test")
assert result == "expected"
def test_edge_case(self):
"""Test edge case."""
result = my_function(input="")
assert result is None
def test_error_handling(self):
"""Test error conditions."""
with pytest.raises(ValueError):
my_function(input=None)Fixtures:
@pytest.fixture
def sample_config():
"""Create a sample configuration for testing."""
return HarnessConfig(
mcp_server=MCPServerConfig(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem"],
),
model="sonnet",
)
def test_with_fixture(sample_config):
"""Test using fixture."""
assert sample_config.model == "sonnet"export ANTHROPIC_API_KEY="sk-ant-..."Add to .env file (create at project root):
ANTHROPIC_API_KEY=sk-ant-...# Initialize config
mcpbr init
# Run small test
mcpbr run -c mcpbr.yaml -n 2 -vUse verbose logging:
mcpbr run -c mcpbr.yaml -n 1 -vv --log-dir debug-logs/Add breakpoints in code:
import pdb; pdb.set_trace() # Python debugger
breakpoint() # Python 3.7+VS Code debugging:
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Run mcpbr",
"type": "python",
"request": "launch",
"module": "mcpbr.cli",
"args": ["run", "-c", "mcpbr.yaml", "-n", "1", "-v"],
"console": "integratedTerminal"
}
]
}# Build fallback image
docker build -t mcpbr-test -f Dockerfile .# Remove mcpbr containers
mcpbr cleanup
# Remove all stopped containers
docker container prune -f
# Remove unused images
docker image prune -a -fFor integration testing:
# docker-compose.yml
version: '3.8'
services:
mcpbr-test:
build: .
volumes:
- .:/app
environment:
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}git checkout -b feature/my-awesome-feature# Fetch latest changes
git fetch upstream
# Rebase on main
git rebase upstream/main
# Or merge
git merge upstream/maingit add .
git commit -m "feat(scope): description"See Contributing Guide for commit message format.
git push origin feature/my-awesome-featurecd docs
pip install -r requirements.txt
mkdocs serveView at http://localhost:8000
Documentation lives in:
-
README.md- Main project README -
docs/- MkDocs documentation site - Wiki - Community wiki (this page!)
Problem: ModuleNotFoundError: No module named 'mcpbr'
Solution:
pip install -e .Problem: Tests fail with "Docker not running"
Solution: Ensure Docker Desktop is running
Problem: ruff finds many errors
Solution:
ruff check --fix src/
ruff format src/Problem: mypy reports type errors
Solution:
- Add type hints to functions
- Use
# type: ignorefor known issues - Update type stubs if needed
# Run tests in parallel
pytest -n auto
# Run only changed tests
pytest --lf # Last failed
pytest --ff # Failed firstUse build cache:
docker build --cache-from mcpbr-test .Use BuildKit:
DOCKER_BUILDKIT=1 docker build .- β Verify setup - Run tests, check linting
- π Read Contributing Guide - Understand workflow
- π― Find an issue - Check good first issues
- π§ Make changes - Implement your feature/fix
- π§ͺ Test thoroughly - Write and run tests
- π Submit PR - Create pull request
- π Contributing Guide
- ποΈ Architecture
- π― Roadmap
- π¬ Discussions
Stuck? We're here to help!
- π¬ Ask in Discussions
- π Open an issue
- π§ Contact maintainers
Happy developing! π