GolfMCP uses a convention-based project structure.
<project-root>/
├── golf.json
├── auth.py               # Authentication configuration (v0.2.0)
├── prompts/
│   └── example_prompt.py
├── resources/
│   └── example_resource.py
│   └── sub_category/
│       └── nested_resource.py
│       └── common.py
└── tools/
    └── example_tool.py
    └── payments/
        └── common.py
        └── get_balance.py
        └── transaction/
            └── submit.py
Deprecated: Authentication configuration in pre_build.py is deprecated. Use the dedicated auth.py file instead for cleaner organization and better maintainability.

Component Discovery

  • Each .py file within tools/, resources/, or prompts/ (and their subdirectories) is treated as a single component.
  • Files named __init__.py are ignored for direct component definition but are essential for Python’s packaging if you structure your components as modules.
  • Files named common.py are special and used for shared code (see Shared Logic documentation).
  • The auth.py file is treated specially for authentication configuration and is not considered a component.

Component ID Derivation

The unique ID for each component is derived from its file path relative to the category directory (tools, resources, prompts). Examples:
  • tools/hello.py -> ID: hello
  • tools/payments/transaction/submit.py -> ID: submit-transaction-payments
  • resources/weather/current.py -> ID: current-weather
ID collisions will result in a build-time error.

Authentication Configuration

The auth.py File (New in v0.2.0)

Golf v0.2.0 introduces a dedicated auth.py file for authentication configuration, providing better organization and cleaner separation from other build logic. Example auth.py configurations (for full details, see Authentication):
# auth.py - API Key Authentication
from golf.auth import configure_api_key

configure_api_key(
    header_name="Authorization",
    header_prefix="Bearer "
)
# auth.py - JWT Authentication
from golf.auth import configure_auth, JWTAuthConfig

configure_auth(
    JWTAuthConfig(
        jwks_uri_env_var="JWKS_URI",
        issuer_env_var="JWT_ISSUER",
        audience_env_var="JWT_AUDIENCE",
        required_scopes=["read:user"]
    )
)
# auth.py - Development Authentication
from golf.auth import configure_auth, StaticTokenConfig

configure_auth(
    StaticTokenConfig(
        tokens={
            "dev-token-123": {
                "client_id": "dev-client",
                "scopes": ["read", "write"]
            }
        },
        required_scopes=["read"]
    )
)