
[ 英文 | 中文 ]
db-query-mcp 是一个支持多种数据库查询和导出的 mcp 工具,具有以下特点:
https://github.com/user-attachments/assets/60771cda-8b52-41bd-90e3-523c836f6366
pip install db-query-mcp
ElasticSearch:
pip install "db-query-mcp[elasticsearch]"
从 GitHub 安装:
pip install git+https://github.com/NewToolAI/db-query-mcp
MySQL 需要额外依赖项:
pip install pymysql
PostgreSQL 需要额外依赖项:
pip install psycopg2-binary
对于其他数据库,请安装相应的连接包:
| 数据库 | 连接包 | 示例连接字符串 |
|---|---|---|
| SQLite | 内置 Python | sqlite:///example.db |
| MySQL | pymysql 或 mysql-connector-python | mysql+pymysql://user:password@localhost/dbname |
| PostgreSQL | psycopg2 或 psycopg2-binary | postgresql://user:password@localhost:5432/dbname |
| Oracle | cx_Oracle | oracle+cx_oracle://user:password@hostname:1521/sidname |
| SQL Server | pyodbc 或 pymssql | mssql+pyodbc://user:password@hostname/dbname |
注意:对于某些客户端,例如 Cursor,一次只能运行一个 db-query-mcp 服务器。
{
"mcpServers": {
"sqlite_db_mcp": {
"command": "uvx",
"args": [
"db-query-mcp",
"--db",
"sqlite",
"--uri",
"sqlite:///sqlite_company.db"
]
}
}
}
{
"mcpServers": {
"es_db_mcp": {
"command": "uvx",
"args": [
"db-query-mcp",
"--db",
"elasticsearch",
"--uri",
"https://user:password@localhost:9200?index=test_data_index&ca_certs=/home/user/http_ca.crt"
]
}
}
}
{
"mcpServers": {
"sqlite_db_mcp": {
"command": "db-query-mcp",
"args": [
"--db",
"sqlite",
"--uri",
"sqlite:///sqlite_company.db"
]
}
}
}
{
8"mcpServers": {
"es_db_mcp": {
"command": "db-query-mcp",
"args": [
"--db",
"elasticsearch",
"--uri",
"https://user:password@localhost:9200?index=test_data_index&ca_certs=/home/user/http_ca.crt"
]
}
}
}