golf-mcp 0.2.6__py3-none-any.whl → 0.2.8__py3-none-any.whl

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.

golf/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.6"
1
+ __version__ = "0.2.8"
2
2
 
3
3
  # Import endpoints with fallback for dev mode
4
4
  try:
golf/auth/__init__.py CHANGED
@@ -235,7 +235,7 @@ def configure_oauth_proxy(
235
235
  revocation_endpoint=revocation_endpoint,
236
236
  base_url=base_url,
237
237
  redirect_path=redirect_path,
238
- scopes_supported=scopes_supported or [],
238
+ scopes_supported=scopes_supported,
239
239
  token_verifier_config=token_verifier_config,
240
240
  )
241
241
  configure_auth(config)
golf/auth/providers.py CHANGED
@@ -470,7 +470,9 @@ class OAuthProxyConfig(BaseModel):
470
470
  redirect_path: str = Field("/oauth/callback", description="OAuth callback path (must match provider registration)")
471
471
 
472
472
  # Scopes and token verification
473
- scopes_supported: list[str] = Field(default_factory=list, description="Scopes supported by this proxy")
473
+ scopes_supported: list[str] | None = Field(
474
+ None, description="Scopes supported by this proxy (optional, can be empty for intelligent fallback)"
475
+ )
474
476
  token_verifier_config: JWTAuthConfig | StaticTokenConfig = Field(
475
477
  ..., description="Token verifier configuration for validating upstream tokens"
476
478
  )
@@ -536,40 +538,14 @@ class OAuthProxyConfig(BaseModel):
536
538
 
537
539
  return url
538
540
 
539
- @field_validator("scopes_supported")
540
- @classmethod
541
- def validate_scopes_supported(cls, v: list[str]) -> list[str]:
542
- """Validate scopes_supported format and security."""
543
- if not v:
544
- return v
545
-
546
- cleaned_scopes = []
547
- for scope in v:
548
- scope = scope.strip()
549
- if not scope:
550
- raise ValueError("Scopes cannot be empty or whitespace-only")
551
-
552
- # OAuth 2.0 scope format validation (RFC 6749)
553
- if not all(32 < ord(c) < 127 and c not in ' "\\' for c in scope):
554
- raise ValueError(
555
- f"Invalid scope format: '{scope}' - must be ASCII printable without spaces, quotes, or backslashes"
556
- )
557
-
558
- # Reasonable length limit to prevent abuse
559
- if len(scope) > 128:
560
- raise ValueError(f"Scope too long: '{scope}' - maximum 128 characters")
561
-
562
- cleaned_scopes.append(scope)
563
-
564
- return cleaned_scopes
565
-
566
541
  @model_validator(mode="after")
567
542
  def validate_oauth_proxy_config(self) -> "OAuthProxyConfig":
568
543
  """Validate OAuth proxy configuration consistency."""
569
544
  # Validate token verifier config is compatible
570
545
  if not isinstance(self.token_verifier_config, JWTAuthConfig | StaticTokenConfig):
571
546
  raise ValueError(
572
- f"token_verifier_config must be JWTAuthConfig or StaticTokenConfig, got {type(self.token_verifier_config).__name__}"
547
+ f"token_verifier_config must be JWTAuthConfig or StaticTokenConfig, "
548
+ f"got {type(self.token_verifier_config).__name__}"
573
549
  )
574
550
 
575
551
  # Warn about HTTPS requirements in production
golf/core/builder.py CHANGED
@@ -170,6 +170,41 @@ class ManifestBuilder:
170
170
  console.print(f"[green]Manifest saved to {output_path}[/green]")
171
171
  return output_path
172
172
 
173
+ def _get_fastmcp_version(self) -> str | None:
174
+ """Get the installed FastMCP version.
175
+
176
+ Returns:
177
+ FastMCP version string (e.g., "2.12.0") or None if not available
178
+ """
179
+ try:
180
+ import fastmcp
181
+
182
+ return fastmcp.__version__
183
+ except (ImportError, AttributeError):
184
+ return None
185
+
186
+ def _is_fastmcp_version_gte(self, target_version: str) -> bool:
187
+ """Check if installed FastMCP version is >= target version.
188
+
189
+ Args:
190
+ target_version: Version string to compare against (e.g., "2.12.0")
191
+
192
+ Returns:
193
+ True if FastMCP version >= target_version, False otherwise
194
+ """
195
+ try:
196
+ from packaging import version
197
+
198
+ current_version = self._get_fastmcp_version()
199
+ if current_version is None:
200
+ # Default to older behavior for safety
201
+ return False
202
+
203
+ return version.parse(current_version) >= version.parse(target_version)
204
+ except (ImportError, ValueError):
205
+ # Default to older behavior for safety
206
+ return False
207
+
173
208
 
