MCP server bridge for SQL operations (SQLite, PostgreSQL, MySQL)
Project description
MCP SQL Bridge
Local-SQL-Insight — Give your AI assistant direct, read-only access to your SQL databases over the Model Context Protocol. No APIs, no cloud. Your data stays on your machine.
Why use this?
- Schema-aware AI — The agent sees table names, columns, and full
CREATE TABLEDDL so it can write correct SQL. - Business context — Expose a project
README.mdas a resource so the AI understands your domain and conventions. - Read-only by design — Only
SELECTis allowed. No accidental writes or schema changes. - Stdio transport — Works with Cursor, Claude Desktop, and any MCP host. No ports or network setup.
- Multi-database (Pro) — Use the same tools against SQLite, PostgreSQL, and MySQL by switching a
backendand connection string.
Quick start
git clone <your-repo-url>
cd mcp-sql-bridge
poetry install
Then plug the server into your editor or desktop app (see below).
Run & test: See RUN_AND_TEST.md for how to run the MCP server, the web server, unit tests, and Docker-based integration tests (e.g. poetry run python scripts/run_docker_integration.py).
Web server (optional)
A small FastAPI app provides a landing page, Swagger UI, and documentation (MkDocs):
poetry install --with web
mkdocs build # build docs (optional; without this, /documentation shows build instructions)
poetry run mcp-sql-bridge-web
Open http://localhost:8000 for the home page, http://localhost:8000/docs for Swagger, http://localhost:8000/redoc for ReDoc, and http://localhost:8000/documentation for the full docs site (after mkdocs build).
How to use with Cursor
-
Install the server (if not already):
cd /path/to/mcp-sql-bridge poetry install
-
Configure MCP
Open Cursor Settings → Tools & MCP (or edit the config file directly).
Add the server using the template inmcp-config.jsonin this repo:-
Option A — Global config
Put the contents ofmcp-config.jsoninto:- macOS / Linux:
~/.cursor/mcp.json - Windows:
%APPDATA%\Cursor\mcp.json
- macOS / Linux:
-
Option B — Project config
Copymcp-config.jsoninto your project as.cursor/mcp.json(and adjust thecwdpath to this repo if needed).
-
-
Set the path
In the config, setcwd(or the path inargs) to the absolute path of yourmcp-sql-bridgeproject directory so Cursor can runpoetry run mcp-sql-bridgefrom there. -
Restart Cursor
MCP servers load at startup. Restart Cursor after changing the config. -
Use it
In any chat, the AI can call Local-SQL-Insight tools:list_tables,execute_readonly_query, and read the Database README resource.- For SQLite, point it at a file path (e.g.
./data/app.db) withbackend: "sqlite"or by omittingbackend. - For PostgreSQL/MySQL (Pro), provide a
backendandconnection_stringURL.
- For SQLite, point it at a file path (e.g.
How to use with Claude Desktop
-
Install the server (if not already):
cd /path/to/mcp-sql-bridge poetry install
-
Locate Claude’s config file
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the MCP server
Add amcpServersentry (or merge into existing) like this, using the absolute path to yourmcp-sql-bridgedirectory:{ "mcpServers": { "local-sql-insight": { "command": "poetry", "args": ["run", "mcp-sql-bridge"], "cwd": "/absolute/path/to/mcp-sql-bridge" } } }
If Claude Desktop uses a different Python environment, you can instead use the full path to the
mcp-sql-bridgeexecutable in the project’s virtualenv, for example:{ "mcpServers": { "local-sql-insight": { "command": "/absolute/path/to/mcp-sql-bridge/.venv/bin/mcp-sql-bridge", "args": [] } } }
-
Restart Claude Desktop
Restart the app so it picks up the new MCP config. -
Use it
Claude can use the list_tables and execute_readonly_query tools and read the Database README resource.- For SQLite, use your SQLite file path (e.g.
~/project/data/app.db). - For PostgreSQL/MySQL, supply connection URLs when the model asks for database details.
- For SQLite, use your SQLite file path (e.g.
What the server provides
| Capability | Description |
|---|---|
| list_tables | Lists every table, its columns, and the full CREATE TABLE statement. Supports `backend: "sqlite" |
| execute_readonly_query | Runs a SELECT query and returns results as a formatted text table. Supports all backends via backend and connection_string / db_path. |
| schema_summary | Compact overview of tables and key columns for a quick schema scan. |
| sample_rows | Limited sample rows from a given table to understand data shape and example values. |
| explain_database | High-level explanation of the database based on its schema. |
| suggest_indexes_for_query | Heuristic index suggestions for a given SELECT query (no writes). |
| Database README (resource) | Serves README.md from the server’s current working directory so the AI can read your project’s business context. |
| Database README template (resource) | A markdown template for per-database README files (owners, conventions, key tables, gotchas). |
For SQLite, the server validates that paths point to real SQLite files (magic header check) and returns clear errors if a path is wrong or not a database.
For PostgreSQL/MySQL, it validates connections and reports connection/auth errors clearly; use read-only roles in production.
Connection strings (PostgreSQL & MySQL)
Use the connection_string argument with backend: "postgres" or backend: "mysql" when calling list_tables or execute_readonly_query.
PostgreSQL — URL format (password in URL is optional; use env vars in production):
postgresql://user:password@localhost:5432/dbnamepostgresql://user@localhost:5432/dbname(no password)postgresql://localhost:5432/dbname(peer/auth trust)
MySQL — URL format:
mysql://user:password@localhost:3306/dbnamemariadb://user:password@localhost:3306/dbname
Install optional drivers: poetry install --extras postgres and/or poetry install --extras mysql (or --extras pro for both). Example MCP configs for multi-database setups are in examples/mcp-config-pro.json and examples/README.md.
Documentation
- Main README (this file) — quick start and usage.
- docs/ — security and hardening, error taxonomy, pricing and licensing, launch and marketing, future ideas.
- CONTRIBUTING.md — development setup, tests, release, PyPI.
Requirements
- Python 3.11+
- Poetry (recommended) or
pipfor dependencies - Optional extras:
postgresextra for PostgreSQL (psycopg)mysqlextra for MySQL (pymysql)
Feedback and support
- Bug reports and feature ideas: Open an issue.
- Questions and discussions: GitHub Discussions.
- Feedback from users (issues, discussions, or contact) is used to prioritize the roadmap and any future paid offerings.
Support & maintenance
- Targeted Python: 3.11+
- MCP: current stable versions at time of release
- Backwards-compatible changes will be released as minor versions; breaking changes will bump the major or minor version and be noted in
CHANGELOG.md. - The project is intended to be feature-complete after the 0.2.x line; future work will focus on fixes and compatibility updates only.
License
MIT. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_sql_bridge-1.0.0.tar.gz.
File metadata
- Download URL: mcp_sql_bridge-1.0.0.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d1894873e400433d4ddfefb9061b513001459d7ad43108f83bdd7676334f388
|
|
| MD5 |
59b3f637368828273a2874e25600395b
|
|
| BLAKE2b-256 |
03cbad24c59369253378a5c82369f078c6fd334e4532b0d0b49a14c88ed36afc
|
File details
Details for the file mcp_sql_bridge-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mcp_sql_bridge-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.2 CPython/3.14.3 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a83dd6496cd0dcfc29e789df3a6825b28ae5774c8074983b77495662c72fa2c3
|
|
| MD5 |
bbfe78035a93cfe6f2c39c6efe2423a4
|
|
| BLAKE2b-256 |
ae1347744ceff675653001d066258e6123994768812aa68b8a85cb6bc7b2a6e0
|