Files
modelcontextprotocol--pytho…/tests/issues/test_100_tool_listing.py
T
wehub-resource-sync 49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:10:27 +08:00

32 lines
950 B
Python

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"