MC

MCP Server: Fast SQL Server, SQLite, PostgreSQL Access

Accelerate database workflows with MCP server for fast, secure access to SQL Server, SQLite and PostgreSQL—deploy, query and manage in seconds.

Quick Install
npx -y @executeautomation/mcp-database-server

Overview

MCP Server is a lightweight service that provides fast, secure, and consistent access to SQL Server, SQLite and PostgreSQL databases. It exposes a simple API and connection model so developers and automation agents can query and manage databases without embedding multiple client drivers or exposing raw credentials. The server is designed to be easy to deploy (Docker or binary), fast in execution, and suitable for integration with LLMs and other tools that consume structured database context.

By centralizing database connections and query handling, MCP Server simplifies common tasks: run ad-hoc queries, inspect schemas, enforce row limits, and audit or restrict SQL usage. This reduces friction during development, testing, CI workflows, or when wiring a database into language-model-driven automations.

Features

  • Multi-engine support: SQL Server (MSSQL), PostgreSQL, SQLite
  • Simple JSON/HTTP API for queries and management
  • Centralized connection configuration (connection strings or files)
  • Connection pooling and lightweight execution for low-latency queries
  • Query parameterization and row-limiting to reduce risk and response size
  • Schema introspection for tooling and LLM context
  • Docker-friendly deployment and single-binary operation
  • Audit-ready logging and optional TLS for secure transport
  • Small footprint suitable for local development or deployment in cloud/on-prem

Installation / Configuration

Below are common ways to run the server: via Docker and as a local binary. Replace placeholders with your real connection strings and file paths.

  1. Run with Docker
# Run the MCP server container (example)
docker run --rm -p 8080:8080 \
  -e MCP_PORT=8080 \
  -e MCP_CONFIG=/config/mcp-config.yml \
  -v $(pwd)/mcp-config.yml:/config/mcp-config.yml:ro \
  executeautomation/mcp-database-server:latest
  1. Run a local binary
# Download the release binary, make executable and run
chmod +x mcp-database-server
./mcp-database-server --config ./mcp-config.yml --port 8080
  1. Example configuration (YAML)
# mcp-config.yml (example)
server:
  port: 8080
  tls: false

connections:
  main_postgres:
    type: postgres
    conn: "postgres://user:[email protected]:5432/dbname?sslmode=disable"
    readonly: false
    maxRows: 1000

  local_sqlite:
    type: sqlite
    filepath: "./data/dev.db"
    readonly: true
    maxRows: 500

  sqlserver_analytics:
    type: mssql
    conn: "Server=tcp:sqlserver.example.com,1433;Database=analytics;User Id=user;Password=pass;"
    readonly: true
    maxRows: 2000

Environment variables are commonly supported (e.g., MCP_CONFIG, MCP_PORT) so you can inject secrets via your deployment pipeline or container environment.

Available Resources

  • GitHub repository (source, releases, examples): https://github.com/executeautomation/mcp-database-server
  • Example config files and sample projects are typically included in the repo’s examples/ directory
  • MCP (Model Context Protocol) specification and integration notes (check repo docs for details)
  • Use standard CLI tools for testing: curl, HTTPie, Postman; and DB clients for direct connections when needed

Supported engines and connection examples:

EngineConnection string example
PostgreSQLpostgres://user:pass@host:5432/dbname
SQLitefilepath: ./data/app.db
SQL ServerServer=tcp:host,1433;Database=db;User Id=…;Password=…;

Use Cases

  • Rapid prototyping with LLMs: expose a sanitized, read-only view of production or dev schemas for language models to generate queries or summaries without distributing credentials.
  • Local development: run a single MCP server that proxies multiple local databases (sqlite files and remote DBs) and provides a unified API to tools.
  • CI / automation tasks: let pipelines run SQL checks, migrations, or data validations via the server’s API instead of embedding driver logic in scripts.
  • Ad-hoc analytics and reporting: centralize small analytics endpoints for tooling and dashboards; leverage connection pooling and row-limits to control resource usage.
  • Audit and governance: consolidate query logging and apply global restrictions (max rows, read-only flags) across environments.

Example: Run a query with curl (JSON API)

curl -X POST "http://localhost:8080/v1/query" \
  -H "Content-Type: application/json" \
  -d '{
    "connection": "main_postgres",
    "sql": "SELECT id, name, created_at FROM users WHERE created_at >= $1 LIMIT 50",
    "params": ["2025-01-01"]
  }'

Typical response (JSON):

{
  "status": "ok",
  "columns": ["id", "name", "created_at"],
  "rows": [
    [1, "Alice", "2025-01-02T12:34:56Z"],
    [2, "Bob", "2025-01-03T09:10:11Z"]
  ],
  "rowCount": 2
}

Notes and best practices

  • Keep secrets out of version control: use environment variables or secret managers for production credentials.
  • Use read-only connections for LLM-driven queries to reduce risk.
  • Use row limits and parameterized queries to prevent excessive data transfer and SQL injection.
  • Review the repository README and the examples directory for exact API details and additional configuration options.

For source, issues and contribution instructions,