golf-mcp 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of golf-mcp might be problematic. Click here for more details.

Files changed (65) hide show
  1. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/PKG-INFO +1 -1
  2. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/pyproject.toml +2 -2
  3. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/__init__.py +1 -1
  4. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/__init__.py +17 -15
  5. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/helpers.py +66 -0
  6. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/providers.py +19 -23
  7. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/resources/weather/city.py +3 -3
  8. golf_mcp-0.2.4/src/golf/examples/basic/resources/weather/common.py → golf_mcp-0.2.6/src/golf/examples/basic/resources/weather/client.py +2 -1
  9. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/resources/weather/current.py +3 -3
  10. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/resources/weather/forecast.py +3 -3
  11. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/PKG-INFO +1 -1
  12. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/SOURCES.txt +1 -1
  13. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/.docs/docs.md +0 -0
  14. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/.docs/fastmcp-diff.md +0 -0
  15. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/.docs/mcp.md +0 -0
  16. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/LICENSE +0 -0
  17. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/MANIFEST.in +0 -0
  18. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/README.md +0 -0
  19. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/setup.cfg +0 -0
  20. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/setup.py +0 -0
  21. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/_endpoints.py.in +0 -0
  22. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/_endpoints_fallback.py +0 -0
  23. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/api_key.py +0 -0
  24. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/factory.py +0 -0
  25. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/auth/registry.py +0 -0
  26. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/cli/__init__.py +0 -0
  27. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/cli/branding.py +0 -0
  28. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/cli/main.py +0 -0
  29. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/commands/__init__.py +0 -0
  30. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/commands/build.py +0 -0
  31. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/commands/init.py +0 -0
  32. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/commands/run.py +0 -0
  33. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/__init__.py +0 -0
  34. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/builder.py +0 -0
  35. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/builder_auth.py +0 -0
  36. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/builder_metrics.py +0 -0
  37. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/builder_telemetry.py +0 -0
  38. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/config.py +0 -0
  39. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/parser.py +0 -0
  40. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/platform.py +0 -0
  41. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/telemetry.py +0 -0
  42. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/core/transformer.py +0 -0
  43. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/__init__.py +0 -0
  44. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/.env.example +0 -0
  45. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/README.md +0 -0
  46. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/auth.py +0 -0
  47. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/golf.json +0 -0
  48. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/prompts/welcome.py +0 -0
  49. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/resources/current_time.py +0 -0
  50. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/resources/info.py +0 -0
  51. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/tools/calculator.py +0 -0
  52. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/examples/basic/tools/say/hello.py +0 -0
  53. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/metrics/__init__.py +0 -0
  54. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/metrics/collector.py +0 -0
  55. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/metrics/registry.py +0 -0
  56. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/telemetry/__init__.py +0 -0
  57. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/telemetry/instrumentation.py +0 -0
  58. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/utilities/__init__.py +0 -0
  59. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/utilities/context.py +0 -0
  60. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/utilities/elicitation.py +0 -0
  61. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf/utilities/sampling.py +0 -0
  62. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/dependency_links.txt +0 -0
  63. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/entry_points.txt +0 -0
  64. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/requires.txt +0 -0
  65. {golf_mcp-0.2.4 → golf_mcp-0.2.6}/src/golf_mcp.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: golf-mcp
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Framework for building MCP servers
5
5
  Author-email: Antoni Gmitruk <antoni@golf.dev>
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "golf-mcp"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  description = "Framework for building MCP servers"
9
9
  authors = [
10
10
  {name = "Antoni Gmitruk", email = "antoni@golf.dev"}
@@ -66,7 +66,7 @@ golf = ["examples/**/*"]
66
66
 
67
67
  [tool.poetry]
68
68
  name = "golf-mcp"
69
- version = "0.2.4"
69
+ version = "0.2.6"
70
70
  description = "Framework for building MCP servers with zero boilerplate"
71
71
  authors = ["Antoni Gmitruk <antoni@golf.dev>"]
72
72
  license = "Apache-2.0"
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.4"
1
+ __version__ = "0.2.6"
2
2
 
3
3
  # Import endpoints with fallback for dev mode
4
4
  try:
@@ -35,6 +35,7 @@ from .helpers import (
35
35
  debug_api_key_context,
36
36
  extract_token_from_header,
37
37
  get_api_key,
38
+ get_auth_token,
38
39
  get_provider_token,
39
40
  set_api_key,
40
41
  )
@@ -72,6 +73,7 @@ __all__ = [
72
73
  "debug_api_key_context",
73
74
  "extract_token_from_header",
74
75
  "get_api_key",
76
+ "get_auth_token",
75
77
  "get_provider_token",
76
78
  "set_api_key",
77
79
  ]
@@ -195,14 +197,14 @@ def configure_dev_auth(
195
197
 
196
198
 
197
199
  def configure_oauth_proxy(
198
- upstream_authorization_endpoint: str,
199
- upstream_token_endpoint: str,
200
- upstream_client_id: str,
201
- upstream_client_secret: str,
200
+ authorization_endpoint: str,
201
+ token_endpoint: str,
202
+ client_id: str,
203
+ client_secret: str,
202
204
  base_url: str,
203
205
  token_verifier_config: JWTAuthConfig | StaticTokenConfig,
204
206
  scopes_supported: list[str] | None = None,
205
- upstream_revocation_endpoint: str | None = None,
207
+ revocation_endpoint: str | None = None,
206
208
  redirect_path: str = "/oauth/callback",
207
209
  ) -> None:
208
210
  """Configure OAuth proxy authentication for non-DCR providers.
@@ -212,25 +214,25 @@ def configure_oauth_proxy(
212
214
  fixed client credentials.
213
215
 
214
216
  Args:
215
- upstream_authorization_endpoint: Provider's authorization URL
216
- upstream_token_endpoint: Provider's token endpoint URL
217
- upstream_client_id: Your client ID registered with the provider
218
- upstream_client_secret: Your client secret from the provider
217
+ authorization_endpoint: Provider's authorization URL
218
+ token_endpoint: Provider's token endpoint URL
219
+ client_id: Your client ID registered with the provider
220
+ client_secret: Your client secret from the provider
219
221
  base_url: This proxy server's public URL
220
222
  token_verifier_config: JWT or static token config for token verification
221
223
  scopes_supported: Scopes to advertise to MCP clients
222
- upstream_revocation_endpoint: Optional token revocation endpoint
224
+ revocation_endpoint: Optional token revocation endpoint
223
225
  redirect_path: OAuth callback path (default: /oauth/callback)
224
226
 
225
227
  Note:
226
228
  Requires golf-mcp-enterprise package for implementation.
227
229
  """
228
230
  config = OAuthProxyConfig(
229
- upstream_authorization_endpoint=upstream_authorization_endpoint,
230
- upstream_token_endpoint=upstream_token_endpoint,
231
- upstream_client_id=upstream_client_id,
232
- upstream_client_secret=upstream_client_secret,
233
- upstream_revocation_endpoint=upstream_revocation_endpoint,
231
+ authorization_endpoint=authorization_endpoint,
232
+ token_endpoint=token_endpoint,
233
+ client_id=client_id,
234
+ client_secret=client_secret,
235
+ revocation_endpoint=revocation_endpoint,
234
236
  base_url=base_url,
235
237
  redirect_path=redirect_path,
236
238
  scopes_supported=scopes_supported or [],
@@ -142,6 +142,72 @@ def get_api_key_from_request(request: Request) -> str | None:
142
142
  return _current_api_key.get()
143
143
 
144
144
 
145
+ def get_auth_token() -> str | None:
146
+ """Get the authorization token from the current request context.
147
+
148
+ This function should be used in tools to retrieve the authorization token
149
+ (typically a JWT or OAuth token) that was sent in the request headers.
150
+
151
+ Unlike get_api_key(), this function extracts the raw token from the Authorization
152
+ header without stripping any prefix, making it suitable for passing through
153
+ to upstream APIs that expect the full Authorization header value.
154
+
155
+ Returns:
156
+ The authorization token if available, None otherwise
157
+
158
+ Example:
159
+ # In a tool file
160
+ from golf.auth import get_auth_token
161
+
162
+ async def call_upstream_api():
163
+ auth_token = get_auth_token()
164
+ if not auth_token:
165
+ return {"error": "No authorization token provided"}
166
+
167
+ # Use the full token in upstream request
168
+ headers = {"Authorization": f"Bearer {auth_token}"}
169
+ async with httpx.AsyncClient() as client:
170
+ response = await client.get("https://api.example.com/data", headers=headers)
171
+ ...
172
+ """
173
+ # Try to get directly from HTTP request if available (FastMCP pattern)
174
+ try:
175
+ # This follows the FastMCP pattern for accessing HTTP requests
176
+ from fastmcp.server.dependencies import get_http_request
177
+
178
+ request = get_http_request()
179
+
180
+ if request and hasattr(request, "state") and hasattr(request.state, "auth_token"):
181
+ return request.state.auth_token
182
+
183
+ if request:
184
+ # Extract authorization token from Authorization header
185
+ auth_header = None
186
+ for k, v in request.headers.items():
187
+ if k.lower() == "authorization":
188
+ auth_header = v
189
+ break
190
+
191
+ if auth_header:
192
+ # Extract the token part (everything after "Bearer ")
193
+ token = extract_token_from_header(auth_header)
194
+ if token:
195
+ return token
196
+
197
+ # If not Bearer format, return the whole header value minus "Bearer " prefix if present
198
+ if auth_header.lower().startswith("bearer "):
199
+ return auth_header[7:] # Remove "Bearer " prefix
200
+ return auth_header
201
+
202
+ except (ImportError, RuntimeError):
203
+ # FastMCP not available or not in HTTP context
204
+ pass
205
+ except Exception:
206
+ pass
207
+
208
+ return None
209
+
210
+
145
211
  def debug_api_key_context() -> dict[str, Any]:
146
212
  """Debug function to inspect API key context.
147
213
 
@@ -458,12 +458,12 @@ class OAuthProxyConfig(BaseModel):
458
458
 
459
459
  provider_type: Literal["oauth_proxy"] = "oauth_proxy"
460
460
 
461
- # Upstream OAuth provider configuration
462
- upstream_authorization_endpoint: str = Field(..., description="Upstream provider's authorization endpoint URL")
463
- upstream_token_endpoint: str = Field(..., description="Upstream provider's token endpoint URL")
464
- upstream_client_id: str = Field(..., description="Your registered client ID with the upstream provider")
465
- upstream_client_secret: str = Field(..., description="Your registered client secret with the upstream provider")
466
- upstream_revocation_endpoint: str | None = Field(None, description="Optional upstream token revocation endpoint")
461
+ # OAuth provider configuration
462
+ authorization_endpoint: str = Field(..., description="OAuth provider's authorization endpoint URL")
463
+ token_endpoint: str = Field(..., description="OAuth provider's token endpoint URL")
464
+ client_id: str = Field(..., description="Your registered client ID with the OAuth provider")
465
+ client_secret: str = Field(..., description="Your registered client secret with the OAuth provider")
466
+ revocation_endpoint: str | None = Field(None, description="Optional token revocation endpoint")
467
467
 
468
468
  # This proxy server configuration
469
469
  base_url: str = Field(..., description="Public URL of this OAuth proxy server")
@@ -476,22 +476,18 @@ class OAuthProxyConfig(BaseModel):
476
476
  )
477
477
 
478
478
  # Environment variable names for runtime configuration
479
- upstream_authorization_endpoint_env_var: str | None = Field(
480
- None, description="Environment variable name for upstream authorization endpoint"
479
+ authorization_endpoint_env_var: str | None = Field(
480
+ None, description="Environment variable name for authorization endpoint"
481
481
  )
482
- upstream_token_endpoint_env_var: str | None = Field(
483
- None, description="Environment variable name for upstream token endpoint"
484
- )
485
- upstream_client_id_env_var: str | None = Field(None, description="Environment variable name for upstream client ID")
486
- upstream_client_secret_env_var: str | None = Field(
487
- None, description="Environment variable name for upstream client secret"
488
- )
489
- upstream_revocation_endpoint_env_var: str | None = Field(
490
- None, description="Environment variable name for upstream revocation endpoint"
482
+ token_endpoint_env_var: str | None = Field(None, description="Environment variable name for token endpoint")
483
+ client_id_env_var: str | None = Field(None, description="Environment variable name for client ID")
484
+ client_secret_env_var: str | None = Field(None, description="Environment variable name for client secret")
485
+ revocation_endpoint_env_var: str | None = Field(
486
+ None, description="Environment variable name for revocation endpoint"
491
487
  )
492
488
  base_url_env_var: str | None = Field(None, description="Environment variable name for base URL")
493
489
 
494
- @field_validator("upstream_authorization_endpoint", "upstream_token_endpoint", "base_url")
490
+ @field_validator("authorization_endpoint", "token_endpoint", "base_url")
495
491
  @classmethod
496
492
  def validate_required_urls(cls, v: str) -> str:
497
493
  """Validate required URLs are properly formatted."""
@@ -514,7 +510,7 @@ class OAuthProxyConfig(BaseModel):
514
510
 
515
511
  return url
516
512
 
517
- @field_validator("upstream_revocation_endpoint")
513
+ @field_validator("revocation_endpoint")
518
514
  @classmethod
519
515
  def validate_optional_url(cls, v: str | None) -> str | None:
520
516
  """Validate optional URLs are properly formatted."""
@@ -588,12 +584,12 @@ class OAuthProxyConfig(BaseModel):
588
584
 
589
585
  urls_to_check = [
590
586
  ("base_url", self.base_url),
591
- ("upstream_authorization_endpoint", self.upstream_authorization_endpoint),
592
- ("upstream_token_endpoint", self.upstream_token_endpoint),
587
+ ("authorization_endpoint", self.authorization_endpoint),
588
+ ("token_endpoint", self.token_endpoint),
593
589
  ]
594
590
 
595
- if self.upstream_revocation_endpoint:
596
- urls_to_check.append(("upstream_revocation_endpoint", self.upstream_revocation_endpoint))
591
+ if self.revocation_endpoint:
592
+ urls_to_check.append(("revocation_endpoint", self.revocation_endpoint))
597
593
 
598
594
  for field_name, url in urls_to_check:
599
595
  parsed = urlparse(url)
@@ -3,7 +3,7 @@
3
3
  from datetime import datetime
4
4
  from typing import Any
5
5
 
6
- from .common import weather_client
6
+ from .client import weather_client
7
7
 
8
8
  # The URI template that clients will use to access this resource
9
9
  # The {city} parameter makes this a resource template
@@ -16,7 +16,7 @@ async def get_weather_for_city(city: str) -> dict[str, Any]:
16
16
  This example demonstrates:
17
17
  1. Resource templates with URI parameters ({city})
18
18
  2. Dynamic resource access based on parameters
19
- 3. Using shared client from the common.py file
19
+ 3. Using shared client from the client.py file
20
20
  4. FastMCP 2.11+ ResourceTemplate.from_function() usage
21
21
 
22
22
  Args:
@@ -25,7 +25,7 @@ async def get_weather_for_city(city: str) -> dict[str, Any]:
25
25
  Returns:
26
26
  Weather data for the specified city
27
27
  """
28
- # Use the shared weather client from common.py
28
+ # Use the shared weather client from client.py
29
29
  weather_data = await weather_client.get_current(city)
30
30
 
31
31
  # Add some additional data
@@ -1,7 +1,8 @@
1
1
  """Weather shared functionality.
2
2
 
3
- This common.py file demonstrates the recommended pattern for
3
+ This file demonstrates the recommended pattern for
4
4
  sharing functionality across multiple resources in a directory.
5
+ Golf automatically discovers and includes shared Python files in builds.
5
6
  """
6
7
 
7
8
  import os
@@ -3,7 +3,7 @@
3
3
  from datetime import datetime
4
4
  from typing import Any
5
5
 
6
- from .common import weather_client
6
+ from .client import weather_client
7
7
 
8
8
  # The URI that clients will use to access this resource
9
9
  resource_uri = "weather://current"
@@ -15,9 +15,9 @@ async def current_weather() -> dict[str, Any]:
15
15
  This example demonstrates:
16
16
  1. Nested resource organization (resources/weather/current.py)
17
17
  2. Resource without URI parameters
18
- 3. Using shared client from the common.py file
18
+ 3. Using shared client from the client.py file
19
19
  """
20
- # Use the shared weather client from common.py
20
+ # Use the shared weather client from client.py
21
21
  weather_data = await weather_client.get_current("New York")
22
22
 
23
23
  # Add some additional data
@@ -3,7 +3,7 @@
3
3
  from datetime import datetime
4
4
  from typing import Any
5
5
 
6
- from .common import weather_client
6
+ from .client import weather_client
7
7
 
8
8
  # The URI that clients will use to access this resource
9
9
  resource_uri = "weather://forecast"
@@ -15,9 +15,9 @@ async def forecast_weather() -> dict[str, Any]:
15
15
  This example demonstrates:
16
16
  1. Nested resource organization (resources/weather/forecast.py)
17
17
  2. Resource without URI parameters
18
- 3. Using shared client from the common.py file
18
+ 3. Using shared client from the client.py file
19
19
  """
20
- # Use the shared weather client from common.py
20
+ # Use the shared weather client from client.py
21
21
  forecast_data = await weather_client.get_forecast("New York", days=5)
22
22
 
23
23
  # Add some additional data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: golf-mcp
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: Framework for building MCP servers
5
5
  Author-email: Antoni Gmitruk <antoni@golf.dev>
6
6
  License-Expression: Apache-2.0
@@ -41,7 +41,7 @@ src/golf/examples/basic/prompts/welcome.py
41
41
  src/golf/examples/basic/resources/current_time.py
42
42
  src/golf/examples/basic/resources/info.py
43
43
  src/golf/examples/basic/resources/weather/city.py
44
- src/golf/examples/basic/resources/weather/common.py
44
+ src/golf/examples/basic/resources/weather/client.py
45
45
  src/golf/examples/basic/resources/weather/current.py
46
46
  src/golf/examples/basic/resources/weather/forecast.py
47
47
  src/golf/examples/basic/tools/calculator.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes