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 (
sqlite3da stdlib, comset_authorizerpara 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 testsTestes
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: sobepython -m mcp_database_servercomo subprocesso de verdade e conversa com ele viamcp.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_authorizerno 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.lockserializa o acesso (bug real encontrado e corrigido durante a implementacao, coberto portest_integration.py).Ferramentas MCP retornam
ValueErrorcom 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).
This server cannot be installed
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 gradedqualityDmaintenanceProvides 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
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to query SQL databases safely with read-only access, allowing schema discovery and SELECT queries while blocking writes and DDL operations.
- AlicenseNot gradedqualityBmaintenanceEnables LLM clients to query SQL databases via natural language with read-only, AST-validated, and capped queries, ensuring safety guarantees.2MIT
- AlicenseNot gradedqualityBmaintenanceProvides read-only access to databases for MCP-compatible AI tools, allowing schema exploration and SELECT queries without exposing credentials or risking data changes.923MIT
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.
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/oliverhubtech-source/mcp-database-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server