fastmcp 2.6.0__py3-none-any.whl → 2.7.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/cli/cli.py +9 -1
- fastmcp/cli/run.py +32 -1
- fastmcp/client/auth/oauth.py +0 -3
- fastmcp/client/transports.py +13 -4
- fastmcp/contrib/bulk_tool_caller/example.py +1 -1
- fastmcp/contrib/mcp_mixin/mcp_mixin.py +10 -3
- fastmcp/prompts/prompt.py +65 -27
- fastmcp/prompts/prompt_manager.py +13 -6
- fastmcp/py.typed +0 -0
- fastmcp/resources/__init__.py +1 -2
- fastmcp/resources/resource.py +90 -4
- fastmcp/resources/resource_manager.py +17 -6
- fastmcp/resources/template.py +90 -56
- fastmcp/resources/types.py +0 -44
- fastmcp/server/auth/providers/in_memory.py +1 -6
- fastmcp/server/context.py +1 -1
- fastmcp/server/openapi.py +17 -32
- fastmcp/server/proxy.py +5 -8
- fastmcp/server/server.py +274 -100
- fastmcp/tools/__init__.py +2 -2
- fastmcp/tools/tool.py +59 -19
- fastmcp/tools/tool_manager.py +9 -3
- fastmcp/utilities/mcp_config.py +6 -4
- fastmcp/utilities/openapi.py +56 -32
- fastmcp/utilities/types.py +7 -1
- {fastmcp-2.6.0.dist-info → fastmcp-2.7.0.dist-info}/METADATA +29 -17
- {fastmcp-2.6.0.dist-info → fastmcp-2.7.0.dist-info}/RECORD +30 -30
- fastmcp/utilities/decorators.py +0 -101
- {fastmcp-2.6.0.dist-info → fastmcp-2.7.0.dist-info}/WHEEL +0 -0
- {fastmcp-2.6.0.dist-info → fastmcp-2.7.0.dist-info}/entry_points.txt +0 -0
- {fastmcp-2.6.0.dist-info → fastmcp-2.7.0.dist-info}/licenses/LICENSE +0 -0
fastmcp/utilities/decorators.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import inspect
|
|
2
|
-
from collections.abc import Callable
|
|
3
|
-
from typing import Generic, ParamSpec, TypeVar, cast, overload
|
|
4
|
-
|
|
5
|
-
from typing_extensions import Self
|
|
6
|
-
|
|
7
|
-
R = TypeVar("R")
|
|
8
|
-
P = ParamSpec("P")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class DecoratedFunction(Generic[P, R]):
|
|
12
|
-
"""Descriptor for decorated functions.
|
|
13
|
-
|
|
14
|
-
You can return this object from a decorator to ensure that it works across
|
|
15
|
-
all types of functions: vanilla, instance methods, class methods, and static
|
|
16
|
-
methods; both synchronous and asynchronous.
|
|
17
|
-
|
|
18
|
-
This class is used to store the original function and metadata about how to
|
|
19
|
-
register it as a tool.
|
|
20
|
-
|
|
21
|
-
Example usage:
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
def my_decorator(fn: Callable[P, R]) -> DecoratedFunction[P, R]:
|
|
25
|
-
return DecoratedFunction(fn)
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
On a function:
|
|
29
|
-
```python
|
|
30
|
-
@my_decorator
|
|
31
|
-
def my_function(a: int, b: int) -> int:
|
|
32
|
-
return a + b
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
On an instance method:
|
|
36
|
-
```python
|
|
37
|
-
class Test:
|
|
38
|
-
@my_decorator
|
|
39
|
-
def my_function(self, a: int, b: int) -> int:
|
|
40
|
-
return a + b
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
On a class method:
|
|
44
|
-
```python
|
|
45
|
-
class Test:
|
|
46
|
-
@classmethod
|
|
47
|
-
@my_decorator
|
|
48
|
-
def my_function(cls, a: int, b: int) -> int:
|
|
49
|
-
return a + b
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Note that for classmethods, the decorator must be applied first, then
|
|
53
|
-
`@classmethod` on top.
|
|
54
|
-
|
|
55
|
-
On a static method:
|
|
56
|
-
```python
|
|
57
|
-
class Test:
|
|
58
|
-
@staticmethod
|
|
59
|
-
@my_decorator
|
|
60
|
-
def my_function(a: int, b: int) -> int:
|
|
61
|
-
return a + b
|
|
62
|
-
```
|
|
63
|
-
"""
|
|
64
|
-
|
|
65
|
-
def __init__(self, fn: Callable[P, R]):
|
|
66
|
-
self.fn = fn
|
|
67
|
-
|
|
68
|
-
def __call__(self, *args: P.args, **kwargs: P.kwargs) -> R:
|
|
69
|
-
"""Call the original function."""
|
|
70
|
-
try:
|
|
71
|
-
return self.fn(*args, **kwargs)
|
|
72
|
-
except TypeError as e:
|
|
73
|
-
if "'classmethod' object is not callable" in str(e):
|
|
74
|
-
raise TypeError(
|
|
75
|
-
"To apply this decorator to a classmethod, apply the decorator first, then @classmethod on top."
|
|
76
|
-
)
|
|
77
|
-
raise
|
|
78
|
-
|
|
79
|
-
@overload
|
|
80
|
-
def __get__(self, instance: None, owner: type | None = None) -> Self: ...
|
|
81
|
-
|
|
82
|
-
@overload
|
|
83
|
-
def __get__(
|
|
84
|
-
self, instance: object, owner: type | None = None
|
|
85
|
-
) -> Callable[P, R]: ...
|
|
86
|
-
|
|
87
|
-
def __get__(
|
|
88
|
-
self, instance: object | None, owner: type | None = None
|
|
89
|
-
) -> Self | Callable[P, R]:
|
|
90
|
-
"""Return the original function when accessed from an instance, or self when accessed from the class."""
|
|
91
|
-
if instance is None:
|
|
92
|
-
return self
|
|
93
|
-
# Return the original function bound to the instance
|
|
94
|
-
return cast(Callable[P, R], self.fn.__get__(instance, owner))
|
|
95
|
-
|
|
96
|
-
def __repr__(self) -> str:
|
|
97
|
-
"""Return a representation that matches Python's function representation."""
|
|
98
|
-
module = getattr(self.fn, "__module__", "unknown")
|
|
99
|
-
qualname = getattr(self.fn, "__qualname__", str(self.fn))
|
|
100
|
-
sig_str = str(inspect.signature(self.fn))
|
|
101
|
-
return f"<function {module}.{qualname}{sig_str}>"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|