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 pytest如果 uv 尚不在 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:列出表或检查单个表execute_query:执行一个安全的只读SELECTexplain_query:返回原生执行计划validate_schema:报告缺失的主键和未索引的外键suggest_index:根据表元数据或查询计划建议索引migration_context:为客户端迁移生成提供模式上下文validate_migration:验证提议的UP和DOWN脚本而不执行它们
每次查询执行和解释都经过安全层。变更语句、注释和多个语句都会被拒绝。查询结果默认最多返回 100 行。
测试
uv run pytest测试套件使用临时 SQLite 数据库,不需要外部凭据或正在运行的数据库服务器。
远程部署
有关 FastMCP Horizon 部署步骤、远程数据库要求和身份验证清单,请参阅 DEPLOYMENT.md。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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.539MIT
- AlicenseNot gradedqualityAmaintenanceRead-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.22MIT
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/AYUSH-148/DB-Explorer-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server