Skip to main content
Glama
AYUSH-148

DB-Explorer-MCP

by AYUSH-148

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:执行一个安全的只读 SELECT

  • explain_query:返回原生执行计划

  • validate_schema:报告缺失的主键和未索引的外键

  • suggest_index:根据表元数据或查询计划建议索引

  • migration_context:为客户端迁移生成提供模式上下文

  • validate_migration:验证提议的 UPDOWN 脚本而不执行它们

每次查询执行和解释都经过安全层。变更语句、注释和多个语句都会被拒绝。查询结果默认最多返回 100 行。

测试

uv run pytest

测试套件使用临时 SQLite 数据库,不需要外部凭据或正在运行的数据库服务器。

远程部署

有关 FastMCP Horizon 部署步骤、远程数据库要求和身份验证清单,请参阅 DEPLOYMENT.md

Install Server
F
license - not found
A
quality
A
maintenance

Maintenance

Maintainers
7hResponse time
Release cycle
Releases (12mo)
Commit activity

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

  • F
    license
    Not graded
    quality
    D
    maintenance
    An 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
  • F
    license
    Not graded
    quality
    F
    maintenance
    A production-ready MCP server that transforms natural language into safe, executable SQL queries with multi-database support and intelligent schema analysis.
    1
  • A
    license
    Not graded
    quality
    D
    maintenance
    A read-only MCP server for PostgreSQL that enables safe database introspection and querying via natural language.
    539
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Read-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.
    22
    MIT

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

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/AYUSH-148/DB-Explorer-MCP'

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