
Demo SSE Endpoint

2025.04.13
251
TypeScript数据库网关数据库管理数据库
DBHub是一个实现模型上下文协议(MCP)服务器接口的通用数据库网关。该网关允许MCP兼容的客户端连接和探索不同的数据库。它支持多种数据库资源查询、数据库工具操作以及提示功能,适用于开发者和数据分析师进行数据库管理和查询。
View on GitHub
Overview
基本能力
产品定位
DBHub是一个通用的数据库网关,通过实现模型上下文协议(MCP)服务器接口,为MCP兼容的客户端提供连接和探索不同数据库的能力。
核心功能
- 数据库资源查询:支持查询数据库的schema、表结构、索引、存储过程等资源。
- 数据库工具:提供执行查询和列出连接器等工具。
- 提示功能:支持生成SQL和解释数据库元素的功能。
- 多数据库支持:支持PostgreSQL、MySQL、SQL Server和SQLite等多种数据库。
适用场景
- 数据库管理:开发者可以通过DBHub管理和查询不同数据库的结构和数据。
- 数据分析:数据分析师可以使用DBHub生成SQL查询并解释数据库元素。
- 开发测试:提供demo模式,方便开发者进行测试和学习。
工具列表
- Execute Query (
run_query
):执行SQL查询。 - List Connectors (
list_connectors
):列出数据库连接器。 - Generate SQL (
generate_sql
):生成SQL语句。 - Explain DB Elements (
explain_db
):解释数据库元素。
常见问题解答
- 如何连接本地数据库:在Docker中使用
host.docker.internal
代替localhost
。 - 如何运行demo模式:使用
--demo
参数启动DBHub。 - 支持的数据库类型:PostgreSQL、MySQL、SQL Server和SQLite。
使用教程
使用依赖
- 确保已安装Docker或Node.js环境。
安装教程
Docker安装
# PostgreSQL示例
docker run --rm --init \
--name dbhub \
--publish 8080:8080 \
bytebase/dbhub \
--transport sse \
--port 8080 \
--dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
NPM安装
# PostgreSQL示例
npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname"
调试方式
使用MCP Inspector调试
# PostgreSQL示例
TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js
SSE模式调试
# 启动DBHub
pnpm dev --transport=sse --port=8080
# 启动MCP Inspector
npx @modelcontextprotocol/inspector