mcp-server-duckdb
A Model Context Protocol server enabling SQL access to DuckDB databases.
Key Features
Use Cases
README
mcp-server-duckdb
A Model Context Protocol (MCP) server implementation for DuckDB, providing database interaction capabilities through MCP tools. It would be interesting to have LLM analyze it. DuckDB is suitable for local analysis.
Overview
This server enables interaction with a DuckDB database through the Model Context Protocol, allowing for database operations like querying, table creation, and schema inspection.
Components
Resources
Currently, no custom resources are implemented.
Prompts
Currently, no custom prompts are implemented.
Tools
The server implements the following database interaction tool:
- query: Execute any SQL query on the DuckDB database
- Input:
query(string) - Any valid DuckDB SQL statement - Output: Query results as text (or success message for operations like CREATE/INSERT)
- Input:
[!NOTE] The server provides a single unified
queryfunction rather than separate specialized functions, as modern LLMs can generate appropriate SQL for any database operation (SELECT, CREATE TABLE, JOIN, etc.) without requiring separate endpoints.
[!NOTE] When the server is running in
readonlymode, DuckDB's native readonly protection is enforced. This ensures that the Language Model (LLM) cannot perform any write operations (CREATE, INSERT, UPDATE, DELETE), maintaining data integrity and preventing unintended changes.
Configuration
Required Parameters
- db-path (string): Path to the DuckDB database file
- The server will automatically create the database file and parent directories if they don't exist
- If
--readonlyis specified and the database file doesn't exist, the server will fail to start with an error
Optional Parameters
- --readonly: Run server in read-only mode (default:
false)- Description: When this flag is set, the server operates in read-only mode. This means:
- The DuckDB database will be opened with
read_only=True, preventing any write operations. - If the specified database file does not exist, it will not be created.
- Security Benefit: Prevents the Language Model (LLM) from performing any write operations, ensuring that the database remains unaltered.
- The DuckDB database will be opened with
- Reference: For more details on read-only connections in DuckDB, see the DuckDB Python API documentation.
- Description: When this flag is set, the server operates in read-only mode. This means:
- --keep-connection: Re-uses a single DuckDB connection mode (default:
false)- Description: When this flag is set, Re-uses a single DuckDB connection for the entire server lifetime. Enables TEMP objects & slightly faster queries, but can hold an exclusive lock on the file.
Installation
Installing via Smithery
To install DuckDB Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install mcp-server-duckdb --client claude
Claude Desktop Integration
Configure the MCP server in Claude Desktop's configuration file:
MacOS
Location: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows
Location: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"duckdb": {
"command": "uvx",
"args": [
"mcp-server-duckdb",
"--db-path",
"~/mcp-server-duckdb/data/data.db"
]
}
}
}
- Note:
~/mcp-server-duckdb/data/data.dbshould be replaced with the actual path to the DuckDB database file.
Development
Prerequisites
- Python with
uvpackage manager - DuckDB Python package
- MCP server dependencies
Debugging
Debugging MCP servers can be challenging due to their stdio-based communication. We recommend using the MCP Inspector for the best debugging experience.
Using MCP Inspector
- Install the inspector using npm:
npx @modelcontextprotocol/inspector uv --directory ~/codes/mcp-server-duckdb run mcp-server-duckdb --db-path ~/mcp-server-duckdb/data/data.db
- Open the provided URL in your browser to access the debugging interface
The inspector provides visibility into:
- Request/response communication
- Tool execution
- Server state
- Error messages
Star History
Repository Owner
User
Repository Details
Programming Languages
Tags
Topics
Join Our Newsletter
Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.
Related MCPs
Discover similar Model Context Protocol servers
MCP libSQL by xexr
Secure, protocol-compliant libSQL database server for MCP-enabled clients.
MCP libSQL by xexr provides a Model Context Protocol (MCP) server designed for secure database access and management via libSQL. It enables database operations—such as querying, table management, and schema inspection—through standardized MCP tools, ensuring compatibility with clients like Claude Desktop and Cursor. The project emphasizes robust security validation, audit logging, and comprehensive error handling. Users benefit from production-ready deployment, extensive test coverage, and streamlined integration with MCP-compatible platforms.
- ⭐ 16
- MCP
- Xexr/mcp-libsql
BigQuery MCP Server
MCP server enabling LLMs to access and interact with BigQuery databases.
BigQuery MCP Server provides a Model Context Protocol-compliant interface that allows large language models to inspect database schemas and execute SQL queries on BigQuery. It exposes tools for executing queries, listing tables, and describing table schemas, supporting both CLI and environment-based configuration. The server integrates with Claude Desktop and can be easily installed via Smithery, facilitating seamless interaction between LLMs and BigQuery data sources.
- ⭐ 120
- MCP
- LucasHild/mcp-server-bigquery
Nile MCP Server
A Model Context Protocol (MCP) server for managing databases on the Nile platform through standardized interfaces.
Nile MCP Server implements the Model Context Protocol to enable seamless integration between LLM applications and the Nile database platform. It provides standardized APIs for database and credential management, SQL execution, and region discovery. Written in TypeScript, the server focuses on type safety, comprehensive error handling, and robust input validation. It supports easy installation and integration with Claude Desktop for advanced AI workflows.
- ⭐ 16
- MCP
- niledatabase/nile-mcp-server
MCP 数据库工具 (MCP Database Utilities)
A secure bridge enabling AI systems safe, read-only access to multiple databases via unified configuration.
MCP Database Utilities provides a secure, standardized service for AI systems to access and analyze databases like SQLite, MySQL, and PostgreSQL using a unified YAML-based configuration. It enforces strict read-only operations, local processing, and credential protection to ensure data privacy and integrity. The tool is suitable for entities focused on data privacy and minimizes risks by isolating database connections and masking sensitive data. Designed for easy integration, it supports multiple installation options and advanced capabilities such as schema analysis and table browsing.
- ⭐ 85
- MCP
- donghao1393/mcp-dbutils
Databricks MCP Server
Expose Databricks data and jobs securely with Model Context Protocol for LLMs.
Databricks MCP Server implements the Model Context Protocol (MCP) to provide a bridge between Databricks APIs and large language models. It enables LLMs to run SQL queries, list Databricks jobs, retrieve job statuses, and fetch detailed job information via a standardized MCP interface. The server handles authentication, secure environment configuration, and provides accessible endpoints for interaction with Databricks workspaces.
- ⭐ 42
- MCP
- JordiNeil/mcp-databricks-server
XiYan MCP Server
A server enabling natural language queries to SQL databases via the Model Context Protocol.
XiYan MCP Server is a Model Context Protocol (MCP) compliant server that allows users to query SQL databases such as MySQL and PostgreSQL using natural language. It leverages the XiYanSQL model, providing state-of-the-art text-to-SQL translation and supports both general LLMs and local deployment for enhanced security. The server lists available database tables as resources and can read table contents, making it simple to integrate with different applications.
- ⭐ 218
- MCP
- XGenerationLab/xiyan_mcp_server
Didn't find tool you were looking for?