dbhub
面向 Postgres、MySQL、SQL Server、Oracle、MariaDB、SQLite 的 Token 感知数据库 MCP 服务器。
MCP 服务会以你的权限运行代码或访问你的数据。安装前请先看项目主页与源码,只给必要的权限;密钥请自行填入,不要提交到仓库。
claude mcp add dbhub -e DSN='<你的DSN>' -e DB_TYPE='<你的DB_TYPE>' -e DB_HOST='<你的DB_HOST>' -e DB_PORT='<你的DB_PORT>' -e DB_USER='<你的DB_USER>' -e DB_PASSWORD='<你的DB_PASSWORD>' -e DB_NAME='<你的DB_NAME>' -e TRANSPORT='<你的TRANSPORT>' -e PORT='<你的PORT>' -e ID='<你的ID>' -e SSH_HOST='<你的SSH_HOST>' -e SSH_PORT='<你的SSH_PORT>' -e SSH_USER='<你的SSH_USER>' -e SSH_PASSWORD='<你的SSH_PASSWORD>' -e SSH_KEY='<你的SSH_KEY>' -e SSH_PASSPHRASE='<你的SSH_PASSPHRASE>' -e SSH_AUTH_SOCK='<你的SSH_AUTH_SOCK>' -- npx -y @bytebase/dbhub@1.5.0
{
"mcpServers": {
"dbhub": {
"command": "npx",
"args": [
"-y",
"@bytebase/dbhub@1.5.0"
],
"env": {
"DSN": "<你的DSN>",
"DB_TYPE": "<你的DB_TYPE>",
"DB_HOST": "<你的DB_HOST>",
"DB_PORT": "<你的DB_PORT>",
"DB_USER": "<你的DB_USER>",
"DB_PASSWORD": "<你的DB_PASSWORD>",
"DB_NAME": "<你的DB_NAME>",
"TRANSPORT": "<你的TRANSPORT>",
"PORT": "<你的PORT>",
"ID": "<你的ID>",
"SSH_HOST": "<你的SSH_HOST>",
"SSH_PORT": "<你的SSH_PORT>",
"SSH_USER": "<你的SSH_USER>",
"SSH_PASSWORD": "<你的SSH_PASSWORD>",
"SSH_KEY": "<你的SSH_KEY>",
"SSH_PASSPHRASE": "<你的SSH_PASSPHRASE>",
"SSH_AUTH_SOCK": "<你的SSH_AUTH_SOCK>"
}
}
}
}DSN(可选)·密钥 Database connection string (e.g., postgres://user:pass@host:5432/db)DB_TYPE(可选) Database type: postgres, mysql, mariadb, sqlserver, oracle, sqliteDB_HOST(可选) Database hostnameDB_PORT(可选) Database portDB_USER(可选) Database usernameDB_PASSWORD(可选)·密钥 Database passwordDB_NAME(可选) Database name or SQLite file pathTRANSPORT(可选) Transport mode: stdio or httpPORT(可选) HTTP server port (default: 8080)ID(可选) Instance identifier for tool namesSSH_HOST(可选) SSH server hostnameSSH_PORT(可选) SSH server port (default: 22)SSH_USER(可选) SSH usernameSSH_PASSWORD(可选)·密钥 SSH passwordSSH_KEY(可选) Path to SSH private keySSH_PASSPHRASE(可选)·密钥 SSH key passphraseSSH_AUTH_SOCK(可选) Path to SSH agent socket摘自项目自己的说明,具体以项目主页为准。
npx @bytebase/dbhub@latest --transport http --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
Also available as:
See the Installation Guide for all options, Command-Line Options for parameters, and Multi-Database Configuration for connecting several databases at once.