This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Golf is a Python framework for building MCP (Model Context Protocol) servers with zero boilerplate. It automatically discovers, parses, and compiles Python files containing tools, resources, and prompts into a runnable FastMCP server.
Golf 0.2.x introduces breaking changes to align with FastMCP 2.11.x:
- Authentication System: Complete rewrite using FastMCP's built-in auth providers (JWT, OAuth, Static tokens)
- Legacy OAuth Removed: Custom OAuth implementation replaced with standards-compliant FastMCP providers
- Configuration Changes:
auth.pyconfiguration must be updated to use new auth configs (legacypre_build.pysupported) - Dependency Updates: Requires FastMCP >=2.14.0
- Removed Files: Legacy
oauth.pyandprovider.pyfiles removed from auth module - Deprecated Functions:
get_provider_token()and OAuth-related helpers return None (legacy compatibility)
- Component Discovery: Golf automatically scans
tools/,resources/, andprompts/directories for Python files - Code Generation: The
ManifestBuilderinsrc/golf/core/builder.pygenerates FastMCP server code from parsed components - CLI Interface: Entry point is
src/golf/cli/main.pywith commands:init,build,run - Configuration: Project settings managed via
golf.jsonfiles, parsed bysrc/golf/core/config.py - Authentication: Modern JWT/OAuth auth using FastMCP 2.11+ providers in
src/golf/auth/ - Telemetry: Anonymous usage tracking with OpenTelemetry support in
src/golf/telemetry/
# Run all tests with coverage
make test
# OR directly:
python -m pytest tests/ -v --cov=golf --cov-report=term-missing --cov-report=html
# Run tests without coverage (faster)
make test-fast
# OR directly:
python -m pytest tests/ -v# Run linting (ruff)
python -m ruff check src/
# Format code (ruff format only)
python -m ruff format src/ tests/# Install in development mode with telemetry dependencies
make install-dev
# Test CLI installation
golf --versionsrc/golf/cli/- CLI commands and entry pointssrc/golf/core/- Core framework logic (builder, parser, config)src/golf/auth/- Authentication providers (OAuth, API keys)src/golf/telemetry/- Usage tracking and OpenTelemetry instrumentationsrc/golf/metrics/- Prometheus metrics collectionsrc/golf/examples/- Example projects (basic template)tests/- Test suite with pytest
Uses pytest with these key configurations:
- Test discovery:
test_*.pyfiles intests/directory - Async support:
asyncio_mode = "auto" - Coverage reporting: HTML reports in
htmlcov/ - Markers:
slowandintegrationfor test categorization - Configuration in
pyproject.tomlunder[tool.pytest.ini_options]
- Black formatting (88 char line length)
- Ruff linting with strict rules
- Mypy type checking with strict settings
- Configuration in
pyproject.toml
Follow these commit message patterns when making changes:
fix[component]: description- Bug fixes (e.g.,fix[parser]: handle edge case in import resolution)feat[component]: description- New features (e.g.,feat[builder]: add shared file support)refactor[component]: description- Code refactoring (e.g.,refactor[auth]: simplify provider creation)test[component]: description- Test additions/changes (e.g.,test[core]: add integration tests)docs[component]: description- Documentation updates (e.g.,docs[api]: update authentication guide)style[component]: description- Code formatting (e.g.,style[core]: format with ruff)
Examples from recent commits:
fix[parser]: add shared file discovery for enhanced importsfix[builder]: enhance import mapping for any shared filefix[transformer]: improve import transformation patterns
Golf projects have this structure:
project/
├── golf.json # Configuration
├── tools/ # Tool implementations
├── resources/ # Resource implementations
├── prompts/ # Prompt templates
└── auth.py # Optional authentication configuration
Component IDs are derived from file paths: tools/payments/charge.py becomes charge_payments.
Golf 0.2.x uses FastMCP's built-in authentication providers:
# In auth.py
from golf.auth import configure_jwt_auth
configure_jwt_auth(
jwks_uri_env_var="JWKS_URI", # JWKS endpoint
issuer_env_var="JWT_ISSUER",
audience_env_var="JWT_AUDIENCE",
required_scopes=["read:user"],
)# In auth.py
from golf.auth import configure_dev_auth
configure_dev_auth(
tokens={
"dev-token-123": {
"client_id": "dev-client",
"scopes": ["read", "write"],
}
},
required_scopes=["read"],
)# In auth.py
from golf.auth import configure_api_key
configure_api_key(
header_name="Authorization",
header_prefix="Bearer ",
required=True,
)