Skip to main content
Glama
test_list_servers.py1.98 kB
"""Unit tests for ListServersService.""" import pytest from mcp_sql.tools.list_servers import ListServersService @pytest.mark.asyncio class TestListServersService: """Test cases for ListServersService.""" async def test_name_property(self, tool_dependencies): """Test that the tool has the correct name.""" service = ListServersService(**tool_dependencies) assert service.name == "list_configured_servers" async def test_description_property(self, tool_dependencies): """Test that the tool has a description.""" service = ListServersService(**tool_dependencies) assert len(service.description) > 0 assert "server" in service.description.lower() async def test_execute_returns_server_list(self, tool_dependencies, mock_context): """Test that execute returns a list of server names.""" service = ListServersService(**tool_dependencies) result = await service.execute(mock_context) assert isinstance(result, list) assert len(result) == 3 assert "server1" in result assert "server2" in result assert "server3" in result async def test_execute_calls_connection_manager(self, tool_dependencies, mock_context): """Test that execute calls the connection manager.""" service = ListServersService(**tool_dependencies) await service.execute(mock_context) tool_dependencies["connection_manager"].get_configured_server_names.assert_called_once() async def test_execute_with_empty_servers(self, tool_dependencies, mock_context): """Test execute when no servers are configured.""" tool_dependencies["connection_manager"].get_configured_server_names.return_value = [] service = ListServersService(**tool_dependencies) result = await service.execute(mock_context) assert isinstance(result, list) assert len(result) == 0

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yuuues/mcp-sql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server