Skip to main content
Glama
oliverhubtech-source

MCP Database Server

MCP Database Server

Pillar: Protocols & Interoperability
Status: Month 1 - essential

Python MCP server to expose schemas, safe queries, and stored procedures to LLM clients.

Problem

LLMs need to consult corporate databases without receiving broad credentials or the freedom to execute destructive SQL.

Related MCP server: DB Insights MCP Server

MVP

  • MCP server with FastMCP

  • Listing of allowed schemas

  • Read-only queries

  • Allowlist of stored procedures

  • Audit of calls

Architecture

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

  • Schema registry (allowlist of tables/columns, db.py)

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

  • Audit logger (trail in memory of each tool call, audit.py)

Diagram

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 (official Model Context Protocol SDK)

  • SQLite (sqlite3 from the stdlib, with set_authorizer for access control)

  • unittest

  • Docker Compose

How to run

Real implementation with the official MCP SDK. Access control does not use regex over SQL (easy to bypass) — it uses SQLite's own set_authorizer, which approves or denies each table/column read and each statement type before any row runs. To run the MCP server:

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

Tests

  • test_security.py: authorizer blocks INSERT/UPDATE/DROP/ALTER, ATTACH, tables outside the allowlist (e.g., sqlite_master), and stacked statements (SELECT 1; DROP TABLE ...).

  • test_server.py: logic of each tool called directly (without protocol), including that every call generates an audit event.

  • test_integration.py: starts python -m mcp_database_server as a real subprocess and talks to it via mcp.client.stdio + ClientSession — proves the server actually speaks MCP, not just that the Python functions work.

Risks and decisions

  • SQL injection and excessive permissions: solved via set_authorizer at the driver level, not regex.

  • A single SQLite connection is not thread-safe; the MCP server dispatches each tool call into a worker thread, so ServerState.lock serializes access (real bug found and fixed during implementation, covered by test_integration.py).

  • MCP tools return ValueError with a clear message to the LLM client instead of leaking a stack trace.

Next steps

  • Replace SQLite with PostgreSQL via SQLAlchemy when real data is involved.

  • Add per-client authentication/allowlist (today any connected MCP client has access to the tools).

  • Persist the audit log outside the process (today it is only in memory).

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