
ktanaka101/mcp-server-duckdb 是从 https://github.com/ktanaka101/mcp-server-duckdb. 导入的 MCP 服务器候选
概览
ktanaka101/mcp-server-duckdb 是从 https://github.com/ktanaka101/mcp-server-duckdb. 导入的 MCP 服务器候选
概述(AI 翻译)
DuckDB 的模型上下文协议(MCP)服务器实现,通过 MCP 工具提供数据库交互功能。 如果能让大型语言模型(LLM)来分析它会很有趣。DuckDB 适合进行局部分析。
概述
该服务器通过模型上下文协议支持与 DuckDB 数据库的交互,支持查询、表创建和模式检查等数据库操作。
组成部分
资源
目前,尚未实现自定义资源。
提示
目前,尚未实现自定义提示。
工具
服务器实现了以下数据库交互工具:
- query:在DuckDB数据库中执行任意SQL查询
- Input:
query(字符串)- 任何有效的DuckDB SQL语句 - 输出:以文本形式查询结果(或如创建/插入等操作的成功消息)
[!注] 服务器提供单一统一的
query函数,而非独立的专用函数,因为现代LLM可以为任何数据库操作(如SELECT、创建表、加入等)生成合适的SQL,而无需单独的端点。
[!注]
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 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)
安装
uvx mcp-server-duckdb --db-path ~/mcp-server-duckdb/data/data.db配置
{
"mcpServers": {
"duckdb": {
"command": "uvx",
"args": [
"mcp-server-duckdb",
"--db-path",
"~/mcp-server-duckdb/data/data.db"
]
}
}
}