fastmcp 2.2.4__py3-none-any.whl → 2.2.6__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.
- fastmcp/__init__.py +1 -0
- fastmcp/client/base.py +0 -1
- fastmcp/client/client.py +12 -8
- fastmcp/client/logging.py +13 -0
- fastmcp/client/sampling.py +2 -0
- fastmcp/client/transports.py +37 -4
- fastmcp/prompts/prompt.py +43 -4
- fastmcp/prompts/prompt_manager.py +14 -3
- fastmcp/resources/resource.py +12 -2
- fastmcp/resources/resource_manager.py +20 -5
- fastmcp/resources/template.py +43 -4
- fastmcp/resources/types.py +55 -11
- fastmcp/server/context.py +15 -13
- fastmcp/server/openapi.py +86 -31
- fastmcp/server/proxy.py +38 -21
- fastmcp/server/server.py +49 -15
- fastmcp/tools/tool.py +22 -6
- {fastmcp-2.2.4.dist-info → fastmcp-2.2.6.dist-info}/METADATA +2 -2
- {fastmcp-2.2.4.dist-info → fastmcp-2.2.6.dist-info}/RECORD +22 -21
- {fastmcp-2.2.4.dist-info → fastmcp-2.2.6.dist-info}/WHEEL +0 -0
- {fastmcp-2.2.4.dist-info → fastmcp-2.2.6.dist-info}/entry_points.txt +0 -0
- {fastmcp-2.2.4.dist-info → fastmcp-2.2.6.dist-info}/licenses/LICENSE +0 -0
fastmcp/tools/tool.py
CHANGED
|
@@ -101,13 +101,16 @@ class Tool(BaseModel):
|
|
|
101
101
|
) -> list[TextContent | ImageContent | EmbeddedResource]:
|
|
102
102
|
"""Run the tool with arguments."""
|
|
103
103
|
try:
|
|
104
|
-
|
|
105
|
-
self.fn,
|
|
106
|
-
self.is_async,
|
|
107
|
-
arguments,
|
|
104
|
+
pass_args = (
|
|
108
105
|
{self.context_kwarg: context}
|
|
109
106
|
if self.context_kwarg is not None
|
|
110
|
-
else None
|
|
107
|
+
else None
|
|
108
|
+
)
|
|
109
|
+
result = await self.fn_metadata.call_fn_with_arg_validation(
|
|
110
|
+
fn=self.fn,
|
|
111
|
+
fn_is_async=self.is_async,
|
|
112
|
+
arguments_to_validate=arguments,
|
|
113
|
+
arguments_to_pass_directly=pass_args,
|
|
111
114
|
)
|
|
112
115
|
return _convert_to_content(result)
|
|
113
116
|
except Exception as e:
|
|
@@ -163,9 +166,22 @@ def _convert_to_content(
|
|
|
163
166
|
|
|
164
167
|
return other_content + mcp_types
|
|
165
168
|
|
|
169
|
+
# if the result is a bytes object, convert it to a text content object
|
|
166
170
|
if not isinstance(result, str):
|
|
167
171
|
try:
|
|
168
|
-
|
|
172
|
+
jsonable_result = pydantic_core.to_jsonable_python(result)
|
|
173
|
+
if jsonable_result is None:
|
|
174
|
+
return [TextContent(type="text", text="null")]
|
|
175
|
+
elif isinstance(jsonable_result, bool):
|
|
176
|
+
return [
|
|
177
|
+
TextContent(
|
|
178
|
+
type="text", text="true" if jsonable_result else "false"
|
|
179
|
+
)
|
|
180
|
+
]
|
|
181
|
+
elif isinstance(jsonable_result, str | int | float):
|
|
182
|
+
return [TextContent(type="text", text=str(jsonable_result))]
|
|
183
|
+
else:
|
|
184
|
+
return [TextContent(type="text", text=json.dumps(jsonable_result))]
|
|
169
185
|
except Exception:
|
|
170
186
|
result = str(result)
|
|
171
187
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.6
|
|
4
4
|
Summary: The fast, Pythonic way to build MCP servers.
|
|
5
5
|
Project-URL: Homepage, https://gofastmcp.com
|
|
6
6
|
Project-URL: Repository, https://github.com/jlowin/fastmcp
|
|
@@ -24,7 +24,7 @@ Requires-Dist: openapi-pydantic>=0.5.1
|
|
|
24
24
|
Requires-Dist: python-dotenv>=1.1.0
|
|
25
25
|
Requires-Dist: rich>=13.9.4
|
|
26
26
|
Requires-Dist: typer>=0.15.2
|
|
27
|
-
Requires-Dist: websockets>=
|
|
27
|
+
Requires-Dist: websockets>=14.0
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
|
|
30
30
|
<div align="center">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
fastmcp/__init__.py,sha256=
|
|
1
|
+
fastmcp/__init__.py,sha256=e-wu5UQpgduOauB-H8lzbnxv_H9K90fCJVnc1qgaAhM,413
|
|
2
2
|
fastmcp/exceptions.py,sha256=QKVHbftoZp4YZQ2NxA-t1SjztqspFdX95YTFOAmr5EE,640
|
|
3
3
|
fastmcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
fastmcp/settings.py,sha256=VCjc-3011pKRYjt2h9rZ68XhVEekbpyLyVUREVBTSrg,1955
|
|
@@ -6,11 +6,12 @@ fastmcp/cli/__init__.py,sha256=Ii284TNoG5lxTP40ETMGhHEq3lQZWxu9m9JuU57kUpQ,87
|
|
|
6
6
|
fastmcp/cli/claude.py,sha256=IAlcZ4qZKBBj09jZUMEx7EANZE_IR3vcu7zOBJmMOuU,4567
|
|
7
7
|
fastmcp/cli/cli.py,sha256=wsFIYTv48_nr0mcW8vjI1l7_thr4cOrRxzo9g-qr2l8,15726
|
|
8
8
|
fastmcp/client/__init__.py,sha256=BXO9NUhntZ5GnUACfaRCzDJ5IzxqFJs8qKG-CRMSco4,490
|
|
9
|
-
fastmcp/client/base.py,sha256=
|
|
10
|
-
fastmcp/client/client.py,sha256=
|
|
9
|
+
fastmcp/client/base.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
fastmcp/client/client.py,sha256=cGVy066XGBtwl4Bwa_Prx-Vy5NMZHrDH8jxiq1oYuBo,7812
|
|
11
|
+
fastmcp/client/logging.py,sha256=Q8jYcZj4KA15Yiz3RP8tBXj8sd9IxL3VThF_Y0O4Upc,356
|
|
11
12
|
fastmcp/client/roots.py,sha256=IxI_bHwHTmg6c2H-s1av1ZgrRnNDieHtYwdGFbzXT5c,2471
|
|
12
|
-
fastmcp/client/sampling.py,sha256=
|
|
13
|
-
fastmcp/client/transports.py,sha256=
|
|
13
|
+
fastmcp/client/sampling.py,sha256=UlDHxnd6k_HoU8RA3ob0g8-e6haJBc9u27N_v291QoI,1698
|
|
14
|
+
fastmcp/client/transports.py,sha256=FMMniyxnaaHyWeFHXXP_ayOpb4jtCoyjaiqLobgYb_M,16885
|
|
14
15
|
fastmcp/contrib/README.md,sha256=rKknYSI1T192UvSszqwwDlQ2eYQpxywrNTLoj177SYU,878
|
|
15
16
|
fastmcp/contrib/bulk_tool_caller/README.md,sha256=5aUUY1TSFKtz1pvTLSDqkUCkGkuqMfMZNsLeaNqEgAc,1960
|
|
16
17
|
fastmcp/contrib/bulk_tool_caller/__init__.py,sha256=xvGSSaUXTQrc31erBoi1Gh7BikgOliETDiYVTP3rLxY,75
|
|
@@ -21,20 +22,20 @@ fastmcp/contrib/mcp_mixin/__init__.py,sha256=aw9IQ1ssNjCgws4ZNt8bkdpossAAGVAwwjB
|
|
|
21
22
|
fastmcp/contrib/mcp_mixin/example.py,sha256=GnunkXmtG5hLLTUsM8aW5ZURU52Z8vI4tNLl-fK7Dg0,1228
|
|
22
23
|
fastmcp/contrib/mcp_mixin/mcp_mixin.py,sha256=cfIRbnSxsVzglTD-auyTE0izVQeHP7Oz18qzYoBZJgg,7899
|
|
23
24
|
fastmcp/prompts/__init__.py,sha256=LtPAv2JKIu54AwUd3iwv-HUd4DPcwgEqy6itEd3BH_E,194
|
|
24
|
-
fastmcp/prompts/prompt.py,sha256=
|
|
25
|
-
fastmcp/prompts/prompt_manager.py,sha256=
|
|
25
|
+
fastmcp/prompts/prompt.py,sha256=xNSlvs-vRB-kz7xnMYf2RwkiilbE0HcOoXgMS6gUogk,7974
|
|
26
|
+
fastmcp/prompts/prompt_manager.py,sha256=4CInlSWASjHUfGu2i0ig2ZICzHHxCMFGTXhuXgYdukQ,3237
|
|
26
27
|
fastmcp/resources/__init__.py,sha256=t0x1j8lc74rjUKtXe9H5Gs4fpQt82K4NgBK6Y7A0xTg,467
|
|
27
|
-
fastmcp/resources/resource.py,sha256=
|
|
28
|
-
fastmcp/resources/resource_manager.py,sha256=
|
|
29
|
-
fastmcp/resources/template.py,sha256=
|
|
30
|
-
fastmcp/resources/types.py,sha256=
|
|
28
|
+
fastmcp/resources/resource.py,sha256=GGG0XugoIMbgAJRMVxsBcZLbt19W3COy8PyTh_uoWjs,2705
|
|
29
|
+
fastmcp/resources/resource_manager.py,sha256=yfQNCEUooZiQ8LNslnAzjQp4Vh-y1YOlFyGEQZ0BtAg,9586
|
|
30
|
+
fastmcp/resources/template.py,sha256=oa85KiuTjh3C7aZvMwmO4fwbTi6IvwlQ3fxizJuv3dk,7261
|
|
31
|
+
fastmcp/resources/types.py,sha256=c1z6BQSosgrlPQ3v67DuXCvDjCJMq9Xl45npEpyk0ik,7710
|
|
31
32
|
fastmcp/server/__init__.py,sha256=pdkghG11VLMZiluQ-4_rl2JK1LMWmV003m9dDRUN8W4,92
|
|
32
|
-
fastmcp/server/context.py,sha256=
|
|
33
|
-
fastmcp/server/openapi.py,sha256=
|
|
34
|
-
fastmcp/server/proxy.py,sha256=
|
|
35
|
-
fastmcp/server/server.py,sha256=
|
|
33
|
+
fastmcp/server/context.py,sha256=_eaL_6QtlQC9yDvHYjntmMzG1aNQZSnli5bIIpCLIwc,7403
|
|
34
|
+
fastmcp/server/openapi.py,sha256=bMmBfgNGzkbweM5g_64NpqvJ6cPtzhSWrzgRvUqP3ec,23185
|
|
35
|
+
fastmcp/server/proxy.py,sha256=pOY6XRvU_GDVv6hd3BttG5W5D1bOtjs9u6iygUMHPsw,10158
|
|
36
|
+
fastmcp/server/server.py,sha256=vQDVo7M8JwltqbprsE7Bd_lTxlnXyrc5jQ4C1uQA1lA,33152
|
|
36
37
|
fastmcp/tools/__init__.py,sha256=ocw-SFTtN6vQ8fgnlF8iNAOflRmh79xS1xdO0Bc3QPE,96
|
|
37
|
-
fastmcp/tools/tool.py,sha256=
|
|
38
|
+
fastmcp/tools/tool.py,sha256=k797XAeXdcUuBfeuvxkEy8xckXi7xSzQVgkzL876rBQ,6755
|
|
38
39
|
fastmcp/tools/tool_manager.py,sha256=hClv7fwj0cQSSwW0i-Swt7xiVqR4T9LVmr1Tp704nW4,3283
|
|
39
40
|
fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
|
|
40
41
|
fastmcp/utilities/decorators.py,sha256=AjhjsetQZF4YOPV5MTZmIxO21iFp_4fDIS3O2_KNCEg,2990
|
|
@@ -42,8 +43,8 @@ fastmcp/utilities/func_metadata.py,sha256=iYXnx7MILOSL8mUQ6Rtq_6U7qA08OkoEN2APY8
|
|
|
42
43
|
fastmcp/utilities/logging.py,sha256=zav8pnFxG_fvGJHUV2XpobmT9WVrmv1mlQBSCz-CPx4,1159
|
|
43
44
|
fastmcp/utilities/openapi.py,sha256=PrH3usbTblaVC6jIH1UGiPEfgB2sSCLj33zA5dH7o_s,45193
|
|
44
45
|
fastmcp/utilities/types.py,sha256=m2rPYMzO-ZFvvZ46N-1-Xqyw693K7yq9Z2xR4pVELyk,2091
|
|
45
|
-
fastmcp-2.2.
|
|
46
|
-
fastmcp-2.2.
|
|
47
|
-
fastmcp-2.2.
|
|
48
|
-
fastmcp-2.2.
|
|
49
|
-
fastmcp-2.2.
|
|
46
|
+
fastmcp-2.2.6.dist-info/METADATA,sha256=gjgxlV6gTth_za73JXr1kzU9LgD9ELMoqAMX1vaaUDY,27767
|
|
47
|
+
fastmcp-2.2.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
48
|
+
fastmcp-2.2.6.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
|
|
49
|
+
fastmcp-2.2.6.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
50
|
+
fastmcp-2.2.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|