fastmcp 2.7.1__py3-none-any.whl → 2.8.0__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 +4 -1
- fastmcp/cli/cli.py +3 -2
- fastmcp/client/auth/oauth.py +1 -1
- fastmcp/client/client.py +3 -1
- fastmcp/client/transports.py +35 -28
- fastmcp/exceptions.py +4 -0
- fastmcp/prompts/prompt.py +8 -18
- fastmcp/prompts/prompt_manager.py +7 -4
- fastmcp/resources/resource.py +21 -26
- fastmcp/resources/resource_manager.py +3 -2
- fastmcp/resources/template.py +8 -16
- fastmcp/server/auth/providers/bearer_env.py +8 -11
- fastmcp/server/openapi.py +65 -38
- fastmcp/server/proxy.py +27 -14
- fastmcp/server/server.py +320 -131
- fastmcp/settings.py +100 -37
- fastmcp/tools/__init__.py +2 -1
- fastmcp/tools/tool.py +114 -75
- fastmcp/tools/tool_manager.py +3 -2
- fastmcp/tools/tool_transform.py +665 -0
- fastmcp/utilities/components.py +55 -0
- fastmcp/utilities/exceptions.py +1 -1
- fastmcp/utilities/mcp_config.py +1 -1
- fastmcp/utilities/tests.py +3 -3
- fastmcp/utilities/types.py +0 -9
- {fastmcp-2.7.1.dist-info → fastmcp-2.8.0.dist-info}/METADATA +3 -1
- {fastmcp-2.7.1.dist-info → fastmcp-2.8.0.dist-info}/RECORD +30 -28
- {fastmcp-2.7.1.dist-info → fastmcp-2.8.0.dist-info}/WHEEL +0 -0
- {fastmcp-2.7.1.dist-info → fastmcp-2.8.0.dist-info}/entry_points.txt +0 -0
- {fastmcp-2.7.1.dist-info → fastmcp-2.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from typing import Annotated, TypeVar
|
|
3
|
+
|
|
4
|
+
from pydantic import BeforeValidator, Field
|
|
5
|
+
|
|
6
|
+
from fastmcp.utilities.types import FastMCPBaseModel
|
|
7
|
+
|
|
8
|
+
T = TypeVar("T")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _convert_set_default_none(maybe_set: set[T] | Sequence[T] | None) -> set[T]:
|
|
12
|
+
"""Convert a sequence to a set, defaulting to an empty set if None."""
|
|
13
|
+
if maybe_set is None:
|
|
14
|
+
return set()
|
|
15
|
+
if isinstance(maybe_set, set):
|
|
16
|
+
return maybe_set
|
|
17
|
+
return set(maybe_set)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class FastMCPComponent(FastMCPBaseModel):
|
|
21
|
+
"""Base class for FastMCP tools, prompts, resources, and resource templates."""
|
|
22
|
+
|
|
23
|
+
name: str = Field(
|
|
24
|
+
description="The name of the component.",
|
|
25
|
+
)
|
|
26
|
+
description: str | None = Field(
|
|
27
|
+
default=None,
|
|
28
|
+
description="The description of the component.",
|
|
29
|
+
)
|
|
30
|
+
tags: Annotated[set[str], BeforeValidator(_convert_set_default_none)] = Field(
|
|
31
|
+
default_factory=set,
|
|
32
|
+
description="Tags for the component.",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
enabled: bool = Field(
|
|
36
|
+
default=True,
|
|
37
|
+
description="Whether the component is enabled.",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def __eq__(self, other: object) -> bool:
|
|
41
|
+
if type(self) is not type(other):
|
|
42
|
+
return False
|
|
43
|
+
assert isinstance(other, type(self))
|
|
44
|
+
return self.model_dump() == other.model_dump()
|
|
45
|
+
|
|
46
|
+
def __repr__(self) -> str:
|
|
47
|
+
return f"{self.__class__.__name__}(name={self.name!r}, description={self.description!r}, tags={self.tags}, enabled={self.enabled})"
|
|
48
|
+
|
|
49
|
+
def enable(self) -> None:
|
|
50
|
+
"""Enable the component."""
|
|
51
|
+
self.enabled = True
|
|
52
|
+
|
|
53
|
+
def disable(self) -> None:
|
|
54
|
+
"""Disable the component."""
|
|
55
|
+
self.enabled = False
|
fastmcp/utilities/exceptions.py
CHANGED
|
@@ -43,7 +43,7 @@ def get_catch_handlers() -> Mapping[
|
|
|
43
43
|
type[BaseException] | Iterable[type[BaseException]],
|
|
44
44
|
Callable[[BaseExceptionGroup[Any]], Any],
|
|
45
45
|
]:
|
|
46
|
-
if fastmcp.settings.
|
|
46
|
+
if fastmcp.settings.client_raise_first_exceptiongroup_error:
|
|
47
47
|
return _catch_handlers
|
|
48
48
|
else:
|
|
49
49
|
return {}
|
fastmcp/utilities/mcp_config.py
CHANGED
|
@@ -55,7 +55,7 @@ class StdioMCPServer(FastMCPBaseModel):
|
|
|
55
55
|
class RemoteMCPServer(FastMCPBaseModel):
|
|
56
56
|
url: str
|
|
57
57
|
headers: dict[str, str] = Field(default_factory=dict)
|
|
58
|
-
transport: Literal["streamable-http", "sse"
|
|
58
|
+
transport: Literal["streamable-http", "sse"] | None = None
|
|
59
59
|
auth: Annotated[
|
|
60
60
|
str | Literal["oauth"] | None,
|
|
61
61
|
Field(
|
fastmcp/utilities/tests.py
CHANGED
|
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any, Literal
|
|
|
10
10
|
|
|
11
11
|
import uvicorn
|
|
12
12
|
|
|
13
|
-
from fastmcp
|
|
13
|
+
from fastmcp import settings
|
|
14
14
|
from fastmcp.utilities.http import find_available_port
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
@@ -32,8 +32,8 @@ def temporary_settings(**kwargs: Any):
|
|
|
32
32
|
from fastmcp.utilities.tests import temporary_settings
|
|
33
33
|
|
|
34
34
|
with temporary_settings(log_level='DEBUG'):
|
|
35
|
-
assert fastmcp.settings.
|
|
36
|
-
assert fastmcp.settings.
|
|
35
|
+
assert fastmcp.settings.log_level == 'DEBUG'
|
|
36
|
+
assert fastmcp.settings.log_level == 'INFO'
|
|
37
37
|
```
|
|
38
38
|
"""
|
|
39
39
|
old_settings = copy.deepcopy(settings.model_dump())
|
fastmcp/utilities/types.py
CHANGED
|
@@ -80,15 +80,6 @@ def find_kwarg_by_type(fn: Callable, kwarg_type: type) -> str | None:
|
|
|
80
80
|
return None
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
def _convert_set_defaults(maybe_set: set[T] | list[T] | None) -> set[T]:
|
|
84
|
-
"""Convert a set or list to a set, defaulting to an empty set if None."""
|
|
85
|
-
if maybe_set is None:
|
|
86
|
-
return set()
|
|
87
|
-
if isinstance(maybe_set, set):
|
|
88
|
-
return maybe_set
|
|
89
|
-
return set(maybe_set)
|
|
90
|
-
|
|
91
|
-
|
|
92
83
|
class Image:
|
|
93
84
|
"""Helper class for returning images from tools."""
|
|
94
85
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
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
|
|
@@ -35,6 +35,8 @@ Description-Content-Type: text/markdown
|
|
|
35
35
|
# FastMCP v2 🚀
|
|
36
36
|
<strong>The fast, Pythonic way to build MCP servers and clients.</strong>
|
|
37
37
|
|
|
38
|
+
*FastMCP is made with 💙 by [Prefect](https://www.prefect.io/)*
|
|
39
|
+
|
|
38
40
|
[](https://gofastmcp.com)
|
|
39
41
|
[](https://pypi.org/project/fastmcp)
|
|
40
42
|
[](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
fastmcp/__init__.py,sha256=
|
|
2
|
-
fastmcp/exceptions.py,sha256
|
|
1
|
+
fastmcp/__init__.py,sha256=ihcFxrKjXfRor78fpuR9aUwFAK0rN9d-BBAlNXldacw,486
|
|
2
|
+
fastmcp/exceptions.py,sha256=-krEavxwddQau6T7MESCR4VjKNLfP9KHJrU1p3y72FU,744
|
|
3
3
|
fastmcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
fastmcp/settings.py,sha256=
|
|
4
|
+
fastmcp/settings.py,sha256=xJnbeE7hRLxpMbrr8ManYuuHFh3xECNyFjk4t4doGG0,8629
|
|
5
5
|
fastmcp/cli/__init__.py,sha256=Ii284TNoG5lxTP40ETMGhHEq3lQZWxu9m9JuU57kUpQ,87
|
|
6
6
|
fastmcp/cli/claude.py,sha256=IAlcZ4qZKBBj09jZUMEx7EANZE_IR3vcu7zOBJmMOuU,4567
|
|
7
|
-
fastmcp/cli/cli.py,sha256=
|
|
7
|
+
fastmcp/cli/cli.py,sha256=NQ_byPYUhJ8zyMW6VV2JlUlBH8xwB4tRejLK7n-yypc,12681
|
|
8
8
|
fastmcp/cli/run.py,sha256=sGH7M3Yi8HGju4sPypKGk3P2cdZq1n3l-_CpJmdGvDc,6277
|
|
9
9
|
fastmcp/client/__init__.py,sha256=kd2hhSuD8rZuF87c9zlPJP_icJ-Rx3exyNoK0EzfOtE,617
|
|
10
|
-
fastmcp/client/client.py,sha256=
|
|
10
|
+
fastmcp/client/client.py,sha256=Bq3Mncxj7dWjcKeDSez-lOF2h7Y9cGaSqZPb3Rkd7jI,24964
|
|
11
11
|
fastmcp/client/logging.py,sha256=hOPRailZUp89RUck6V4HPaWVZinVrNY8HD4hD0dd-fE,822
|
|
12
12
|
fastmcp/client/oauth_callback.py,sha256=ODAnVX-ettL82RuI5KpfkKf8iDtYMDue3Tnab5sjQtM,10071
|
|
13
13
|
fastmcp/client/progress.py,sha256=WjLLDbUKMsx8DK-fqO7AGsXb83ak-6BMrLvzzznGmcI,1043
|
|
14
14
|
fastmcp/client/roots.py,sha256=IxI_bHwHTmg6c2H-s1av1ZgrRnNDieHtYwdGFbzXT5c,2471
|
|
15
15
|
fastmcp/client/sampling.py,sha256=UlDHxnd6k_HoU8RA3ob0g8-e6haJBc9u27N_v291QoI,1698
|
|
16
|
-
fastmcp/client/transports.py,sha256=
|
|
16
|
+
fastmcp/client/transports.py,sha256=2h4Jhm60--uycQbz680jEya-3xAvEg-9d3yFalDpNDo,32845
|
|
17
17
|
fastmcp/client/auth/__init__.py,sha256=4DNsfp4iaQeBcpds0JDdMn6Mmfud44stWLsret0sVKY,91
|
|
18
18
|
fastmcp/client/auth/bearer.py,sha256=MFEFqcH6u_V86msYiOsEFKN5ks1V9BnBNiPsPLHUTqo,399
|
|
19
|
-
fastmcp/client/auth/oauth.py,sha256=
|
|
19
|
+
fastmcp/client/auth/oauth.py,sha256=xiwLftGkadRNsB5eNPl7JtjOI936qgVjsogvOzoxdO0,14700
|
|
20
20
|
fastmcp/contrib/README.md,sha256=rKknYSI1T192UvSszqwwDlQ2eYQpxywrNTLoj177SYU,878
|
|
21
21
|
fastmcp/contrib/bulk_tool_caller/README.md,sha256=5aUUY1TSFKtz1pvTLSDqkUCkGkuqMfMZNsLeaNqEgAc,1960
|
|
22
22
|
fastmcp/contrib/bulk_tool_caller/__init__.py,sha256=xvGSSaUXTQrc31erBoi1Gh7BikgOliETDiYVTP3rLxY,75
|
|
@@ -27,41 +27,43 @@ fastmcp/contrib/mcp_mixin/__init__.py,sha256=aw9IQ1ssNjCgws4ZNt8bkdpossAAGVAwwjB
|
|
|
27
27
|
fastmcp/contrib/mcp_mixin/example.py,sha256=GnunkXmtG5hLLTUsM8aW5ZURU52Z8vI4tNLl-fK7Dg0,1228
|
|
28
28
|
fastmcp/contrib/mcp_mixin/mcp_mixin.py,sha256=3e0wHlKI9OF12t-SbpRTL-TWjBBLw7T8ATjCdoDtX6k,8173
|
|
29
29
|
fastmcp/prompts/__init__.py,sha256=An8uMBUh9Hrb7qqcn_5_Hent7IOeSh7EA2IUVsIrtHc,179
|
|
30
|
-
fastmcp/prompts/prompt.py,sha256=
|
|
31
|
-
fastmcp/prompts/prompt_manager.py,sha256=
|
|
30
|
+
fastmcp/prompts/prompt.py,sha256=8Iv16SUHoCFKfZLhb8itjU3qpMnAaek0nTECjEIFaCI,9122
|
|
31
|
+
fastmcp/prompts/prompt_manager.py,sha256=uZUJI8V5avQv_Bq2NcvXM2hymFDXyHkDfAKOdtHXasg,4307
|
|
32
32
|
fastmcp/resources/__init__.py,sha256=y1iAuqx-GIrS1NqIYzKezIDiYyjNEzzHD35epHpMnXE,463
|
|
33
|
-
fastmcp/resources/resource.py,sha256=
|
|
34
|
-
fastmcp/resources/resource_manager.py,sha256=
|
|
35
|
-
fastmcp/resources/template.py,sha256=
|
|
33
|
+
fastmcp/resources/resource.py,sha256=CY7clkTrF1_3z1yT2HvkA7tGSX9uY0iyZ2AVAXreCCE,4980
|
|
34
|
+
fastmcp/resources/resource_manager.py,sha256=M8R25SWHjzY6zYekgwnajeE8uGe4TYx1LfUJlWt9XjA,11827
|
|
35
|
+
fastmcp/resources/template.py,sha256=ohbjlgMzkhVjmjhqa1Bkh5jzj6oWOHKwRxcneYZDt1Q,8415
|
|
36
36
|
fastmcp/resources/types.py,sha256=SiYNLnpXT-mHgNUrzqKUvXYUsY-V3gwJIrYdJfFwDDo,4868
|
|
37
37
|
fastmcp/server/__init__.py,sha256=bMD4aQD4yJqLz7-mudoNsyeV8UgQfRAg3PRwPvwTEds,119
|
|
38
38
|
fastmcp/server/context.py,sha256=7r-gxMiCgDpd9AStTk0hwfme540H7S1dEcU0bjoerxU,10169
|
|
39
39
|
fastmcp/server/dependencies.py,sha256=iKJdz1XsVJcrfHo_reXj9ZSldw-HeAwsp9S6lAgfGA8,2358
|
|
40
40
|
fastmcp/server/http.py,sha256=2v4_N9piolv4z8Nbkn8K0TtHOZzs683mUNA81uGdDdY,11687
|
|
41
|
-
fastmcp/server/openapi.py,sha256=
|
|
42
|
-
fastmcp/server/proxy.py,sha256=
|
|
43
|
-
fastmcp/server/server.py,sha256=
|
|
41
|
+
fastmcp/server/openapi.py,sha256=ct2hTxhFzwtohmuO1iycZBhQ9iHmsQb3zcj8zF5fjIY,39329
|
|
42
|
+
fastmcp/server/proxy.py,sha256=1IoQ4Yx7P7Z7blNsianM1ZwNW_TcIegRwdkqUx_pdl4,10124
|
|
43
|
+
fastmcp/server/server.py,sha256=3tprt4gjRKj5WRhlZCzPL9pEOUxOiH4BYEXq4nVSmiM,72390
|
|
44
44
|
fastmcp/server/auth/__init__.py,sha256=doHCLwOIElvH1NrTdpeP9JKfnNf3MDYPSpQfdsQ-uI0,84
|
|
45
45
|
fastmcp/server/auth/auth.py,sha256=kz02HGwXYU0N0clURZDjFNWdKSpTYmgmCnGJN-jSG3Y,1640
|
|
46
46
|
fastmcp/server/auth/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
47
|
fastmcp/server/auth/providers/bearer.py,sha256=3pTKL3tEU7FlCD5yI81LTa2n0dBsM7GRpIIn30WCWsA,12679
|
|
48
|
-
fastmcp/server/auth/providers/bearer_env.py,sha256=
|
|
48
|
+
fastmcp/server/auth/providers/bearer_env.py,sha256=zHbJmzT6RhEW9tGG-_aRACQ_t0GwXCvKEAnKQLCO9mY,1892
|
|
49
49
|
fastmcp/server/auth/providers/in_memory.py,sha256=sCRJambxXFZLg_EbJ5ma-aUZvtxuuKbGy7lTxIbzVb0,13772
|
|
50
|
-
fastmcp/tools/__init__.py,sha256=
|
|
51
|
-
fastmcp/tools/tool.py,sha256=
|
|
52
|
-
fastmcp/tools/tool_manager.py,sha256=
|
|
50
|
+
fastmcp/tools/__init__.py,sha256=vzqb-Y7Kf0d5T0aOsld-O-FA8kD7-4uFExChewFHEzY,201
|
|
51
|
+
fastmcp/tools/tool.py,sha256=b9OuZne-iJC6217n9Vj6cWlLwwjy0UYLljpTmtRoZng,11243
|
|
52
|
+
fastmcp/tools/tool_manager.py,sha256=Kj7YMaf_t_hKhr5CgthF9takB5AdS7bkG5Z8EPgL5Lo,4790
|
|
53
|
+
fastmcp/tools/tool_transform.py,sha256=HkBl2xQFHGmYFgI6GHi2XflDgD6ypAa6FpVfxeOeIGs,27441
|
|
53
54
|
fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
|
|
54
55
|
fastmcp/utilities/cache.py,sha256=aV3oZ-ZhMgLSM9iAotlUlEy5jFvGXrVo0Y5Bj4PBtqY,707
|
|
55
|
-
fastmcp/utilities/
|
|
56
|
+
fastmcp/utilities/components.py,sha256=NJXop6vn42DC2MyLtJRuJ7QEyac4T5WcOsYaClIog6E,1669
|
|
57
|
+
fastmcp/utilities/exceptions.py,sha256=7Z9j5IzM5rT27BC1Mcn8tkS-bjqCYqMKwb2MMTaxJYU,1350
|
|
56
58
|
fastmcp/utilities/http.py,sha256=1ns1ymBS-WSxbZjGP6JYjSO52Wa_ls4j4WbnXiupoa4,245
|
|
57
59
|
fastmcp/utilities/json_schema.py,sha256=m65XU9lPq7pCxJ9vvCeGRl0HOFr6ArezvYpMBR6-gAg,3777
|
|
58
60
|
fastmcp/utilities/logging.py,sha256=B1WNO-ZWFjd9wiFSh13YtW1hAKaNmbpscDZleIAhr-g,1317
|
|
59
|
-
fastmcp/utilities/mcp_config.py,sha256=
|
|
61
|
+
fastmcp/utilities/mcp_config.py,sha256=kbmvpF5YE7eiDH68XObagFGPKw26SwuDchmH7pyFSD4,2519
|
|
60
62
|
fastmcp/utilities/openapi.py,sha256=ctceiGb4jYgzZGSseMb-yZccEEXf41P-dhB3ae9lGdk,38992
|
|
61
|
-
fastmcp/utilities/tests.py,sha256=
|
|
62
|
-
fastmcp/utilities/types.py,sha256=
|
|
63
|
-
fastmcp-2.
|
|
64
|
-
fastmcp-2.
|
|
65
|
-
fastmcp-2.
|
|
66
|
-
fastmcp-2.
|
|
67
|
-
fastmcp-2.
|
|
63
|
+
fastmcp/utilities/tests.py,sha256=72ryn-IyrvE9BKL_RPJ6T__qTcSRp8yzhOQSM6cdYpE,3903
|
|
64
|
+
fastmcp/utilities/types.py,sha256=ZRCgFlCDMwbSxi6aYmlu5WN2nNS3jfjleLQnvHGUzzw,4262
|
|
65
|
+
fastmcp-2.8.0.dist-info/METADATA,sha256=nGUf6asW4pGz2IjHG3iYmURX3ETy5F0wVBq9z4Sykqg,17754
|
|
66
|
+
fastmcp-2.8.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
67
|
+
fastmcp-2.8.0.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
|
|
68
|
+
fastmcp-2.8.0.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
69
|
+
fastmcp-2.8.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|