Skip to main content
Glama

DBHubは、モデルコンテキストプロトコル(MCP)サーバーインターフェースを実装した汎用データベースゲートウェイです。このゲートウェイにより、MCP対応クライアントは様々なデータベースに接続し、情報を参照することができます。

+------------------+ +--------------+ +------------------+ | | | | | | | | | | | | | Claude Desktop +--->+ +--->+ PostgreSQL | | | | | | | | Cursor +--->+ DBHub +--->+ SQL Server | | | | | | | | Other MCP +--->+ +--->+ SQLite | | Clients | | | | | | | | +--->+ MySQL | | | | | | | | | | +--->+ MariaDB | | | | | | | | | | +--->+ Oracle | | | | | | | +------------------+ +--------------+ +------------------+ MCP Clients MCP Server Databases

デモ SSE エンドポイント

https://demo.dbhub.ai/sse はサンプルの従業員データベースに接続します。Cursor または MCP Inspector でデータベースを指定して、実際の動作を確認できます。

mcp-inspector

Related MCP server: Supabase MCP Server

サポートされているマトリックス

データベースリソース

リソース名

URI形式

PostgreSQL

MySQL

マリアDB

SQL サーバー

SQLite

オラクル

スキーマ

db://schemas

スキーマ内のテーブル

db://schemas/{schemaName}/tables

スキーマ内のテーブル構造

db://schemas/{schemaName}/tables/{tableName}

テーブル内のインデックス

db://schemas/{schemaName}/tables/{tableName}/indexes

スキーマ内の手順

db://schemas/{schemaName}/procedures

スキーマ内の手順の詳細

db://schemas/{schemaName}/procedures/{procedureName}

データベースツール

道具

コマンド名

PostgreSQL

MySQL

マリアDB

SQL サーバー

SQLite

オラクル

SQLを実行する

execute_sql

リストコネクタ

list_connectors

プロンプト機能

プロンプト

コマンド名

PostgreSQL

MySQL

マリアDB

SQL サーバー

SQLite

オラクル

SQLを生成する

generate_sql

DB要素を説明する

explain_db

インストール

ドッカー

# PostgreSQL example docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport sse \ --port 8080 \ --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
# Demo mode with sample employee database docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport sse \ --port 8080 \ --demo
# Oracle example docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub \ --transport sse \ --port 8080 \ --dsn "oracle://username:password@localhost:1521/service_name"
# Oracle example with thick mode for connecting to 11g or older docker run --rm --init \ --name dbhub \ --publish 8080:8080 \ bytebase/dbhub-oracle-thick \ --transport sse \ --port 8080 \ --dsn "oracle://username:password@localhost:1521/service_name"

国立博物館

# PostgreSQL example npx @bytebase/dbhub --transport sse --port 8080 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
# Demo mode with sample employee database npx @bytebase/dbhub --transport sse --port 8080 --demo

注: デモ モードには、従業員、部門、給与などのテーブルを含むバンドルされた SQLite サンプル「従業員」データベースが含まれています。

クロードデスクトップ

クロード・デスクトップ

// claude_desktop_config.json { "mcpServers": { "dbhub-postgres-docker": { "command": "docker", "args": [ "run", "-i", "--rm", "bytebase/dbhub", "--transport", "stdio", "--dsn", // Use host.docker.internal as the host if connecting to the local db "postgres://user:password@host.docker.internal:5432/dbname?sslmode=disable" ] }, "dbhub-postgres-npx": { "command": "npx", "args": [ "-y", "@bytebase/dbhub", "--transport", "stdio", "--dsn", "postgres://user:password@localhost:5432/dbname?sslmode=disable" ] }, "dbhub-demo": { "command": "npx", "args": ["-y", "@bytebase/dbhub", "--transport", "stdio", "--demo"] } } }

カーソル

カーソル

使用法

SSL接続

DSN 文字列のsslmodeパラメータを使用して SSL モードを指定できます。

データベース

sslmode=disable

sslmode=require

デフォルトのSSL動作

PostgreSQL

証明書の検証

MySQL

証明書の検証

マリアDB

証明書の検証

SQL サーバー

証明書の検証

オラクル

該当なし(Oracle クライアント構成を使用)

SQLite

N/A (ファイルベース)

SSL モード オプション:

  • sslmode=disable : すべてのSSL/TLS暗号化が無効になります。データはプレーンテキストで送信されます。

  • sslmode=require : 接続は暗号化されますが、サーバーの証明書は検証されません。パケットスニッフィングに対する保護は提供されますが、中間者攻撃に対する保護は提供されません。信頼できる自己署名CAの場合に使用できます。

sslmodeを指定しないと、ほとんどのデータベースはデフォルトで証明書検証を実行し、最高レベルのセキュリティを実現します。

使用例:

# Disable SSL postgres://user:password@localhost:5432/dbname?sslmode=disable # Require SSL without certificate verification postgres://user:password@localhost:5432/dbname?sslmode=require # Standard SSL with certificate verification (default) postgres://user:password@localhost:5432/dbname

読み取り専用モード

DBHub を読み取り専用モードで実行できます。これにより、SQL クエリの実行が読み取り専用操作に制限されます。

# Enable read-only mode npx @bytebase/dbhub --readonly --dsn "postgres://user:password@localhost:5432/dbname"

読み取り専用モードでは、読み取り専用の SQL 操作のみが許可されます。

