fastmcp 2.2.2__py3-none-any.whl → 2.2.3__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/resources/template.py +5 -2
- fastmcp/tools/tool.py +6 -1
- {fastmcp-2.2.2.dist-info → fastmcp-2.2.3.dist-info}/METADATA +19 -19
- {fastmcp-2.2.2.dist-info → fastmcp-2.2.3.dist-info}/RECORD +7 -7
- {fastmcp-2.2.2.dist-info → fastmcp-2.2.3.dist-info}/WHEEL +0 -0
- {fastmcp-2.2.2.dist-info → fastmcp-2.2.3.dist-info}/entry_points.txt +0 -0
- {fastmcp-2.2.2.dist-info → fastmcp-2.2.3.dist-info}/licenses/LICENSE +0 -0
fastmcp/resources/template.py
CHANGED
|
@@ -24,13 +24,16 @@ from fastmcp.utilities.types import _convert_set_defaults
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def build_regex(template: str) -> re.Pattern:
|
|
27
|
-
# Escape all non-brace characters, then restore {var} placeholders
|
|
28
27
|
parts = re.split(r"(\{[^}]+\})", template)
|
|
29
28
|
pattern = ""
|
|
30
29
|
for part in parts:
|
|
31
30
|
if part.startswith("{") and part.endswith("}"):
|
|
32
31
|
name = part[1:-1]
|
|
33
|
-
|
|
32
|
+
if name.endswith("*"):
|
|
33
|
+
name = name[:-1]
|
|
34
|
+
pattern += f"(?P<{name}>.+)"
|
|
35
|
+
else:
|
|
36
|
+
pattern += f"(?P<{name}>[^/]+)"
|
|
34
37
|
else:
|
|
35
38
|
pattern += re.escape(part)
|
|
36
39
|
return re.compile(f"^{pattern}$")
|
fastmcp/tools/tool.py
CHANGED
|
@@ -76,7 +76,12 @@ class Tool(BaseModel):
|
|
|
76
76
|
fn_callable,
|
|
77
77
|
skip_names=[context_kwarg] if context_kwarg is not None else [],
|
|
78
78
|
)
|
|
79
|
-
|
|
79
|
+
try:
|
|
80
|
+
parameters = func_arg_metadata.arg_model.model_json_schema()
|
|
81
|
+
except Exception as e:
|
|
82
|
+
raise TypeError(
|
|
83
|
+
f'Unable to parse parameters for function "{fn.__name__}": {e}'
|
|
84
|
+
) from e
|
|
80
85
|
|
|
81
86
|
return cls(
|
|
82
87
|
fn=fn_callable,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fastmcp
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.3
|
|
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
|
|
@@ -361,32 +361,32 @@ The `Context` object provides:
|
|
|
361
361
|
|
|
362
362
|
### Images
|
|
363
363
|
|
|
364
|
-
Easily handle image
|
|
364
|
+
Easily handle image outputs using the `fastmcp.Image` helper class.
|
|
365
|
+
|
|
366
|
+
<Tip>
|
|
367
|
+
The below code requires the `pillow` library to be installed.
|
|
368
|
+
</Tip>
|
|
365
369
|
|
|
366
370
|
```python
|
|
367
|
-
from fastmcp import FastMCP, Image
|
|
368
|
-
from
|
|
369
|
-
|
|
371
|
+
from mcp.server.fastmcp import FastMCP, Image
|
|
372
|
+
from io import BytesIO
|
|
373
|
+
try:
|
|
374
|
+
from PIL import Image as PILImage
|
|
375
|
+
except ImportError:
|
|
376
|
+
raise ImportError("Please install the `pillow` library to run this example.")
|
|
370
377
|
|
|
371
|
-
mcp = FastMCP("
|
|
378
|
+
mcp = FastMCP("My App")
|
|
372
379
|
|
|
373
380
|
@mcp.tool()
|
|
374
|
-
def create_thumbnail(
|
|
375
|
-
"""
|
|
376
|
-
img = PILImage.open(
|
|
377
|
-
img.thumbnail((100, 100))
|
|
378
|
-
buffer =
|
|
381
|
+
def create_thumbnail(image_path: str) -> Image:
|
|
382
|
+
"""Create a thumbnail from an image"""
|
|
383
|
+
img = PILImage.open(image_path)
|
|
384
|
+
img.thumbnail((100, 100))
|
|
385
|
+
buffer = BytesIO()
|
|
379
386
|
img.save(buffer, format="PNG")
|
|
380
|
-
# Return a new Image object with the thumbnail data
|
|
381
387
|
return Image(data=buffer.getvalue(), format="png")
|
|
382
|
-
|
|
383
|
-
@mcp.tool()
|
|
384
|
-
def load_image_from_disk(path: str) -> Image:
|
|
385
|
-
"""Loads an image from the specified path."""
|
|
386
|
-
# Handles reading file and detecting format based on extension
|
|
387
|
-
return Image(path=path)
|
|
388
388
|
```
|
|
389
|
-
|
|
389
|
+
Return the `Image` helper class from your tool to send an image to the client. The `Image` helper class handles the conversion to/from the base64-encoded format required by the MCP protocol. It works with either a path to an image file, or a bytes object.
|
|
390
390
|
|
|
391
391
|
|
|
392
392
|
### MCP Clients
|
|
@@ -26,7 +26,7 @@ fastmcp/prompts/prompt_manager.py,sha256=tMob9a-igjuzf6oTPLPGidFpJdg5JaPJVlYgyNk
|
|
|
26
26
|
fastmcp/resources/__init__.py,sha256=t0x1j8lc74rjUKtXe9H5Gs4fpQt82K4NgBK6Y7A0xTg,467
|
|
27
27
|
fastmcp/resources/resource.py,sha256=5FN2a7dpNwf7FSEYTNvQvkTxtodu1OPxSlJL-U-8yrM,2413
|
|
28
28
|
fastmcp/resources/resource_manager.py,sha256=_0itubfjYvfkA_wXKa4DQN5YpE7ejXhsE1hdt7m8XwU,9072
|
|
29
|
-
fastmcp/resources/template.py,sha256=
|
|
29
|
+
fastmcp/resources/template.py,sha256=PlC-fSGbQWJcFgM-fFgW-Xq8XwN3xsI68ivYcrk690E,5825
|
|
30
30
|
fastmcp/resources/types.py,sha256=tigil7z-SUJMakGXzDLIGSqTepPrAsRpwqwtBA4yoUY,6168
|
|
31
31
|
fastmcp/server/__init__.py,sha256=pdkghG11VLMZiluQ-4_rl2JK1LMWmV003m9dDRUN8W4,92
|
|
32
32
|
fastmcp/server/context.py,sha256=s1885AZRipKB3VltfaO3VEtMxGefKs8fdZByj-4tbNI,7120
|
|
@@ -34,7 +34,7 @@ fastmcp/server/openapi.py,sha256=DVdUfs-rbBF_CIlxrI6HJ5aYbzuyDqGLAhT1TeyxwFc,224
|
|
|
34
34
|
fastmcp/server/proxy.py,sha256=JHbxnOKbxyD5Jg2M_zSlNGKVBSZ5NUlVhQoKf442wxo,9619
|
|
35
35
|
fastmcp/server/server.py,sha256=PFhnwa24diSKCz8KO39q43yuSHSbqYrzgnSspc-SPfg,31721
|
|
36
36
|
fastmcp/tools/__init__.py,sha256=ocw-SFTtN6vQ8fgnlF8iNAOflRmh79xS1xdO0Bc3QPE,96
|
|
37
|
-
fastmcp/tools/tool.py,sha256=
|
|
37
|
+
fastmcp/tools/tool.py,sha256=hAdeQaJ-1AgPyVZPvCQKYFkK0opccJWa39xWGFAWlzA,5975
|
|
38
38
|
fastmcp/tools/tool_manager.py,sha256=hClv7fwj0cQSSwW0i-Swt7xiVqR4T9LVmr1Tp704nW4,3283
|
|
39
39
|
fastmcp/utilities/__init__.py,sha256=-imJ8S-rXmbXMWeDamldP-dHDqAPg_wwmPVz-LNX14E,31
|
|
40
40
|
fastmcp/utilities/decorators.py,sha256=AjhjsetQZF4YOPV5MTZmIxO21iFp_4fDIS3O2_KNCEg,2990
|
|
@@ -42,8 +42,8 @@ fastmcp/utilities/func_metadata.py,sha256=uh-u3gAjLD4kCcGf0ZkZZwBTTl-84JuANZTnDq
|
|
|
42
42
|
fastmcp/utilities/logging.py,sha256=zav8pnFxG_fvGJHUV2XpobmT9WVrmv1mlQBSCz-CPx4,1159
|
|
43
43
|
fastmcp/utilities/openapi.py,sha256=PrH3usbTblaVC6jIH1UGiPEfgB2sSCLj33zA5dH7o_s,45193
|
|
44
44
|
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.
|
|
45
|
+
fastmcp-2.2.3.dist-info/METADATA,sha256=dC6bbGM3xckA7dpYhpD3zQUyxSpTqLV0DppozXl5pjU,27771
|
|
46
|
+
fastmcp-2.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
47
|
+
fastmcp-2.2.3.dist-info/entry_points.txt,sha256=ff8bMtKX1JvXyurMibAacMSKbJEPmac9ffAKU9mLnM8,44
|
|
48
|
+
fastmcp-2.2.3.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
49
|
+
fastmcp-2.2.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|