Skip to main content
Glama
MCP SQL Connector

MCP SQL Connector

by sruthir28

MCP SQL Connector

An MCP server that lets Claude query SQLite databases. Ask questions in natural language and Claude translates them into SQL queries.

Tools

Tool

What it does

list_tables

Show all tables in the database

describe_table

Show columns and types for a table

query

Run a read-only SQL SELECT query

summarize_table

Get row count + sample rows

Related MCP server: mcp-sqlite-insights

Safety

  • Database is opened in read-only mode (mode=ro) at the driver level

  • Only SELECT and WITH (CTE) queries are allowed

  • Dangerous keywords (INSERT, UPDATE, DELETE, DROP, ALTER, ATTACH, LOAD_EXTENSION, etc.) are blocked

  • Table names are validated against a strict alphanumeric pattern before use

  • SQL comments are stripped before safety checks to prevent bypass attempts

Setup

Prerequisites

  • Python 3.10+

  • A SQLite database file

Install

git clone https://github.com/sruthir28/mcp-sql-connector.git
cd mcp-sql-connector
python -m venv .venv
source .venv/bin/activate
pip install -e .

Create sample data (optional)

python setup_db.py

Configure in Claude Code

Add to your project's .mcp.json:

{
  "mcpServers": {
    "sql-connector": {
      "command": "/path/to/mcp-sql-connector/.venv/bin/python",
      "args": ["/path/to/mcp-sql-connector/server.py"],
      "env": {
        "MCP_DB_PATH": "/path/to/your/database.db"
      }
    }
  }
}

Configure in Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "sql-connector": {
      "command": "/path/to/mcp-sql-connector/.venv/bin/python",
      "args": ["/path/to/mcp-sql-connector/server.py"],
      "env": {
        "MCP_DB_PATH": "/path/to/your/database.db"
      }
    }
  }
}

Usage Examples

Once connected, you can ask Claude things like:

  • "What tables are in the database?"

  • "Show me all employees in Engineering"

  • "What's the total budget across all active projects?"

  • "Which tasks are high priority and still in progress?"

Claude will use the MCP tools to query the database and return results.

Environment Variables

Variable

Default

Description

MCP_DB_PATH

sample.db

Path to the SQLite database file

MCP_MAX_ROWS

100

Maximum rows returned per query

MCP_QUERY_TIMEOUT_MS

5000

Query timeout in milliseconds

Error Responses

All tools return errors in a consistent JSON format:

{"error": "Description of what went wrong"}

Common errors:

  • Table not found: The table name doesn't exist in the database

  • Invalid table name: Table name contains special characters (only letters, numbers, underscores allowed)

  • Query rejected: The SQL contains disallowed keywords or doesn't start with SELECT

  • Database not found: The MCP_DB_PATH doesn't point to a valid file (server won't start)

License

MIT

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
      Enables Claude to safely explore and query a SQLite database through natural language, including listing tables, inspecting schemas, and running read-only SELECT queries.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude and other MCP clients to map a SQLite database's schema and run read-only SQL queries against it, with writes blocked at the SQLite level through multiple enforcement layers. Results come back as context-friendly Markdown tables with row caps and a query timeout.
      2
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables Claude and other MCP clients to inspect a local SQLite database's tables, columns, and schema, and run safe read-only SQL queries with capped JSON results.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables Claude or any MCP host to explore and query a SQLite database through read-only tools for listing tables, describing schemas, and running SQL queries.
      3
      MIT