DB-Explorer-MCP
Database Explorer MCP
リレーショナルデータベースを探索・安全にクエリするためのFastMCPサーバーです。ローカル開発用データベースはSQLiteです。SQLAlchemyはドライバを通じてPostgreSQLやMySQLにも対応しています。
アーキテクチャ
MCPクライアントは自然言語による推論を行い、SQLを生成します。このサーバーはデータベースツールを公開し、読み取り専用クエリを検証・実行し、構造化された結果を返します。
MCP client LLM -> FastMCP tools -> safety layer -> SQLAlchemy -> databaseこのサーバーはAnthropicを呼び出さないため、Anthropic APIキーは不要です。
Related MCP server: nl2sql-mcp
セットアップ
uvをインストールし、このディレクトリで次を実行します:
uv sync
uv run python tests/seed_test_db.py
uv run pytestuvがまだPATHにない場合は、次を使用します:
py -m uv sync
py -m uv run pytestデフォルトのデータベースは次のとおりです:
sqlite:///sample.db別のデータベースを使用するには、サーバーを起動する前にDATABASE_URLを設定します。例:
$env:DATABASE_URL = "sqlite:///C:/data/example.db"
$env:DATABASE_URL = "postgresql+psycopg2://user:password@localhost:5432/example"
$env:DATABASE_URL = "mysql+pymysql://user:password@localhost:3306/example"MCPサーバーを実行する
uv run server.py共有可能なVS Code MCP設定は.vscode/mcp.jsonにあります。stdio経由でサーバーを起動し、MCP互換クライアントやInspectorで使用できます。
リモートホスティングの場合は、Streamable HTTPを使用します:
$env:MCP_TRANSPORT = "streamable-http"
$env:MCP_HOST = "0.0.0.0"
$env:MCP_PORT = "8000"
uv run server.pyリモートデプロイメントは認証を提供し、シークレット設定を通じてDATABASE_URLを保護する必要があります。
ツール
explore_schema:テーブルの一覧表示または1つのテーブルの調査execute_query:安全な読み取り専用SELECTを1回実行explain_query:ネイティブ実行プランを返すvalidate_schema:欠落した主キーとインデックスなし外部キーを報告suggest_index:テーブルメタデータまたはクエリプランからインデックスを提案migration_context:クライアント側のマイグレーション生成用のスキーマコンテキストを提供validate_migration:提案されたUPスクリプトとDOWNスクリプトを実行せずに検証
すべてのクエリ実行と説明はセーフティレイヤーを通過します。変更ステートメント、コメント、複数ステートメントは拒否されます。クエリ結果はデフォルトで最大100行です。
テスト
uv run pytestテストスイートは一時的なSQLiteデータベースを使用するため、外部認証情報や実行中のデータベースサーバーは不要です。
リモートデプロイ
FastMCP Horizonのデプロイ手順、リモートデータベースの要件、認証チェックリストについては、DEPLOYMENT.mdを参照してください。
Available Tools
7 toolsexecute_queryB
Execute one validated, read-only SQL SELECT query.
Inputs: sql (required), row_limit. Returns: object
explain_queryA
Return the database execution plan for one safe SELECT query.
Inputs: sql (required). Returns: object
explore_schemaA
Explore database tables, columns, keys, indexes, and sample rows.
Inputs: table_name, include_sample_data. Returns: object
migration_contextB
Return schema context for client-side migration generation.
Inputs: no named parameters. Returns: object
suggest_indexB
Suggest indexes from a query plan or table foreign-key metadata.
Inputs: query, table_name. Returns: object
validate_migrationA
Validate migration scripts without executing them.
Inputs: up_sql (required), down_sql (required). Returns: object
validate_schemaC
Check tables for missing primary keys and unindexed foreign keys.
Inputs: table_name. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools have distinct purposes: exploring, executing, explaining, validating, and suggesting indexes are clearly separate. The main overlap risk is between explore_schema and migration_context, since both provide schema context, but their intended use cases differ enough to avoid serious confusion.
Six of seven tools follow a clean verb_noun pattern (explore_schema, execute_query, explain_query, validate_schema, suggest_index, validate_migration). migration_context breaks the pattern by being a noun phrase, but the overall naming style remains predictable and readable.
With 7 tools, the server is well-scoped for the stated purpose of database exploration, query execution, and migration validation. Each tool addresses a meaningful workflow step without unnecessary bloat.
The toolset covers the core read-only database workflows: schema inspection, query validation/execution/explanation, structural tenant-focused checks, index suggestions, and migration validation. No obvious dead-end exists for the server's stated purpose.
Maintenance
Related MCP Connectors
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Draxlr's remote MCP server connects AI assistants to your SQL databases and dashboards. Explore schemas, run read-only queries, manage saved queries and dashboards, and export results, all with row-level security so each user sees only their own data.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceAn MCP server that provides safe, read-only access to SQLite databases through MCP. This server is built with the FastMCP framework, which enables LLMs to explore and query SQLite databases with built-in safety features and query validation.107-
- FlicenseNot gradedqualityFmaintenanceA production-ready MCP server that transforms natural language into safe, executable SQL queries with multi-database support and intelligent schema analysis.1-
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for PostgreSQL that enables safe database introspection and querying via natural language.MIT
- FlicenseAqualityCmaintenanceRead-only Text-to-SQL MCP server for PostgreSQL and MySQL that lets users query databases using natural language, with robust multi-layer safety guarantees against writes.6-