fastmcp 2.7.0__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.
@@ -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
@@ -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.settings.client_raise_first_exceptiongroup_error:
46
+ if fastmcp.settings.client_raise_first_exceptiongroup_error:
47
47
  return _catch_handlers
48
48
  else:
49
49
  return {}
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Any, Literal
3
+ from typing import TYPE_CHECKING, Annotated, Any, Literal
4
4
  from urllib.parse import urlparse
5
5
 
6
6
  from pydantic import AnyUrl, Field
@@ -55,7 +55,13 @@ 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", "http"] | None = None
58
+ transport: Literal["streamable-http", "sse"] | None = None
59
+ auth: Annotated[
60
+ str | Literal["oauth"] | None,
61
+ Field(
62
+ description='Either a string representing a Bearer token or the literal "oauth" to use OAuth authentication.'
63
+ ),
64
+ ] = None
59
65
 
60
66
  def to_transport(self) -> StreamableHttpTransport | SSETransport:
61
67
  from fastmcp.client.transports import SSETransport, StreamableHttpTransport
@@ -66,9 +72,11 @@ class RemoteMCPServer(FastMCPBaseModel):
66
72
  transport = self.transport
67
73
 
68
74
  if transport == "sse":
69
- return SSETransport(self.url, headers=self.headers)
75
+ return SSETransport(self.url, headers=self.headers, auth=self.auth)
70
76
  else:
71
- return StreamableHttpTransport(self.url, headers=self.headers)
77
+ return StreamableHttpTransport(
78
+ self.url, headers=self.headers, auth=self.auth
79
+ )
72
80
 
73
81
 
74
82
  class MCPConfig(FastMCPBaseModel):
@@ -10,7 +10,7 @@ from typing import TYPE_CHECKING, Any, Literal
10
10
 
11
11
  import uvicorn
12
12
 
13
- from fastmcp.settings import settings
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.settings.log_level == 'DEBUG'
36
- assert fastmcp.settings.settings.log_level == 'INFO'
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())
@@ -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.7.0
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
  [![Docs](https://img.shields.io/badge/docs-gofastmcp.com-blue)](https://gofastmcp.com)
39
41
  [![PyPI - Version](https://img.shields.io/pypi/v/fastmcp.svg)](https://pypi.org/project/fastmcp)
40
42
  [![Tests](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jlowin/fastmcp/actions/workflows/run-tests.yml)
@@ -1,22 +1,22 @@
1
- fastmcp/__init__.py,sha256=yTAqLZORsPqbr7AE0ayw6zIYBeMlxQlI-3HE2WqbvHk,435
2
- fastmcp/exceptions.py,sha256=YvaKqOT3w0boXF9ylIoaSIzW9XiQ1qLFG1LZq6B60H8,680
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=DbFdWx4EVHhJZF6e2GB0pBMCSjc425kXIVY8mqfOVX8,6175
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=zoHJ8DjUBLISVb4VHaVP-fCJP4Y8zG6-UhhNqSvczqY,12667
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=vQk0l6htoD6CyO0le8q23iYd5hX1l8NIbxchedbWqgE,24872
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=Pi4g2B9lKbgvey-7lTLkjsSVxE2DoT2yMq82D7xktK0,32091
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=LJHCB-34EC-sL9GC97XFQkyanK8Cc5skAp6GkH0tKzE,14709
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=FMvDO3491LJkdPSorKKwr_2KtDJx_C54iYDbGtBzH5M,9474
31
- fastmcp/prompts/prompt_manager.py,sha256=zAxlMzNHt8z5tD6lHl60aETvCBq6FNfE_1I4p5juKRE,4161
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=pvyeuUJvBGyudvxEKiBsof8B5X1EfYpCNwC4wO3-rZA,5139
34
- fastmcp/resources/resource_manager.py,sha256=AZO05oYJ6DmFst7hWedT6Jx7WfhISodw4K-HdQpY5iI,11761
35
- fastmcp/resources/template.py,sha256=EDoPOMFRwCNHugEtmlcuTuWx2O1qe5_nUOLrGNYvsXM,8749
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
- fastmcp/server/dependencies.py,sha256=DfN40fz4UkmdzvVg3QesuHKUVJ07iQU5ookkWawAoH4,2336
40
- fastmcp/server/http.py,sha256=RbUnqqKsiThOGZwJH-BIzC5_V1EXQh9tBlN4S-JJhbY,11624
41
- fastmcp/server/openapi.py,sha256=heLQA3B57nCOLNsbOYLVFbZGI8XQaVeXL6ST5L55vuo,38596
42
- fastmcp/server/proxy.py,sha256=EVup0L4gGMnxkG2SJHE09ugKvfhPyJ_3AnkhAS-Dc3E,9562
43
- fastmcp/server/server.py,sha256=pupGTlXcbindBILxYQoFYqQomQcDMK5QS04vTngYIdk,65399
39
+ fastmcp/server/dependencies.py,sha256=iKJdz1XsVJcrfHo_reXj9ZSldw-HeAwsp9S6lAgfGA8,2358
40
+ fastmcp/server/http.py,sha256=2v4_N9piolv4z8Nbkn8K0TtHOZzs683mUNA81uGdDdY,11687
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=MXsr4rjRm8DDmbdNd7IEXT6naCq48fkC1LlpoFAjt7c,1971
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=G-XFAr0RhVFj_crAZFaWZDUqcBPCTCyzAndpKXtpIFc,126
51
- fastmcp/tools/tool.py,sha256=J5VDyQE85IyZPXEq8x0n1V2qdNJ5zVlgB7FkzxJwW9E,9994
52
- fastmcp/tools/tool_manager.py,sha256=C3mB0lgQU-vmcrUltqck-Yx7zrnIHXthHijS-dJliU8,4724
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/exceptions.py,sha256=Aax9K0larjzrrgJBS6o_PQwoIrvBvVwck2suZvgafXE,1359
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=Htux1dKyDaeK6-gT_fZwpJ_yj0MxUjGfPFAY3Dnnxsk,2233
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=4Vuua6nVgbE5uQspEK0fk4tBuJ0rO4GTBmnyD0kXJPA,3930
62
- fastmcp/utilities/types.py,sha256=HX1y4JrDC3sZA2ENRqsyxMyLQepr5-JiS9StXhIX8TE,4548
63
- fastmcp-2.7.0.dist-info/METADATA,sha256=kXjE9Y1-qt0-OP2PVR2b1Gjdp6QKb68olWBNxM5xQmc,17687
64
- fastmcp-2.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
65
- fastmcp-2.7.0.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
66
- fastmcp-2.7.0.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
67
- fastmcp-2.7.0.dist-info/RECORD,,
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,,