Skip to content

Commit 79ec8dc

Browse files
committed
test: Add test for unlimited tool listing (issue #100)
1 parent ed99316 commit 79ec8dc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/issues/test_100_tool_listing.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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"

0 commit comments

Comments
 (0)