Skip to main content

mcp-tools-sql

CI PyPI Python License

Every change to mcp-tools-sql passes these checks (details):

Ruff mypy pylint architecture coverage OpenSSF Scorecard CodeQL

An MCP server for safe, configurable SQL database access. Exposes schema introspection, user-defined SELECT queries, and structured UPDATE operations as MCP tools for LLM-assisted workflows.

Key Ideas

  • Configurable, not ad-hoc: Every query the LLM can run is defined upfront in config. The config is the security boundary.
  • Queries are read-only: Each configured query's SQL is proved read-only before it is registered as a tool; a violating query is skipped with a warning. This is unconditional — security.allow_updates governs updates.* only.
  • Schema discovery: Built-in tools to explore schemas, tables, columns, and foreign key relations.
  • Structured updates: UPDATE operations are defined as table + key + fields, not raw SQL. The server generates the SQL.
  • Split config: Query definitions live in the project repo (safe to commit). Credentials live in the user's home directory (never committed).
  • Multi-backend: MS SQL Server (primary) and SQLite. PostgreSQL is planned: its config is accepted, but there is no backend implementation yet.

Architecture

MCP Client (Claude Code, etc.)
    ↕ STDIO/MCP
mcp-tools-sql server
    ├── Built-in tools (schema introspection)
    ├── Configured query tools (from mcp-tools-sql.toml)
    ├── Configured update tools (from mcp-tools-sql.toml)
    └── Backend abstraction
         ├── SQLite (stdlib)
         ├── MS SQL Server (pyodbc)
         └── PostgreSQL (psycopg)

See docs/architecture/architecture.md for details.

Installation

pip install mcp-tools-sql              # core + SQLite
pip install mcp-tools-sql[mssql]       # + SQL Server support

Quick Start

# Generate starter project query config (mcp-tools-sql.toml) and a
# database config skeleton at ~/.mcp-tools-sql/config.toml
mcp-tools-sql init --backend sqlite

# Edit ~/.mcp-tools-sql/config.toml and set the SQLite path, e.g.:
#     [connections.default]
#     backend = "sqlite"
#     path = "./mydb.db"

# Validate environment, configs, dependencies, and connectivity
mcp-tools-sql verify

# Try the tools without an MCP client
mcp-tools-sql tool
mcp-tools-sql tool read_tables --help

# Start MCP server
mcp-tools-sql --config mcp-tools-sql.toml

mcp-tools-sql help config prints a complete guide to both config files — enough for an LLM driving the CLI to set the server up on its own.

Documentation

Doc Covers
docs/configuration.md Both config files: discovery, every key, examples, multiple databases
docs/mcp-client-setup.md Wiring the server into Claude Code, Claude Desktop and other MCP clients
docs/cli.md Every command and flag, example output, exit codes
docs/architecture/architecture.md Internals
docs/quality-and-security-checks.md CI quality and security checks, required repo settings

Logging

The MCP server writes structured JSON logs to a new ~/.mcp-tools-sql/logs/mcp_tools_sql_<timestamp>.log file on every launch — MCP clients usually discard a server's stderr, so the file is the only durable record. User-facing messages, warnings and errors still appear on the console.

mcp-tools-sql --log-file /var/log/mcp-tools-sql.log   # explicit file
mcp-tools-sql --console-only --log-level DEBUG        # no file, verbose stderr

init and verify log to the console only. See docs/cli.md for thresholds and per-command defaults.

Configuration

Two config files:

File Purpose Location
mcp-tools-sql.toml Query/update definitions Project dir (committed)
~/.mcp-tools-sql/config.toml Database connections + credentials User home (never committed)

The query config may instead live in [tool.mcp-tools-sql] of the project's pyproject.toml. --config and --database-config override both paths.

One connection can route to several databases (catalogs), and several connections can be configured side by side. See docs/configuration.md for every key.

Note: databases is a routing/discovery list, not an authorization boundary — a connection still reaches any catalog its login is granted. Grant least privilege with per-connection database credentials at the server.

License

MIT

Metadata

Release files for mcp-tools-sql 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-tools-sql 0.2.0
File Size Uploaded Provenance Actions
mcp_tools_sql-0.2.0.tar.gz 307.4 kB With provenance Details for mcp_tools_sql-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-tools-sql 0.2.0
File Interpreter ABI Platform Actions
mcp_tools_sql-0.2.0-py3-none-any.whl Python 3 none any Details for mcp_tools_sql-0.2.0-py3-none-any.whl

Total release size: 432.6 kB

Release files / mcp_tools_sql-0.2.0.tar.gz

Download URL mcp_tools_sql-0.2.0.tar.gz
Size 307.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8442d643b2702aadeaf4527c48385bd655308411a052fc271cd73cca07013d3a
BLAKE2b-256 checksum
How to use checksums
ad746903c1c4f4e44bab4ede316aae12fdeef3b4e4e246bc095af1d42ba9a4da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / mcp_tools_sql-0.2.0-py3-none-any.whl

Download URL mcp_tools_sql-0.2.0-py3-none-any.whl
Size 125.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9740fd1b4a70291dc3a091b75868b75876abb29f242ca8ae3f9c72717db19f89
BLAKE2b-256 checksum
How to use checksums
e802db795807f37307256d5e82b59544cedff90ec1007d9922edb0e5fcb0dd80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for mcp-tools-sql 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_tools_sql-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page