Integrations
Enables connection to PostgreSQL databases with support for authentication, SSL connections, and execution of SQL queries against PostgreSQL 9.5 or later.
Provides direct access to SQLite database files, allowing for executing queries, schema modifications, and data operations against local SQLite databases.
MCP 数据库服务器
该MCP(模型上下文协议)服务器为Claude提供数据库访问能力,支持SQLite、SQL Server、PostgreSQL数据库。
安装
- 克隆存储库:
- 安装依赖项:
- 构建项目:
使用选项
有两种方法可以将此 MCP 服务器与 Claude 一起使用:
- 直接使用:全局安装包并直接使用
- 本地开发:从本地开发环境运行
直接使用 NPM 包
使用此 MCP 服务器的最简单方法是全局安装它:
这使得您可以直接使用服务器,而无需在本地构建它。
本地开发设置
如果您想修改代码或从本地环境运行:
- 按照安装部分所示克隆并构建存储库
- 使用下面使用部分中的命令运行服务器
用法
SQLite 数据库
要与 SQLite 数据库一起使用:
SQL Server 数据库
要与 SQL Server 数据库一起使用:
必需参数:
--server
:SQL Server 主机名或 IP 地址--database
:数据库名称
可选参数:
--user
:SQL Server 身份验证的用户名(如果未提供,则将使用 Windows 身份验证)--password
:SQL Server 身份验证的密码--port
:端口号(默认值:1433)
PostgreSQL 数据库
要与 PostgreSQL 数据库一起使用:
必需参数:
--host
:PostgreSQL 主机名或 IP 地址--database
:数据库名称
可选参数:
--user
:PostgreSQL 身份验证的用户名--password
:PostgreSQL 身份验证的密码--port
:端口号(默认值:5432)--ssl
:启用 SSL 连接(true/false)--connection-timeout
:连接超时(以毫秒为单位)(默认值:30000)
配置 Claude 桌面
直接使用配置
如果您全局安装了该软件包,请使用以下命令配置 Claude Desktop:
本地开发配置
对于本地开发,配置 Claude Desktop 以使用本地构建的版本:
Claude Desktop 配置文件通常位于:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- Linux:
~/.config/Claude/claude_desktop_config.json
可用的数据库工具
MCP 数据库服务器提供了以下可供 Claude 使用的工具:
工具 | 描述 | 必需参数 |
---|---|---|
read_query | 执行 SELECT 查询来读取数据 | query :SQL SELECT 语句 |
write_query | 执行 INSERT、UPDATE 或 DELETE 查询 | query :SQL修改语句 |
create_table | 在数据库中创建新表 | query :CREATE TABLE 语句 |
alter_table | 修改现有表架构 | query :ALTER TABLE 语句 |
drop_table | 从数据库中删除表 | table_name :表的名称confirm :安全标志(必须为真) |
list_tables | 获取所有表的列表 | 没有任何 |
describe_table | 查看表的架构信息 | table_name :表的名称 |
export_query | 将查询结果导出为 CSV/JSON | query :SQL SELECT 语句format :“csv”或“json” |
append_insight | 将业务洞察添加到备忘录 | insight :洞察力的文本 |
list_insights | 列出所有业务见解 | 没有任何 |
有关如何与 Claude 一起使用这些工具的实际示例,请参阅使用示例。
其他文档
- SQL Server 安装指南:有关连接 SQL Server 数据库的详细信息
- PostgreSQL 设置指南:有关连接 PostgreSQL 数据库的详细信息
- 使用示例:与 Claude 一起使用的示例查询和命令
发展
要在开发模式下运行服务器:
观察开发过程中的变化:
要求
- Node.js 18+
- 对于 SQL Server 连接:SQL Server 2012 或更高版本
- 对于 PostgreSQL 连接:PostgreSQL 9.5 或更高版本
执照
麻省理工学院
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
模型上下文协议服务器使 Claude 等 LLM 能够与 SQLite 和 SQL Server 数据库交互,从而允许模式检查和 SQL 查询执行。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to interact with Salesforce data through SOQL queries, SOSL searches, and various API operations including record management.Last updated -1053PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that provides database interaction capabilities through SQLite, enabling users to run SQL queries, analyze business data, and automatically generate business insight memos.Last updated -69TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables Claude and other LLMs to interact with Notion workspaces, providing capabilities like searching, retrieving, creating and updating pages, as well as managing databases.Last updated -2752TypeScript
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs to interact with databases (currently MongoDB) through natural language, supporting operations like querying, inserting, deleting documents, and running aggregation pipelines.Last updated -TypeScriptMIT License