-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathtest_100_tool_listing.py
More file actions
31 lines (21 loc) · 950 Bytes
/
test_100_tool_listing.py
File metadata and controls
31 lines (21 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pytest
from mcp.server.mcpserver import MCPServer
pytestmark = pytest.mark.anyio
async def test_list_tools_returns_all_tools():
mcp = MCPServer("TestTools")
# Create 100 tools with unique names
num_tools = 100
for i in range(num_tools):
@mcp.tool(name=f"tool_{i}")
def dummy_tool_func(): # pragma: no cover
f"""Tool number {i}"""
return i
globals()[f"dummy_tool_{i}"] = dummy_tool_func # Keep reference to avoid garbage collection
# Get all tools
tools = await mcp.list_tools()
# Verify we get all tools
assert len(tools) == num_tools, f"Expected {num_tools} tools, but got {len(tools)}"
# Verify each tool is unique and has the correct name
tool_names = [tool.name for tool in tools]
expected_names = [f"tool_{i}" for i in range(num_tools)]
assert sorted(tool_names) == sorted(expected_names), "Tool names don't match expected names"