Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update @mcp.resource to use function documentation as default descri…
…ption if not provided
  • Loading branch information
jingyugao committed May 15, 2025
commit 66d459bb7c486a358f4caf859135be9d9c33dd6f
6 changes: 3 additions & 3 deletions src/mcp/server/fastmcp/resources/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
from collections.abc import Callable
from pathlib import Path
from typing import Any
from typing import Any, Self

import anyio
import anyio.to_thread
Expand Down Expand Up @@ -76,7 +76,7 @@ def from_function(
name: str | None = None,
description: str | None = None,
mime_type: str | None = None,
):
) -> Self:
"""Create a template from a function."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

func_name = name or fn.__name__
if func_name == "<lambda>":
Expand All @@ -87,7 +87,7 @@ def from_function(

return cls(
uri=AnyUrl(uri),
name=name,
name=func_name,
description=description or fn.__doc__ or "",
mime_type=mime_type or "text/plain",
fn=fn,
Expand Down
Loading