File tree 1 file changed +27
-0
lines changed 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ import pytest
2
+ from mcp .server .fastmcp import FastMCP
3
+
4
+ pytestmark = pytest .mark .anyio
5
+
6
+ async def test_list_tools_returns_all_tools ():
7
+ mcp = FastMCP ("TestTools" )
8
+
9
+ # Create 100 tools with unique names
10
+ num_tools = 100
11
+ for i in range (num_tools ):
12
+ @mcp .tool (name = f"tool_{ i } " )
13
+ def dummy_tool_func ():
14
+ f"""Tool number { i } """
15
+ return i
16
+ globals ()[f'dummy_tool_{ i } ' ] = dummy_tool_func # Keep reference to avoid garbage collection
17
+
18
+ # Get all tools
19
+ tools = await mcp .list_tools ()
20
+
21
+ # Verify we get all tools
22
+ assert len (tools ) == num_tools , f"Expected { num_tools } tools, but got { len (tools )} "
23
+
24
+ # Verify each tool is unique and has the correct name
25
+ tool_names = [tool .name for tool in tools ]
26
+ expected_names = [f"tool_{ i } " for i in range (num_tools )]
27
+ assert sorted (tool_names ) == sorted (expected_names ), "Tool names don't match expected names"
You can’t perform that action at this time.
0 commit comments