Skip to content

Commit 66d459b

Browse files
committed
Update @mcp.resource to use function documentation as default description if not provided
1 parent 9fb9ce6 commit 66d459b

File tree

1 file changed

+3
-3
lines changed
  • src/mcp/server/fastmcp/resources

1 file changed

+3
-3
lines changed

src/mcp/server/fastmcp/resources/types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
from collections.abc import Callable
66
from pathlib import Path
7-
from typing import Any
7+
from typing import Any, Self
88

99
import anyio
1010
import anyio.to_thread
@@ -76,7 +76,7 @@ def from_function(
7676
name: str | None = None,
7777
description: str | None = None,
7878
mime_type: str | None = None,
79-
):
79+
) -> Self:
8080
"""Create a template from a function."""
8181
func_name = name or fn.__name__
8282
if func_name == "<lambda>":
@@ -87,7 +87,7 @@ def from_function(
8787

8888
return cls(
8989
uri=AnyUrl(uri),
90-
name=name,
90+
name=func_name,
9191
description=description or fn.__doc__ or "",
9292
mime_type=mime_type or "text/plain",
9393
fn=fn,

0 commit comments

Comments
 (0)