174
209
  def build_manifest(project_path: Path, settings: Settings) -> dict[str, Any]:
175
210
  """Build a FastMCP manifest from parsed components.
@@ -511,6 +546,41 @@ class CodeGenerator:
511
546
  and len(component.parameters) > 0
512
547
  )
513
548
 
549
+ def _get_fastmcp_version(self) -> str | None:
550
+ """Get the installed FastMCP version.
551
+
552
+ Returns:
553
+ FastMCP version string (e.g., "2.12.0") or None if not available
554
+ """
555
+ try:
556
+ import fastmcp
557
+
558
+ return fastmcp.__version__
559
+ except (ImportError, AttributeError):
560
+ return None
561
+
562
+ def _is_fastmcp_version_gte(self, target_version: str) -> bool:
563
+ """Check if installed FastMCP version is >= target version.
564
+
565
+ Args:
566
+ target_version: Version string to compare against (e.g., "2.12.0")
567
+
568
+ Returns:
569
+ True if FastMCP version >= target_version, False otherwise
570
+ """
571
+ try:
572
+ from packaging import version
573
+
574
+ current_version = self._get_fastmcp_version()
575
+ if current_version is None:
576
+ # Default to older behavior for safety
577
+ return False
578
+
579
+ return version.parse(current_version) >= version.parse(target_version)
580
+ except (ImportError, ValueError):
581
+ # Default to older behavior for safety
582
+ return False
583
+
514
584
  def _generate_server(self) -> None:
515
585
  """Generate the main server entry point."""
516
586
  server_file = self.output_dir / "server.py"
@@ -956,23 +1026,40 @@ class CodeGenerator:
956
1026
  main_code.extend(middleware_setup)
957
1027
  main_code.append(f" middleware = [{', '.join(middleware_list)}]")
958
1028
  main_code.append("")
959
- main_code.extend(
960
- [
961
- " # Run SSE server with middleware using FastMCP's run method",
962
- f' mcp.run(transport="sse", host=host, port=port, '
963
- f'path="{endpoint_path}", log_level="info", '
964
- f"middleware=middleware, show_banner=False)",
965
- ]
966
- )
1029
+ if self._is_fastmcp_version_gte("2.12.0"):
1030
+ main_code.extend(
1031
+ [
1032
+ " # Run SSE server with middleware using FastMCP's run method",
1033
+ ' mcp.run(transport="sse", host=host, port=port, '
1034
+ 'log_level="info", middleware=middleware, show_banner=False)',
1035
+ ]
1036
+ )
1037
+ else:
1038
+ main_code.extend(
1039
+ [
1040
+ " # Run SSE server with middleware using FastMCP's run method",
1041
+ f' mcp.run(transport="sse", host=host, port=port, '
1042
+ f'path="{endpoint_path}", log_level="info", '
1043
+ f"middleware=middleware, show_banner=False)",
1044
+ ]
1045
+ )
967
1046
  else:
968
- main_code.extend(
969
- [
970
- " # Run SSE server using FastMCP's run method",
971
- f' mcp.run(transport="sse", host=host, port=port, '
972
- f'path="{endpoint_path}", log_level="info", '
973
- f"show_banner=False)",
974
- ]
975
- )
1047
+ if self._is_fastmcp_version_gte("2.12.0"):
1048
+ main_code.extend(
1049
+ [
1050
+ " # Run SSE server using FastMCP's run method",
1051
+ ' mcp.run(transport="sse", host=host, port=port, log_level="info", show_banner=False)',
1052
+ ]
1053
+ )
1054
+ else:
1055
+ main_code.extend(
1056
+ [
1057
+ " # Run SSE server using FastMCP's run method",
1058
+ f' mcp.run(transport="sse", host=host, port=port, '
1059
+ f'path="{endpoint_path}", log_level="info", '
1060
+ f"show_banner=False)",
1061
+ ]
1062
+ )
976
1063
 
977
1064
  elif self.settings.transport in ["streamable-http", "http"]:
978
1065
  # Check if we need middleware for streamable-http
@@ -999,23 +1086,41 @@ class CodeGenerator:
999
1086
  main_code.extend(middleware_setup)
1000
1087
  main_code.append(f" middleware = [{', '.join(middleware_list)}]")
1001
1088
  main_code.append("")
1002
- main_code.extend(
1003
- [
1004
- " # Run HTTP server with middleware using FastMCP's run method",
1005
- f' mcp.run(transport="streamable-http", host=host, '
1006
- f'port=port, path="{endpoint_path}", log_level="info", '
1007
- f"middleware=middleware, show_banner=False)",
1008
- ]
1009
- )
1089
+ if self._is_fastmcp_version_gte("2.12.0"):
1090
+ main_code.extend(
1091
+ [
1092
+ " # Run HTTP server with middleware using FastMCP's run method",
1093
+ ' mcp.run(transport="streamable-http", host=host, '
1094
+ 'port=port, log_level="info", middleware=middleware, show_banner=False)',
1095
+ ]
1096
+ )
1097
+ else:
1098
+ main_code.extend(
1099
+ [
1100
+ " # Run HTTP server with middleware using FastMCP's run method",
1101
+ f' mcp.run(transport="streamable-http", host=host, '
1102
+ f'port=port, path="{endpoint_path}", log_level="info", '
1103
+ f"middleware=middleware, show_banner=False)",
1104
+ ]
1105
+ )
1010
1106
  else:
1011
- main_code.extend(
1012
- [
1013
- " # Run HTTP server using FastMCP's run method",
1014
- f' mcp.run(transport="streamable-http", host=host, '
1015
- f'port=port, path="{endpoint_path}", log_level="info", '
1016
- f"show_banner=False)",
1017
- ]
1018
- )
1107
+ if self._is_fastmcp_version_gte("2.12.0"):
1108
+ main_code.extend(
1109
+ [
1110
+ " # Run HTTP server using FastMCP's run method",
1111
+ ' mcp.run(transport="streamable-http", host=host, '
1112
+ 'port=port, log_level="info", show_banner=False)',
1113
+ ]
1114
+ )
1115
+ else:
1116
+ main_code.extend(
1117
+ [
1118
+ " # Run HTTP server using FastMCP's run method",
1119
+ f' mcp.run(transport="streamable-http", host=host, '
1120
+ f'port=port, path="{endpoint_path}", log_level="info", '
1121
+ f"show_banner=False)",
1122
+ ]
1123
+ )
1019
1124
  else:
1020
1125
  # For stdio transport, use mcp.run()
1021
1126
  main_code.extend([" # Run with stdio transport", ' mcp.run(transport="stdio", show_banner=False)'])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: golf-mcp
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Framework for building MCP servers
5
5
  Author-email: Antoni Gmitruk <antoni@golf.dev>
6
6
  License-Expression: Apache-2.0
@@ -132,7 +132,6 @@ A Golf project initialized with `golf init` will have a structure similar to thi
132
132
  - **`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.
133
133
  - **`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.
134
134
  - 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).
135
- - **`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.
136
135
 
137
136
  ## Example: Defining a Tool
138
137
 
@@ -1,12 +1,12 @@
1
- golf/__init__.py,sha256=qWIRfT1s1Et0Jru9N8JfQhbMc-CsZpqWQV9S0Ay5YPk,306
1
+ golf/__init__.py,sha256=22iRBt6mUc1Eiq6uhr-REdh-_NN9o_9MFc7aHLsImkM,306
2
2
  golf/_endpoints.py,sha256=-mvAmjx3YtqfAdajO13Kv7LKVBMdqsKqX0_3aCmCK4I,317
3
3
  golf/_endpoints.py.in,sha256=MeqcSF6xinnPknpBGF26xA9FYmSYKSWqCFXOSDlXiOA,216
4
4
  golf/_endpoints_fallback.py,sha256=CD6m45Ams1A9HVKowY8dCFUDMiFmJ8ZWSwHCENvU5u4,386
5
- golf/auth/__init__.py,sha256=u-6_EFTvfs91B2Jko39swp3tCpHkj3r9wDQzQBmfxn0,8027
5
+ golf/auth/__init__.py,sha256=9VsuGjoP-MTY-CRiPfPKGuD096OMUpCQoAlMJU8RzIE,8021
6
6
  golf/auth/api_key.py,sha256=OonqTlG6USJxqK8TlPviJTv7sgYmTVfCxG_JsEjnEM4,2320
7
7
  golf/auth/factory.py,sha256=3-il1GbjjZlQfvWUZs-09r61Y_-b5cYEegWF7sY_cUs,13128
8
8
  golf/auth/helpers.py,sha256=WoYyjUAQwgDnLvJDvyhuEOmm8w0fQ-ZDqaYxs_lC8nw,8127
9
- golf/auth/providers.py,sha256=qgybeHtrb0MojUsXZm813gzT4zBCNxCiSCWvxKG2iis,25950
9
+ golf/auth/providers.py,sha256=f89WeQUrYopS0GBcTO3yXlqyPQvG7s7GpaiUK2tb2ME,25048
10
10
  golf/auth/registry.py,sha256=Rjj7LnWvzEsI1GCnFbFcxpRllrVanD9bumWPaJ1giFQ,7960
11
11
  golf/cli/__init__.py,sha256=R8Y8KdD2C8gDo24fXGq-fdWWNeaq3MYjrbaSB8Hb-Hg,45
12
12
  golf/cli/branding.py,sha256=ndpy2kVxBzqr4fwsAlh_fbhxqgRPoF6kM3ufP9hg5QI,6896
@@ -16,7 +16,7 @@ golf/commands/build.py,sha256=sLq9lSW4naq2vIlBreKI5SGnviQrhBWw13zfOZOKhuM,2293
16
16
  golf/commands/init.py,sha256=KkAg_3-KxBDFOcZqUHqcPAkDipykFVaLWpQ2tydnVPk,9617
17
17
  golf/commands/run.py,sha256=a8GSwLt6E2cUJespv-u3jbD-rNUMHqF3VArD1uXV-Vk,4299
18
18
  golf/core/__init__.py,sha256=4bKeskJ2fPaZqkz2xQScSa3phRLLrmrczwSL632jv-o,52
19
- golf/core/builder.py,sha256=Ghm9YUDIWnUc0bIxfKD75OZIa-h0B61iC26OEmfA4ug,62214
19
+ golf/core/builder.py,sha256=Tx6AtWnnasY_Rfu1CEdhE7y3hZdN0RuhwLevJU9vZgo,66355
20
20
  golf/core/builder_auth.py,sha256=SXPCpc5ipntoNqIAIA2ZCeGmEua6QVs7yC3MDtGKAro,8224
21
21
  golf/core/builder_metrics.py,sha256=j6Gtgd867o46JbDfSNGNsHt1QtV1XHKUJs1z8r4siQM,8830
22
22
  golf/core/builder_telemetry.py,sha256=86bp7UlMUN6JyQRrZ5EizovP6AJ_q65OANJTeJXDIKc,3421
@@ -48,9 +48,9 @@ golf/utilities/__init__.py,sha256=X9iY9yi3agz1GVcn8-qWeOCt8CSSsruHxqPNtiF63TY,53
48
48
  golf/utilities/context.py,sha256=DGGvhVe---QMhy0wtdWhNp-_WVk1NvAcOFn0uBKBpYo,1579
49
49
  golf/utilities/elicitation.py,sha256=MParZZZsY45s70-KXduHa6IvpWXnLW2FCPfrGijMaHs,5223
50
50
  golf/utilities/sampling.py,sha256=88nDv-trBE4gZQbcnMjXl3LW6TiIhv5zR_cuEIGjaIM,7233
51
- golf_mcp-0.2.6.dist-info/licenses/LICENSE,sha256=5_j2f6fTJmvfmUewzElhkpAaXg2grVoxKouOA8ihV6E,11348
52
- golf_mcp-0.2.6.dist-info/METADATA,sha256=yE954KDxWowq6DfMIUQne6Ypl4LsWEqSTeqeHFXomaE,9558
53
- golf_mcp-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
54
- golf_mcp-0.2.6.dist-info/entry_points.txt,sha256=5y7rHYM8jGpU-nfwdknCm5XsApLulqsnA37MO6BUTYg,43
55
- golf_mcp-0.2.6.dist-info/top_level.txt,sha256=BQToHcBUufdyhp9ONGMIvPE40jMEtmI20lYaKb4hxOg,5
56
- golf_mcp-0.2.6.dist-info/RECORD,,
51
+ golf_mcp-0.2.8.dist-info/licenses/LICENSE,sha256=5_j2f6fTJmvfmUewzElhkpAaXg2grVoxKouOA8ihV6E,11348
52
+ golf_mcp-0.2.8.dist-info/METADATA,sha256=ebA3N_gR-sN6BRMP8j-2I-7VOn52L18Yih6C6vlK4cs,9370
53
+ golf_mcp-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
54
+ golf_mcp-0.2.8.dist-info/entry_points.txt,sha256=5y7rHYM8jGpU-nfwdknCm5XsApLulqsnA37MO6BUTYg,43
55
+ golf_mcp-0.2.8.dist-info/top_level.txt,sha256=BQToHcBUufdyhp9ONGMIvPE40jMEtmI20lYaKb4hxOg,5
56
+ golf_mcp-0.2.8.dist-info/RECORD,,