π The fast, Pythonic way to build MCP servers and clients.
Move search from resource to tool
zzstoatzz2701de8e7b29
diff --git a/examples/atproto_mcp/README.md b/examples/atproto_mcp/README.mdindex 6ca2e30b8..2ca9a4b72 100644--- a/examples/atproto_mcp/README.md+++ b/examples/atproto_mcp/README.md@@ -8,12 +8,12 @@ This example demonstrates a FastMCP server that provides tools and resources for- **atproto://profile/status**: Get connection status and profile information- **atproto://timeline**: Retrieve your timeline feed-- **atproto://search/{query}**: Search for posts by keyword- **atproto://notifications**: Get recent notifications### Tools (Actions)- **post**: Create posts with rich features (text, images, quotes, replies, links, mentions)+- **search**: Search for posts by query- **follow**: Follow users by handle- **like**: Like posts by URI- **repost**: Share posts by URIdiff --git a/examples/atproto_mcp/demo.py b/examples/atproto_mcp/demo.pyindex 8ece76f9a..0184c27f9 100644--- a/examples/atproto_mcp/demo.py+++ b/examples/atproto_mcp/demo.py@@ -55,7 +55,7 @@ async def main(enable_posting: bool = False):# 3. Search for postsprint("\n3. Searching for posts about 'Bluesky'...")- result = await client.read_resource("atproto://search/Bluesky")+ result = await client.call_tool("search", {"query": "Bluesky", "limit": 5})search: SearchResult = (json.loads(result[0].text) if result else cast(SearchResult, {}))@@ -195,7 +195,6 @@ async def main(enable_posting: bool = False):print("\n Resources (read-only):")print(" - atproto://profile/status")print(" - atproto://timeline")- print(" - atproto://search/{query}")print(" - atproto://notifications")print("\n Tools (actions):")@@ -206,6 +205,7 @@ async def main(enable_posting: bool = False):print(" β’ Replies and threads")print(" β’ Quote posts")print(" β’ Combinations (quote + image, reply + rich text, etc.)")+ print(" - search: Search for posts")print(" - follow: Follow users")print(" - like: Like posts")print(" - repost: Share posts")diff --git a/examples/atproto_mcp/src/atproto_mcp/server.py b/examples/atproto_mcp/src/atproto_mcp/server.pyindex af27cbade..79ae5b8a0 100644--- a/examples/atproto_mcp/src/atproto_mcp/server.py+++ b/examples/atproto_mcp/src/atproto_mcp/server.py@@ -41,23 +41,6 @@ def get_timeline() -> TimelineResult:return _atproto.fetch_timeline(settings.atproto_timeline_default_limit)-@atproto_mcp.resource("atproto://search/{query}")-def search_posts(- query: Annotated[str, Field(description="Search query for posts")],- limit: Annotated[- int,- Field(- default=settings.atproto_search_default_limit,- ge=1,- le=100,- description="Number of results to return",- ),- ],-) -> SearchResult:- """Search for posts containing specific text."""- return _atproto.search_for_posts(query, limit)--@atproto_mcp.resource("atproto://notifications")def get_notifications() -> NotificationsResult:"""Get recent notifications for the authenticated user."""@@ -132,3 +115,14 @@ def repost() -> RepostResult:"""Repost a post by its AT URI."""return _atproto.repost_by_uri(uri)+++@atproto_mcp.tool+def search(+ query: Annotated[str, Field(description="Search query for posts")],+ limit: Annotated[+ int, Field(ge=1, le=100, description="Number of results to return")+ ] = settings.atproto_search_default_limit,+) -> SearchResult:+ """Search for posts containing specific text."""+ return _atproto.search_for_posts(query, limit)