File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -253,7 +253,9 @@ async def list_tools(self) -> list[MCPTool]:
253253
254254 # Check if there are no duplicated tools
255255 if len (tools ) != len (set ([tool .name for tool in tools ])):
256- raise Exception ("There are duplicated tools. Check the for tools with the same name both static and generated at runtime." )
256+ raise Exception (
257+ "There are duplicated tools. Check the for tools with the same name both static and generated at runtime."
258+ )
257259
258260 return [
259261 MCPTool (
Original file line number Diff line number Diff line change 77from mcp .server .fastmcp .tools .base import Tool
88from mcp .types import TextContent
99
10+
1011@pytest .mark .anyio
1112async def test_runtime_tools ():
1213 """Test that runtime tools work correctly."""
14+
1315 async def runtime_mcp_tools_generator () -> list [Tool ]:
1416 """Generate runtime tools."""
17+
1518 def runtime_tool_1 (message : str ):
1619 return message
17-
20+
1821 def runtime_tool_2 (message : str ):
1922 return message
2023
21- return [
22- Tool .from_function (runtime_tool_1 ),
23- Tool .from_function (runtime_tool_2 )
24- ]
24+ return [Tool .from_function (runtime_tool_1 ), Tool .from_function (runtime_tool_2 )]
2525
2626 # Create server with various tool configurations, both static and runtime
2727 mcp = FastMCP (name = "RuntimeToolsTestServer" , runtime_mcp_tools_generator = runtime_mcp_tools_generator )
@@ -70,4 +70,4 @@ def static_tool(message: str) -> str:
7070 assert len (result .content ) == 1
7171 content = result .content [0 ]
7272 assert isinstance (content , TextContent )
73- assert content .text == "Unknown tool: non_existing_tool"
73+ assert content .text == "Unknown tool: non_existing_tool"
You can’t perform that action at this time.
0 commit comments