golf-mcp 0.2.8__py3-none-any.whl → 0.2.10__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 +1 -1
- golf/auth/__init__.py +5 -0
- golf/core/builder.py +76 -1
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/METADATA +1 -1
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/RECORD +9 -9
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/WHEEL +0 -0
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/entry_points.txt +0 -0
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/licenses/LICENSE +0 -0
- {golf_mcp-0.2.8.dist-info → golf_mcp-0.2.10.dist-info}/top_level.txt +0 -0
golf/__init__.py
CHANGED
golf/auth/__init__.py
CHANGED
|
@@ -206,6 +206,7 @@ def configure_oauth_proxy(
|
|
|
206
206
|
scopes_supported: list[str] | None = None,
|
|
207
207
|
revocation_endpoint: str | None = None,
|
|
208
208
|
redirect_path: str = "/oauth/callback",
|
|
209
|
+
**env_vars: str,
|
|
209
210
|
) -> None:
|
|
210
211
|
"""Configure OAuth proxy authentication for non-DCR providers.
|
|
211
212
|
|
|
@@ -223,6 +224,9 @@ def configure_oauth_proxy(
|
|
|
223
224
|
scopes_supported: Scopes to advertise to MCP clients
|
|
224
225
|
revocation_endpoint: Optional token revocation endpoint
|
|
225
226
|
redirect_path: OAuth callback path (default: /oauth/callback)
|
|
227
|
+
**env_vars: Environment variable names (authorization_endpoint_env_var,
|
|
228
|
+
token_endpoint_env_var, client_id_env_var, client_secret_env_var,
|
|
229
|
+
base_url_env_var, revocation_endpoint_env_var)
|
|
226
230
|
|
|
227
231
|
Note:
|
|
228
232
|
Requires golf-mcp-enterprise package for implementation.
|
|
@@ -237,6 +241,7 @@ def configure_oauth_proxy(
|
|
|
237
241
|
redirect_path=redirect_path,
|
|
238
242
|
scopes_supported=scopes_supported,
|
|
239
243
|
token_verifier_config=token_verifier_config,
|
|
244
|
+
**env_vars,
|
|
240
245
|
)
|
|
241
246
|
configure_auth(config)
|
|
242
247
|
|
golf/core/builder.py
CHANGED
|
@@ -581,6 +581,70 @@ class CodeGenerator:
|
|
|
581
581
|
# Default to older behavior for safety
|
|
582
582
|
return False
|
|
583
583
|
|
|
584
|
+
def _generate_startup_section(self, project_path: Path) -> list[str]:
|
|
585
|
+
"""Generate code section for startup.py execution during server runtime."""
|
|
586
|
+
startup_path = project_path / "startup.py"
|
|
587
|
+
|
|
588
|
+
if not startup_path.exists():
|
|
589
|
+
return []
|
|
590
|
+
|
|
591
|
+
return [
|
|
592
|
+
"",
|
|
593
|
+
"# Execute startup script for loading secrets and initialization",
|
|
594
|
+
"import importlib.util",
|
|
595
|
+
"import sys",
|
|
596
|
+
"import os",
|
|
597
|
+
"from pathlib import Path",
|
|
598
|
+
"",
|
|
599
|
+
"# Look for startup.py in the same directory as this server.py",
|
|
600
|
+
"startup_path = Path(__file__).parent / 'startup.py'",
|
|
601
|
+
"if startup_path.exists():",
|
|
602
|
+
" try:",
|
|
603
|
+
" # Save original environment for restoration",
|
|
604
|
+
" try:",
|
|
605
|
+
" original_dir = os.getcwd()",
|
|
606
|
+
" except (FileNotFoundError, OSError):",
|
|
607
|
+
" # Use server directory as fallback",
|
|
608
|
+
" original_dir = str(Path(__file__).parent)",
|
|
609
|
+
" os.chdir(original_dir)",
|
|
610
|
+
" original_path = sys.path.copy()",
|
|
611
|
+
" ",
|
|
612
|
+
" # Set context for startup script execution",
|
|
613
|
+
" script_dir = str(startup_path.parent)",
|
|
614
|
+
" os.chdir(script_dir)",
|
|
615
|
+
" sys.path.insert(0, script_dir)",
|
|
616
|
+
" ",
|
|
617
|
+
" # Debug output for startup script development",
|
|
618
|
+
" if os.environ.get('GOLF_DEBUG'):",
|
|
619
|
+
" print(f'Executing startup script: {startup_path}')",
|
|
620
|
+
" print(f'Working directory: {os.getcwd()}')",
|
|
621
|
+
" print(f'Python path: {sys.path[:3]}...')", # Show first 3 entries
|
|
622
|
+
" ",
|
|
623
|
+
" # Load and execute startup script",
|
|
624
|
+
" spec = importlib.util.spec_from_file_location('startup', startup_path)",
|
|
625
|
+
" if spec and spec.loader:",
|
|
626
|
+
" startup_module = importlib.util.module_from_spec(spec)",
|
|
627
|
+
" spec.loader.exec_module(startup_module)",
|
|
628
|
+
" else:",
|
|
629
|
+
" print('Warning: Could not load startup.py', file=sys.stderr)",
|
|
630
|
+
" ",
|
|
631
|
+
" except Exception as e:",
|
|
632
|
+
" import traceback",
|
|
633
|
+
" print(f'Warning: Startup script execution failed: {e}', file=sys.stderr)",
|
|
634
|
+
" print(traceback.format_exc(), file=sys.stderr)",
|
|
635
|
+
" # Continue server startup despite script failure",
|
|
636
|
+
" ",
|
|
637
|
+
" finally:",
|
|
638
|
+
" # Always restore original environment",
|
|
639
|
+
" try:",
|
|
640
|
+
" os.chdir(original_dir)",
|
|
641
|
+
" sys.path[:] = original_path",
|
|
642
|
+
" except Exception:",
|
|
643
|
+
" # If directory restoration fails, at least fix the path",
|
|
644
|
+
" sys.path[:] = original_path",
|
|
645
|
+
"",
|
|
646
|
+
]
|
|
647
|
+
|
|
584
648
|
def _generate_server(self) -> None:
|
|
585
649
|
"""Generate the main server entry point."""
|
|
586
650
|
server_file = self.output_dir / "server.py"
|
|
@@ -935,6 +999,9 @@ class CodeGenerator:
|
|
|
935
999
|
"",
|
|
936
1000
|
]
|
|
937
1001
|
|
|
1002
|
+
# Generate startup section
|
|
1003
|
+
startup_section = self._generate_startup_section(self.project_path)
|
|
1004
|
+
|
|
938
1005
|
# OpenTelemetry setup code will be handled through imports and lifespan
|
|
939
1006
|
|
|
940
1007
|
# Add auth setup code if auth is configured
|
|
@@ -1145,12 +1212,13 @@ class CodeGenerator:
|
|
|
1145
1212
|
]
|
|
1146
1213
|
|
|
1147
1214
|
# Combine all sections
|
|
1148
|
-
# Order: imports, env_section, auth_setup, server_code (mcp init),
|
|
1215
|
+
# Order: imports, env_section, startup_section, auth_setup, server_code (mcp init),
|
|
1149
1216
|
# early_telemetry_init, early_metrics_init, component_registrations,
|
|
1150
1217
|
# metrics_route_code, health_check_code, main_code (run block)
|
|
1151
1218
|
code = "\n".join(
|
|
1152
1219
|
imports
|
|
1153
1220
|
+ env_section
|
|
1221
|
+
+ startup_section
|
|
1154
1222
|
+ auth_setup_code
|
|
1155
1223
|
+ server_code_lines
|
|
1156
1224
|
+ early_telemetry_init
|
|
@@ -1352,6 +1420,13 @@ def build_project(
|
|
|
1352
1420
|
generator = CodeGenerator(project_path, settings, output_dir, build_env=build_env, copy_env=copy_env)
|
|
1353
1421
|
generator.generate()
|
|
1354
1422
|
|
|
1423
|
+
# Copy startup.py to output directory if it exists (after server generation)
|
|
1424
|
+
startup_path = project_path / "startup.py"
|
|
1425
|
+
if startup_path.exists():
|
|
1426
|
+
dest_path = output_dir / "startup.py"
|
|
1427
|
+
shutil.copy2(startup_path, dest_path)
|
|
1428
|
+
console.print(get_status_text("success", "Startup script copied to build directory"))
|
|
1429
|
+
|
|
1355
1430
|
# Platform registration (only for prod builds)
|
|
1356
1431
|
if build_env == "prod":
|
|
1357
1432
|
console.print()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
golf/__init__.py,sha256=
|
|
1
|
+
golf/__init__.py,sha256=KrLUEDZhh_8Gu_JcwZgGUhFN9JR6Sjqt8v46gVPBsmE,307
|
|
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=
|
|
5
|
+
golf/auth/__init__.py,sha256=gx62l8Z72eIldO2LtzKQ2OQVeobrhaSggTzJaZ0hcCo,8279
|
|
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
|
|
@@ -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
|
|
19
|
+
golf/core/builder.py,sha256=-iUhj1G5SKSE9kG9Y2glxQPp3b45fqXVrYi3gQGmgbs,69963
|
|
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.
|
|
52
|
-
golf_mcp-0.2.
|
|
53
|
-
golf_mcp-0.2.
|
|
54
|
-
golf_mcp-0.2.
|
|
55
|
-
golf_mcp-0.2.
|
|
56
|
-
golf_mcp-0.2.
|
|
51
|
+
golf_mcp-0.2.10.dist-info/licenses/LICENSE,sha256=5_j2f6fTJmvfmUewzElhkpAaXg2grVoxKouOA8ihV6E,11348
|
|
52
|
+
golf_mcp-0.2.10.dist-info/METADATA,sha256=4YRKbcRjyZfBFPFcnzJ5ZV8hU3enJEVmQy2VumwVlpc,9371
|
|
53
|
+
golf_mcp-0.2.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
54
|
+
golf_mcp-0.2.10.dist-info/entry_points.txt,sha256=5y7rHYM8jGpU-nfwdknCm5XsApLulqsnA37MO6BUTYg,43
|
|
55
|
+
golf_mcp-0.2.10.dist-info/top_level.txt,sha256=BQToHcBUufdyhp9ONGMIvPE40jMEtmI20lYaKb4hxOg,5
|
|
56
|
+
golf_mcp-0.2.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|