Skip to main content
Glama
MCP SQL Server

MCP SQL Server

by harryvaldez

MCP SQL Server

Remote FastMCP server for dual SQL Server 2019 instances with strong read-only controls, rate limiting, and diagnostics.

What This Repository Provides

  • FastMCP + FastAPI service exposing SQL tools over HTTP at /mcp

  • Dual-instance SQL Server 2019 support (primary and secondary)

  • Read-only SQL policy controls with denylist (13 patterns: DDL, DML, DCL, system procedures) and allowlist config

  • Redis or local rate limiting with per-actor and global limits

  • Security-oriented output handling (sensitive field redaction)

  • Diagnostics endpoints for runtime posture and tool usage

  • Docker runtime and compose files for local and remote operation

Related MCP server: mcp-sql-multi

Important Documentation

Repository Structure

  • src: service runtime, tool registration, middleware, diagnostics

  • config: instance config, policy, and rate-limit settings

  • policy: SQL allowlist and denylist definitions

  • docker: Dockerfile and compose files

  • tests: unit tests

  • testing: integration and operational test harnesses

  • docs: tool catalog, runbooks, and run instructions

  • docs/runbooks/scaling-strategy.md: runbook for scaling and load-validation operations

  • docs/runbooks/security-maintenance.md: runbook for security posture checks and maintenance

  • docs/access-levels-and-controlled-write.md: access model and controlled-write enforcement reference

Quick Start (Local)

  1. Create and activate a Python 3.11+ virtual environment.

  2. Install dependencies:

Windows (PowerShell):

pip install -e .[dev]

Linux/macOS:

pip install -e '.[dev]'
  1. Copy environment and config templates:

Windows (PowerShell):

Copy-Item .env.example .env

Linux/macOS:

cp .env.example .env
  1. Configure instances in config/instances.yaml (this repository already includes it; no instances.yaml.example file is provided). For parity with the .env.example -> .env pattern above, use the existing file as your local runtime file and use config/instances.runtime.example.yaml as the format/key reference.

  2. Run the service:

python -m src.server
  1. Validate endpoints:

Primary rollout verification checks:

  • /diagnostics/health: confirms service and instance connectivity.

  • /diagnostics/security: confirms auth mode, required scope count, group-authorization posture, and registered tool inventory.

  • /diagnostics/pool: confirms per-instance SQL pool sizing and reuse counters.

Docker Runtime

Use the runtime compose flow documented in docs/run-mcp-server-with-docker.md.

Controlled-write policy is enforced from config/runtime-policy.yaml. The file policy/sql-allowlist.yaml is a review/reference mirror and is not loaded as a runtime policy source.

docker compose -f docker/docker-compose.runtime.yml up -d

Operational Runbooks

Testing

Run unit tests:

pytest -q

Current validation snapshot:

Security Notes

  • Do not commit real secrets.

  • Keep .env local only.

  • Prefer least-privilege SQL credentials.

  • See SECURITY.md for reporting and hardening guidance.

Contributing

See CONTRIBUTING.md for branch, PR, and test expectations.

Release and CI

  • CI runs on pull requests and pushes to master/main.

  • Release tags follow v* (example: v1.2).

  • Latest release notes: docs/release-notes-v1.4.0.md

CMMI-Oriented Platform Integration

This repository includes GitHub-native process controls aligned to CMMI implementation patterns:

  • Requirements management: requirement issue template and PR traceability sections

  • Configuration management: branch protection, CODEOWNERS, signed commits, and protected release tags

  • Verification and validation: CI checks, PR gates, and traceability check workflow

  • Measurement and analysis: scheduled traceability matrix generation

  • Audit trail: issue/PR history, commit history, and workflow logs retained in GitHub

Artifacts:

  • .github/ISSUE_TEMPLATE/requirement.yml

  • .github/workflows/traceability-check.yml

  • .github/workflows/traceability-matrix.yml

  • docs/traceability-matrix.md

License

Licensed under the MIT License. See LICENSE.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Read-only SQL Server MCP server enabling safe database queries, table listing, and schema inspection with built-in security protections.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables querying multiple SQL Server, Azure SQL, or Synapse databases through a single MCP interface, with support for read-only targets and various authentication methods.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables read-only SQL querying and schema inspection across MSSQL, PostgreSQL, and MySQL databases via MCP tools.
      ISC
    • A
      license
      A
      quality
      C
      maintenance
      Enables MCP clients to securely query databases, list tables, inspect table schemas, and test connections across Oracle, SQL Server, MySQL, PostgreSQL, and SQLite using read-only SQL tools.
      4
      MIT