π The fast, Pythonic way to build MCP servers and clients.
Merge branch 'main' into transform-tools
Jeremiah Lowin0b8bf825c131
diff --cc tests/tools/test_tool.pyindex bc7423848,97f6fdf81..fb4a95b64--- a/tests/tools/test_tool.py+++ b/tests/tools/test_tool.py@@@ -5,7 -5,7 +5,7 @@@ from pydantic import AnyUrl, BaseModefrom fastmcp import FastMCP, Imagefrom fastmcp.client import Clientfrom fastmcp.exceptions import ToolError- from fastmcp.tools import FunctionTool-from fastmcp.tools.tool import Tool, _convert_to_content++from fastmcp.tools.tool import FunctionTool, _convert_to_contentfrom fastmcp.utilities.tests import temporary_settings@@@ -183,6 -183,32 +183,32 @@@ class TestToolFromFunctionclass MyClass:x: int = 10+ @classmethod+ def call(cls, x: int, y: int) -> int:+ """Add two numbers."""+ return x + y+- tool = Tool.from_function(MyClass.call)++ tool = FunctionTool.from_function(MyClass.call)+ assert tool.name == "call"+ assert tool.description == "Add two numbers."+ assert "x" in tool.parameters["properties"]+ assert "y" in tool.parameters["properties"]++ async def test_tool_serializer(self):+ """Test that a tool's serializer is used to serialize the result."""++ def custom_serializer(data) -> str:+ return f"Custom serializer: {data}"++ def process_list(items: list[int]) -> int:+ return sum(items)+- tool = Tool.from_function(process_list, serializer=custom_serializer)++ tool = FunctionTool.from_function(process_list, serializer=custom_serializer)++ result = await tool.run(arguments={"items": [1, 2, 3, 4, 5]})+ assert isinstance(result[0], TextContent)+ assert result[0].text == "Custom serializer: 15"+class TestLegacyToolJsonParsing:"""Tests for Tool's JSON pre-parsing functionality."""