SuperAPIAI Directory

mcp-server-duckdb

github.com · AI developer platforms

mcp-server-duckdb is a Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities through MCP tools. It enables LLMs to perform operations such as querying, creating tables, and viewing schemas on a DuckDB database. The project provides a unified query tool that supports any valid DuckDB SQL statement; an optional --readonly mode blocks writes to protect data integrity; and --keep-connection reuses a single connection to support TEMP objects and slightly improve query speed. A db-path parameter must be provided to specify the database file path; if the file and its parent directory do not exist, they are created automatically (in readonly mode they are not created and startup fails). It is suitable for scenarios such as local data analysis.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsmacOS

About this tool

mcp-server-duckdb is a Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities through MCP tools. The material notes that DuckDB is well suited for local analysis, and having an LLM analyze it would be quite interesting.

Purpose The server enables clients to interact with a DuckDB database through MCP, supporting database operations such as querying, creating tables, and schema inspection. Currently, no custom resources or custom prompts are implemented.

Main capabilities The server implements one database interaction tool: query, used to execute arbitrary SQL queries on a DuckDB database. The input is query (a string), i.e., any valid DuckDB SQL statement; the output is the query result in text form, or a success message for operations such as CREATE/INSERT. The material explains that the server provides a single unified query function rather than multiple specialized functions, because modern LLMs can generate appropriate SQL for arbitrary database operations (SELECT, CREATE TABLE, JOIN, etc.) without needing separate endpoints.

Usage The required parameter is db-path (a string), i.e., the path to the DuckDB database file. The server automatically creates the database file and its parent directory if they do not exist; however, if --readonly is specified and the database file does not exist, the server will fail to start and report an error.

Optional parameters include: --readonly: Run the server in readonly mode, default false. When set, the DuckDB database is opened with read_only=True, blocking any write operations; if the specified database file does not exist, it will not be created. The security benefit is preventing the LLM from performing any write operations, ensuring the database is not modified. The material suggests referring to the DuckDB Python API documentation for more details on readonly connections. --keep-connection: Reuse a single DuckDB connection mode, default false. When set, a single DuckDB connection is reused throughout the server lifecycle, which can enable TEMP objects and slightly speed up queries, but may hold an exclusive lock on the file.

Integration and prerequisites DuckDB Server for Claude Desktop can be installed automatically via Smithery. Claude Desktop integration requires configuration in its config fileSet up the MCP server: on macOS the location is ~/Library/Application Support/Claude/claude_desktop_config.json, and on Windows the location is %APPDATA%/Claude/claude_desktop_config.json. Note that ~/mcp-server-duckdb/data/data.db should be replaced with the actual path to the DuckDB database file. Prerequisites include: Python and the uv package manager, the DuckDB Python package, and the MCP server dependencies.

Debugging Because the MCP server communicates over stdio, debugging can be difficult; using MCP Inspector is recommended for the best debugging experience. You can install the inspector via npm, then open the provided URL in a browser to access the debugging interface. The inspector can show request/response communication.

Use cases and limitations It is suitable for enabling an LLM to query and analyze a local DuckDB database via MCP, especially for local analysis scenarios. In terms of limitations: there are currently no custom resources or custom prompts; in read-only mode, writes are not possible and the database file must already exist; the reused connection mode may hold an exclusive file lock.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools