MCP Database Server
MCP Database Server
Pilar: Protocolos, Interoperabilidad y APIs
Estado: Mes 1 - esencial
Servidor MCP en Python para exponer esquemas, consultas seguras y procedimientos almacenados a clientes LLM.
Problema
Los LLM necesitan consultar bases de datos corporativas sin recibir credenciales amplias ni libertad para ejecutar SQL destructivo.
Related MCP server: DB Insights MCP Server
MVP
Servidor MCP con FastMCP
Listado de esquemas permitidos
Consultas de solo lectura
Lista blanca de procedimientos almacenados
Auditoría de llamadas
Arquitectura
Servidor MCP (
mcp.server.MCPServer, herramientas registradas vía@mcp.tool())Registro de esquemas (lista blanca de tablas/columnas,
db.py)Autorizador de solo lectura (
sqlite3.Connection.set_authorizer,security.py)Registro de auditoría (rastro en memoria de cada llamada de herramienta,
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 del Model Context Protocol)SQLite (
sqlite3de la stdlib, conset_authorizerpara el control de acceso)unittest
Docker Compose
Cómo ejecutar
Implementación real con el SDK oficial del MCP. El control de acceso no usa
regex sobre el SQL (fácil de burlar) - usa el set_authorizer del propio
SQLite, que aprueba o niega cada tabla/columna leída y cada tipo de sentencia
antes de que cualquier línea se ejecute. Para ejecutar el 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 testsPruebas
test_security.py: el autorizador bloquea INSERT/UPDATE/DELETE/DROP/ALTER, ATTACH, tablas fuera de la lista blanca (ej.:sqlite_master) y sentencias apiladas (SELECT 1; DROP TABLE ...).test_server.py: lógica de cada herramienta llamada directamente (sin protocolo), incluyendo que cada llamada genera un evento de auditoría.test_integration.py: levantapython -m mcp_database_servercomo subproceso real y conversa con él víamcp.client.stdio+ClientSession- prueba que el servidor habla MCP, no solo que las funciones Python funcionan.
Riesgos y decisiones
Inyección SQL y permiso excesivo: resuelto vía
set_authorizera nivel del driver, no regex.Una única conexión SQLite no es segura para hilos; el servidor MCP despacha cada llamada de herramienta en un hilo de trabajo, por lo que
ServerState.lockserializa el acceso (bug real encontrado y corregido durante la implementación, cubierto portest_integration.py).Las herramientas MCP devuelven
ValueErrorcon un mensaje claro para el cliente LLM en lugar de filtrar un stack trace.
Próximos pasos
Cambiar SQLite por PostgreSQL vía SQLAlchemy cuando los datos sean reales.
Añadir autenticación/lista blanca por cliente (hoy cualquier cliente MCP conectado tiene acceso a las herramientas).
Persistir el registro de auditoría fuera del proceso (hoy es solo en 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