これにより、実稼働データベースに接続するときにセキュリティがさらに強化されます。

データベース接続を構成する

テスト用にサンプル従業員データベースを使用して、DBHub をデモ モードで使用できます。

npx @bytebase/dbhub --demo

実際のデータベースでは、データベースソース名(DSN)が必要です。これはいくつかの方法で指定できます。

  • コマンドライン引数(最高優先度):

    npx @bytebase/dbhub --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
  • 環境変数(第2優先度):

    export DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @bytebase/dbhub
  • 環境ファイル(優先度3):

    • 開発の場合: DSNで.env.localを作成します

    • 本番環境の場合: DSN GXP14 で.envを作成します。

[!警告] Dockerで実行する場合、ホストマシンで実行されているデータベースに接続するには、 localhostではなくhost.docker.internalを使用してください。例: mysql://user:password@host.docker.internal:3306/dbname

DBHub は次のデータベース接続文字列形式をサポートしています。

データベース

DSNフォーマット

MySQL

mysql://[user]:[password]@[host]:[port]/[database]

mysql://user:password@localhost:3306/dbname?sslmode=disable

マリアDB

mariadb://[user]:[password]@[host]:[port]/[database]

mariadb://user:password@localhost:3306/dbname?sslmode=disable

PostgreSQL

postgres://[user]:[password]@[host]:[port]/[database]

postgres://user:password@localhost:5432/dbname?sslmode=disable

SQL サーバー

sqlserver://[user]:[password]@[host]:[port]/[database]

sqlserver://user:password@localhost:1433/dbname?sslmode=disable

SQLite

sqlite:///[path/to/file]

または

sqlite::memory:

sqlite:///path/to/database.db

sqlite:C:/Users/YourName/data/database.db (windows)

または

sqlite::memory:

オラクル

oracle://[user]:[password]@[host]:[port]/[service_name]

oracle://username:password@localhost:1521/service_name?sslmode=disable

オラクル

「NJS-138: このデータベース サーバー バージョンへの接続は、Thin モードの node-oracledb ではサポートされていません」というエラーが表示される場合は、以下に説明するように Thick モードを使用する必要があります。

ドッカー

bytebase bytebase/dbhub docker イメージの代わりにbytebase/dbhub-oracle-thick使用します。

npx
  1. お使いのプラットフォーム用のOracle Instant Clientをダウンロードしてインストールします

  2. ORACLE_LIB_DIR環境変数を Oracle Instant Client のパスに設定します。

# Set environment variable to Oracle Instant Client directory export ORACLE_LIB_DIR=/path/to/instantclient_19_8 # Then run DBHub npx @bytebase/dbhub --dsn "oracle://username:password@localhost:1521/service_name"

SQL サーバー

追加のクエリパラメータ:

認証

  • authentication=azure-active-directory-access-token 。Azureから実行する場合にのみ適用されます。DefaultAzureCredential 参照してください。

輸送

  • stdio (デフォルト) - Claude Desktop などのツールと直接統合する場合:

    npx @bytebase/dbhub --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"
  • sse - ブラウザおよびネットワーククライアントの場合:

    npx @bytebase/dbhub --transport sse --port 5678 --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

コマンドラインオプション

オプション

説明

デフォルト

デモ

サンプル従業員データベースを使用してデモモードで実行する

false

dsn

データベース接続文字列

デモモードでない場合は必須

輸送

トランスポートモード:

stdio

または

sse

stdio

ポート

HTTP サーバー ポート (

--transport=sse

を使用する場合にのみ適用されます)

8080

読み取り専用

SQL 実行を読み取り専用操作に制限する

false

デモモードでは、従業員、部門、役職、給与、部門従業員、部門マネージャーのテーブルを含むサンプル従業員データベースがロードされたインメモリSQLiteデータベースを使用します。サンプルデータベースには、テーブル作成、データロード、テスト用のSQLスクリプトが含まれています。

発達

  1. 依存関係をインストールします:

    pnpm install
  2. 開発モードで実行:

    pnpm dev
  3. 生産用にビルド:

    pnpm build pnpm start --transport stdio --dsn "postgres://user:password@localhost:5432/dbname?sslmode=disable"

テスト

このプロジェクトではテストに Vitest を使用します。

  • テストを実行: pnpm test

  • ウォッチモードでテストを実行する: pnpm test:watch

コミット前フック(開発者向け)

プロジェクトには、各コミットの前にテストを自動的に実行するための事前コミットフックが含まれています。

  1. リポジトリのクローンを作成した後、コミット前のフックを設定します。

    ./scripts/setup-husky.sh
  2. これにより、コミットを作成するたびにテスト スイートが自動的に実行され、テストを中断させるコミットが防止されます。

MCP Inspectorでデバッグする

標準入出力

# PostgreSQL example TRANSPORT=stdio DSN="postgres://user:password@localhost:5432/dbname?sslmode=disable" npx @modelcontextprotocol/inspector node /path/to/dbhub/dist/index.js

南南東

# Start DBHub with SSE transport pnpm dev --transport=sse --port=8080 # Start the MCP Inspector in another terminal npx @modelcontextprotocol/inspector

DBHubサーバーの/sseエンドポイントに接続する

寄稿者

スターの歴史

星の歴史チャート

-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bytebase/dbhub'

If you have feedback or need assistance with the MCP directory API, please join our Discord server