golf-mcp 0.2.6__py3-none-any.whl → 0.2.7__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/core/builder.py +137 -32
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/METADATA +1 -2
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/RECORD +8 -8
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/WHEEL +0 -0
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/entry_points.txt +0 -0
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {golf_mcp-0.2.6.dist-info → golf_mcp-0.2.7.dist-info}/top_level.txt +0 -0
golf/__init__.py
CHANGED
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
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
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
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
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.
|
|
3
|
+
Version: 0.2.7
|
|
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,4 +1,4 @@
|
|
|
1
|
-
golf/__init__.py,sha256=
|
|
1
|
+
golf/__init__.py,sha256=6vytM_ZxcMhG5rXftdEzDMmvD941REm-UGAitD-fBss,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
|
|
@@ -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=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.
|
|
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.7.dist-info/licenses/LICENSE,sha256=5_j2f6fTJmvfmUewzElhkpAaXg2grVoxKouOA8ihV6E,11348
|
|
52
|
+
golf_mcp-0.2.7.dist-info/METADATA,sha256=5F9gLHC0HqScjtaPXvIWJ30JfX4CSFIkVRvXQYYl5cI,9370
|
|
53
|
+
golf_mcp-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
54
|
+
golf_mcp-0.2.7.dist-info/entry_points.txt,sha256=5y7rHYM8jGpU-nfwdknCm5XsApLulqsnA37MO6BUTYg,43
|
|
55
|
+
golf_mcp-0.2.7.dist-info/top_level.txt,sha256=BQToHcBUufdyhp9ONGMIvPE40jMEtmI20lYaKb4hxOg,5
|
|
56
|
+
golf_mcp-0.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|