Skip to content

Commit 8fec9d2

Browse files
Nikita BelliniNikita Bellini
authored andcommitted
Format
1 parent ae0ec16 commit 8fec9d2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/mcp/server/fastmcp/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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(

tests/server/fastmcp/test_runtime_tools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
from mcp.server.fastmcp.tools.base import Tool
88
from mcp.types import TextContent
99

10+
1011
@pytest.mark.anyio
1112
async 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"

0 commit comments

Comments
 (0)