Skip to main content
Glama

MySQL MCP Server

MIT License
580
  • Linux
  • Apple
import pytest from mysql_mcp_server.server import app, list_tools, list_resources, read_resource, call_tool from pydantic import AnyUrl def test_server_initialization(): """Test that the server initializes correctly.""" assert app.name == "mysql_mcp_server" @pytest.mark.asyncio async def test_list_tools(): """Test that list_tools returns expected tools.""" tools = await list_tools() assert len(tools) == 1 assert tools[0].name == "execute_sql" assert "query" in tools[0].inputSchema["properties"] @pytest.mark.asyncio async def test_call_tool_invalid_name(): """Test calling a tool with an invalid name.""" with pytest.raises(ValueError, match="Unknown tool"): await call_tool("invalid_tool", {}) @pytest.mark.asyncio async def test_call_tool_missing_query(): """Test calling execute_sql without a query.""" with pytest.raises(ValueError, match="Query is required"): await call_tool("execute_sql", {}) # Skip database-dependent tests if no database connection @pytest.mark.asyncio @pytest.mark.skipif( not all([ pytest.importorskip("mysql.connector"), pytest.importorskip("mysql_mcp_server") ]), reason="MySQL connection not available" ) async def test_list_resources(): """Test listing resources (requires database connection).""" try: resources = await list_resources() assert isinstance(resources, list) except ValueError as e: if "Missing required database configuration" in str(e): pytest.skip("Database configuration not available") raise

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/designcomputer/mysql_mcp_server'

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