golf
CLAUDE.md840 starsChanged 20 months agoApache-2.0View on GitHub
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.3.x targets FastMCP 4.0.0 and MCP 2026-07-28 while retaining FastMCP's legacy-client compatibility: Uses pytest with these key configurations: - Test discovery: test_*.py files in tests/ directory - Async support: asyncio_mode = "auto" - Coverage reporting: HTML reports in htmlcov/ - Markers: slow and integration for test…
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 76
Test discovery: test_*.py files in tests/ directory
- Distinctive: line 91
Follow these commit message patterns when making changes:
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
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.
Authentication Compatibility
Golf 0.3.x targets FastMCP 4.0.0 and MCP 2026-07-28 while retaining FastMCP's legacy-client compatibility:
- 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 exactly FastMCP 4.0.0, Python >=3.10, and Pydantic >=2.12
- Removed Files: Legacy
oauth.pyandprovider.pyfiles removed from auth module - Deprecated Functions:
get_provider_token()and OAuth-related helpers return None (legacy compatibility)
Key Architecture
- 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: JWT/OAuth auth using FastMCP 4.0.0 providers in
src/golf/auth/ - Telemetry: Anonymous usage tracking with OpenTelemetry support in
src/golf/telemetry/
Common Development Commands
Testing
# 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/ -vCode Quality
# Run linting (ruff)
python -m ruff check src/
# Format code (ruff format only)
python -m ruff format src/ tests/Installation
# Install in development mode with telemetry dependencies
make install-dev
# Test CLI installation
golf --versionProject Structure
src/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
Testing Framework
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]
Code Style
- Black formatting (88 char line length)
- Ruff linting with strict rules
- Mypy type checking with strict settings
- Configuration in
pyproject.toml
Git Commit Guidelines
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
Component System
Golf projects have this structure:
project/
├── golf.json # Configuration
├── tools/ # Tool implementations
├── resources/ # Resource implementations
├── prompts/ # Prompt templates
└── auth.py # Optional authentication configurationComponent IDs are derived from file paths: tools/payments/charge.py becomes charge_payments.
Authentication in Golf 0.3.x
Golf 0.3.x uses FastMCP 4.0.0's built-in authentication providers. JWT configurations require an audience/resource binding; inbound MCP resource tokens must never be forwarded to upstream APIs.
JWT Authentication (Production)
# 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"],
)Development Authentication
# 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"],
)API Key header extraction (deprecated)
configure_api_key() is not MCP authentication. It only extracts a
caller-provided header for get_api_key() so tools can forward that
credential to an upstream API, which validates it. Golf does not check
the key value. Use JWT, OAuth, or development tokens to authenticate
MCP clients. This helper will be removed in a future release.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

