How motherduckdb/mcp-server-motherduck works
This is a local MCP server that gives AI assistants SQL and catalog access to DuckDB and MotherDuck. A client invokes a registered server tool; the server dispatches to a query or catalog handler, which uses the shared database client to execute SQL or inspect metadata and returns JSON. The README also documents local-file, in-memory, S3, and MotherDuck connections, configurable result limits, and optional connection switching. Tool registration and calls are visible in the server excerpt; some backend behavior is documented but not fully sampled.
Main entry points: server.py MCP server · database.py Database client · execute_query.py Execute SQL · list_databases.py List databases
Components 14
Server entry and guidance
- CLI entry
src/mcp_server_motherduck/__init__.py - MCP server
src/mcp_server_motherduck/server.py - Usage instructions
src/mcp_server_motherduck/instructions.py - Server config
src/mcp_server_motherduck/configs.py
MCP tool handlers
- Execute SQL
src/mcp_server_motherduck/tools/execute_query.py - List databases
src/mcp_server_motherduck/tools/list_databases.py - List tables
src/mcp_server_motherduck/tools/list_tables.py - List columns
src/mcp_server_motherduck/tools/list_columns.py - Switch connection
src/mcp_server_motherduck/tools/switch_database_connection.py
Database runtime
- Database client
src/mcp_server_motherduck/database.py
Database backends
- DuckDB
- MotherDuck
- S3-hosted files
Other components
- AI assistant
Connections 17
- AI assistant → MCP server: invokes tools
README.md - CLI entry → MCP server: creates server
src/mcp_server_motherduck/__init__.py - MCP server → Database client: creates client
src/mcp_server_motherduck/server.py - MCP server → Usage instructions: gets guidance
src/mcp_server_motherduck/server.py - MCP server → Execute SQL: dispatches query
src/mcp_server_motherduck/server.py - MCP server → List databases: dispatches listing
src/mcp_server_motherduck/server.py - MCP server → List tables: dispatches listing
src/mcp_server_motherduck/server.py - MCP server → List columns: dispatches listing
src/mcp_server_motherduck/server.py - MCP server → Switch connection: dispatches switch
src/mcp_server_motherduck/server.py - Execute SQL → Database client: executes query
src/mcp_server_motherduck/tools/execute_query.py - List databases → Database client: reads catalog
src/mcp_server_motherduck/tools/list_databases.py - List tables → Database client: reads catalog
src/mcp_server_motherduck/tools/list_tables.py - List columns → Database client: reads catalog
src/mcp_server_motherduck/tools/list_columns.py - Switch connection → Database client: changes connection
src/mcp_server_motherduck/tools/switch_database_connection.py - Database client → DuckDB: executes SQL
src/mcp_server_motherduck/database.py - Database client → MotherDuck: connects to
README.md - Database client → S3-hosted files: opens remote files
README.md