MCP 数据库服务器是一个新的 MCP 服务器,可帮助连接到 SQLite、SQL Server 和 PostgreSQL 数据库。
MCP 数据库服务器是一个新的 MCP 服务器,可帮助连接到 SQLite、SQL Server 和 PostgreSQL 数据库。
This MCP (Model Context Protocol) server provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.
git clone https://github.com/executeautomation/mcp-database-server.git
cd mcp-database-servernpm installnpm run buildThere are two ways to use this MCP server with Claude:
The easiest way to use this MCP server is by installing it globally:
npm install -g @executeautomation/database-serverThis allows you to use the server directly without building it locally.
If you want to modify the code or run from your local environment:
To use with an SQLite database:
node dist/src/index.js /path/to/your/database.dbTo use with a SQL Server database:
node dist/src/index.js --sqlserver --server --database [--user --password ]Required parameters:
--server: SQL Server host name or IP address--database: Name of the databaseOptional parameters:
--user: Username for SQL Server authentication (if not provided, Windows Authentication will be used)--password: Password for SQL Server authentication--port: Port number (default: 1433)To use with a PostgreSQL database:
node dist/src/index.js --postgresql --host --database [--user --password ]Required parameters:
--host: PostgreSQL host name or IP address--database: Name of the databaseOptional parameters:
--user: Username for PostgreSQL authentication--password: Password for PostgreSQL authentication--port: Port number (default: 5432)--ssl: Enable SSL connection (true/false)--connection-timeout: Connection timeout in milliseconds (default: 30000)To use with a MySQL database:
node dist/src/index.js --mysql --host --database --port [--user --password ]Required parameters:
--host: MySQL host name or IP address--database: Name of the database--port: Port number (default: 3306)Optional parameters:
--user: Username for MySQL authentication--password: Password for MySQL authentication--ssl: Enable SSL connection (true/false or object)--connection-timeout: Connection timeout in milliseconds (default: 30000)For Amazon RDS MySQL instances with IAM database authentication:
Prerequisites:
aws configure (uses default profile)AWS_PROFILE=myprofile environment variableAWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variablesnode dist/src/index.js --mysql --aws-iam-auth --host --database --user --aws-region Required parameters:
--host: RDS endpoint hostname--database: Name of the database--aws-iam-auth: Enable AWS IAM authentication--user: AWS IAM username (also the database user)--aws-region: AWS region where RDS instance is locatedNote: SSL is automatically enabled for AWS IAM authentication
If you installed the package globally, configure Claude Desktop with:
…For local development, configure Claude Desktop to use your locally built version:
…The Claude Desktop configuration file is typically located at:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.jsonThe MCP Database Server provides the following tools that Claude can use:
| Tool | Description | Required Parameters |
|---|---|---|
read_query |
Execute SELECT queries to read data | query: SQL SELECT statement |
write_query |
Execute INSERT, UPDATE, or DELETE queries | query: SQL modification statement |
create_table |
Create new tables in the database | query: CREATE TABLE statement |
alter_table |
Modify existing table schema | query: ALTER TABLE statement |
drop_table |
Remove a table from the database | table_name: Name of table |
confirm: Safety flag (must be true) |
||
list_tables |
Get a list of all tables | None |
describe_table |
View schema information for a table | table_name: Name of table |
export_query |
Export query results as CSV/JSON | query: SQL SELECT statement |
format: "csv" or "json" |
||
append_insight |
Add a business insight to memo | insight: Text of insight |
list_insights |
List all business insights | None |
For practical examples of how to use these tools with Claude, see Usage Examples.
To run the server in development mode:
npm run devTo watch for changes during development:
npm run watchMIT
暂无开放 Issues,或尚未同步最近议题。