Skip to main content
Glama
oliverhubtech-source

MCP Database Server

MCP Database Server

Pilar: Protocolos, Interoperabilidade & APIs
Status: Mes 1 - essencial

Servidor MCP em Python para expor schemas, queries seguras e stored procedures a clientes LLM.

Problema

LLMs precisam consultar bancos corporativos sem receber credenciais amplas nem liberdade para executar SQL destrutivo.

Related MCP server: DB Insights MCP Server

MVP

  • Servidor MCP com FastMCP

  • Listagem de schemas permitidos

  • Queries somente leitura

  • Allowlist de stored procedures

  • Auditoria de chamadas

Arquitetura

  • MCP server (mcp.server.MCPServer, tools registrados via @mcp.tool())

  • Schema registry (allowlist de tabelas/colunas, db.py)

  • Read-only authorizer (sqlite3.Connection.set_authorizer, security.py)

  • Audit logger (trilha em memoria de cada chamada de tool, audit.py)

Diagrama

flowchart LR
    A0[MCP client] --> A1[MCP server: list_tables / describe_table / run_readonly_query]
    A1 --> A2[SQLite authorizer: allowlist + read-only]
    A2 --> A3[SQLite: invoices]
    A1 --> A4[Audit log]

Stack

  • Python

  • mcp (SDK oficial do Model Context Protocol)

  • SQLite (sqlite3 da stdlib, com set_authorizer para o controle de acesso)

  • unittest

  • Docker Compose

Como executar

Implementacao real com o SDK oficial do MCP. O controle de acesso nao usa regex sobre o SQL (facil de burlar) - usa o set_authorizer do proprio SQLite, que aprova ou nega cada tabela/coluna lida e cada tipo de statement antes de qualquer linha rodar. Para rodar o servidor MCP:

python3.12 -m venv .venv && source .venv/bin/activate
pip install -e .
python -m mcp_database_server   # sobe o servidor MCP via stdio
python -m unittest discover -s tests

Testes

  • test_security.py: authorizer bloqueia INSERT/UPDATE/DELETE/DROP/ALTER, ATTACH, tabelas fora do allowlist (ex.: sqlite_master) e statements empilhados (SELECT 1; DROP TABLE ...).

  • test_server.py: logica de cada tool chamada direto (sem protocolo), incluindo que toda chamada gera um evento de auditoria.

  • test_integration.py: sobe python -m mcp_database_server como subprocesso de verdade e conversa com ele via mcp.client.stdio + ClientSession - prova que o servidor fala MCP, nao so que as funcoes Python funcionam.

Riscos e decisoes

  • SQL injection e permissao excessiva: resolvido via set_authorizer no nivel do driver, nao regex.

  • Uma unica conexao SQLite nao e thread-safe; o MCP server despacha cada tool call numa worker thread, entao ServerState.lock serializa o acesso (bug real encontrado e corrigido durante a implementacao, coberto por test_integration.py).

  • Ferramentas MCP retornam ValueError com mensagem clara para o cliente LLM em vez de vazar stack trace.

Proximos passos

  • Trocar SQLite por PostgreSQL via SQLAlchemy quando o dado for real.

  • Adicionar autenticacao/allowlist por cliente (hoje qualquer client MCP conectado tem acesso as tools).

  • Persistir o audit log fora do processo (hoje e so em memoria).

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response 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
    Provides secure, read-only access to Microsoft SQL Server with multi-layer protection, enabling safe query execution, schema discovery, and SQL script analysis through natural language.
    1
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to query SQL databases safely with read-only access, allowing schema discovery and SELECT queries while blocking writes and DDL operations.
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables LLM clients to query SQL databases via natural language with read-only, AST-validated, and capped queries, ensuring safety guarantees.
    2
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Provides read-only access to databases for MCP-compatible AI tools, allowing schema exploration and SELECT queries without exposing credentials or risking data changes.
    92
    3
    MIT

View all related MCP servers

Related MCP Connectors

  • Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.

  • Runtime permission, approval, and audit layer for AI agent tool execution.

  • Read-only access to your VortexIQ store data: audits, KPIs, alerts, Brand DNA, reports, Ask VIQ.

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/oliverhubtech-source/mcp-database-server'

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