Consolidate get_* and _list_* methods into single API (#2719)

This commit is contained in:
Jeremiah Lowin 2025-12-24 22:26:52 -05:00 committed by GitHub
commit 125f79ff39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 582 additions and 587 deletions

View file

@ -164,7 +164,7 @@ def greet(name: str) -> str:
server = await source.load_server()
assert server.name == "TestServer"
tools = await server.get_tools()
assert "greet" in tools
assert any(t.name == "greet" for t in tools)
async def test_import_server_with_main_block(self, tmp_path):
"""Test importing server with if __name__ == '__main__' block."""
@ -186,7 +186,7 @@ if __name__ == "__main__":
server = await source.load_server()
assert server.name == "MainServer"
tools = await server.get_tools()
assert "calculate" in tools
assert any(t.name == "calculate" for t in tools)
async def test_import_server_standard_names(self, tmp_path):
"""Test automatic detection of standard names (mcp, server, app)."""
@ -240,7 +240,7 @@ def custom_tool() -> str:
server = await source.load_server()
assert server.name == "CustomServer"
tools = await server.get_tools()
assert "custom_tool" in tools
assert any(t.name == "custom_tool" for t in tools)
async def test_import_server_no_standard_names_fails(self, tmp_path):
"""Test importing server when no standard names exist fails."""

View file

@ -50,7 +50,7 @@ def get_config() -> dict:
# Test the tool works and can access the parsed args
tools = await server.get_tools()
assert "get_config" in tools
assert any(t.name == "get_config" for t in tools)
async def test_server_with_no_args(self, tmp_path):
"""Test a server that uses argparse with no arguments (defaults)."""
@ -131,5 +131,5 @@ mcp = FastMCP(name)
# Verify tools are available
tools = await server.get_tools()
assert "get_status" in tools
assert "echo_message" in tools
assert any(t.name == "get_status" for t in tools)
assert any(t.name == "echo_message" for t in tools)