|
30 | 30 |
|
31 | 31 | Golf is a **framework** designed to streamline the creation of MCP server applications. It allows developers to define server's capabilities—*tools*, *prompts*, and *resources*—as simple Python files within a conventional directory structure. Golf then automatically discovers, parses, and compiles these components into a runnable FastMCP server, minimizing boilerplate and accelerating development. |
32 | 32 |
|
33 | | -With Golf v0.2.0, you get **enterprise-grade authentication** (JWT, API key, development tokens), **built-in utilities** for LLM interactions, and **automatic telemetry** integration. Focus on implementing your agent's logic while Golf handles authentication, monitoring, and server infrastructure. |
| 33 | +With Golf v0.2.0, you get **enterprise-grade authentication** (JWT, OAuth Server, API key, development tokens), **built-in utilities** for LLM interactions, and **automatic telemetry** integration. Focus on implementing your agent's logic while Golf handles authentication, monitoring, and server infrastructure. |
34 | 34 |
|
35 | 35 | ## Quick Start |
36 | 36 |
|
@@ -85,11 +85,11 @@ A Golf project initialized with `golf init` will have a structure similar to thi |
85 | 85 | │ └─ welcome.py # Example prompt |
86 | 86 | │ |
87 | 87 | ├─ .env # Environment variables (e.g., API keys, server port) |
88 | | -└─ auth.py # Authentication configuration (JWT, API key, dev tokens) |
| 88 | +└─ auth.py # Authentication configuration (JWT, OAuth Server, API key, dev tokens) |
89 | 89 | ``` |
90 | 90 |
|
91 | 91 | - **`golf.json`**: Configures server name, port, transport, telemetry, and other build settings. |
92 | | -- **`auth.py`**: Dedicated authentication configuration file (new in v0.2.0) for JWT, API key, or development authentication. |
| 92 | +- **`auth.py`**: Dedicated authentication configuration file (new in v0.2.0, breaking change from v0.1.x authentication API) for JWT, OAuth Server, API key, or development authentication. |
93 | 93 | - **`tools/`**, **`resources/`**, **`prompts/`**: Contain your Python files, each defining a single component. These directories can also contain nested subdirectories to further organize your components (e.g., `tools/payments/charge.py`). The module docstring of each file serves as the component's description. |
94 | 94 | - Component IDs are automatically derived from their file path. For example, `tools/hello.py` becomes `hello`, and a nested file like `tools/payments/submit.py` would become `submit_payments` (filename, followed by reversed parent directories under the main category, joined by underscores). |
95 | 95 | - **`common.py`** (not shown, but can be placed in subdirectories like `tools/payments/common.py`): Used to share code (clients, models, etc.) among components in the same subdirectory. |
@@ -132,10 +132,26 @@ Golf includes enterprise-grade authentication, built-in utilities, and automatic |
132 | 132 |
|
133 | 133 | ```python |
134 | 134 | # auth.py - Configure authentication |
135 | | -from golf.auth import configure_api_key, configure_jwt_auth, configure_dev_auth |
136 | | - |
137 | | -# API Key (pass-through to external APIs) |
138 | | -configure_api_key(header_name="Authorization", header_prefix="Bearer ") |
| 135 | +from golf.auth import configure_auth, JWTAuthConfig, StaticTokenConfig, OAuthServerConfig |
| 136 | + |
| 137 | +# JWT authentication (production) |
| 138 | +configure_auth(JWTAuthConfig( |
| 139 | + jwks_uri_env_var="JWKS_URI", |
| 140 | + issuer_env_var="JWT_ISSUER", |
| 141 | + audience_env_var="JWT_AUDIENCE", |
| 142 | + required_scopes=["read", "write"] |
| 143 | +)) |
| 144 | + |
| 145 | +# OAuth Server mode (Golf acts as OAuth 2.0 server) |
| 146 | +# configure_auth(OAuthServerConfig( |
| 147 | +# base_url="https://your-golf-server.com", |
| 148 | +# valid_scopes=["read", "write", "admin"] |
| 149 | +# )) |
| 150 | + |
| 151 | +# Static tokens (development only) |
| 152 | +# configure_auth(StaticTokenConfig( |
| 153 | +# tokens={"dev-token": {"client_id": "dev", "scopes": ["read"]}} |
| 154 | +# )) |
139 | 155 |
|
140 | 156 | # Built-in utilities available in all tools |
141 | 157 | from golf.utils import elicit, sample, get_context |
|
0 commit comments