sql-mcp 0.5.0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/MANIFEST.in +1 -1
  2. sql_mcp-1.0.1/PKG-INFO +416 -0
  3. sql_mcp-1.0.1/README.md +378 -0
  4. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/pyproject.toml +12 -6
  5. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/requirements.txt +1 -1
  6. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/agent_server.py +1 -1
  7. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/auth.py +15 -15
  8. sql_mcp-1.0.1/sql_mcp/main_agent.json +18 -0
  9. sql_mcp-1.0.1/sql_mcp/mcp_config.json +27 -0
  10. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/mcp_server.py +16 -8
  11. sql_mcp-1.0.1/sql_mcp/prompts/__init__.py +0 -0
  12. sql_mcp-1.0.1/sql_mcp/prompts/main_agent.json +18 -0
  13. sql_mcp-1.0.1/sql_mcp/skills/__init__.py +0 -0
  14. sql_mcp-1.0.1/sql_mcp/skills/sql-starter/SKILL.md +19 -0
  15. sql_mcp-1.0.1/sql_mcp.egg-info/PKG-INFO +416 -0
  16. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp.egg-info/SOURCES.txt +4 -0
  17. sql_mcp-1.0.1/sql_mcp.egg-info/entry_points.txt +9 -0
  18. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp.egg-info/requires.txt +4 -4
  19. sql_mcp-0.5.0/PKG-INFO +0 -257
  20. sql_mcp-0.5.0/README.md +0 -219
  21. sql_mcp-0.5.0/sql_mcp/main_agent.json +0 -14
  22. sql_mcp-0.5.0/sql_mcp/mcp_config.json +0 -33
  23. sql_mcp-0.5.0/sql_mcp.egg-info/PKG-INFO +0 -257
  24. sql_mcp-0.5.0/sql_mcp.egg-info/entry_points.txt +0 -3
  25. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/LICENSE +0 -0
  26. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/setup.cfg +0 -0
  27. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/__init__.py +0 -0
  28. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/__main__.py +0 -0
  29. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/api/__init__.py +0 -0
  30. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/api/api_client_sql.py +0 -0
  31. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/api_client.py +0 -0
  32. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/dialects.py +0 -0
  33. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/mcp/__init__.py +0 -0
  34. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/mcp/mcp_sql.py +0 -0
  35. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/safety.py +0 -0
  36. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/sql_input_models.py +0 -0
  37. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp/sql_response_models.py +0 -0
  38. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp.egg-info/dependency_links.txt +0 -0
  39. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/sql_mcp.egg-info/top_level.txt +0 -0
  40. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_api_wrapper.py +0 -0
  41. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_auth.py +0 -0
  42. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_concept_parity.py +0 -0
  43. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_dialect_paths.py +0 -0
  44. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_dialects.py +0 -0
  45. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_init_dynamics.py +0 -0
  46. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_safety.py +0 -0
  47. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_sql_mcp_validation.py +0 -0
  48. {sql_mcp-0.5.0 → sql_mcp-1.0.1}/tests/test_startup.py +0 -0
@@ -1,4 +1,4 @@
1
1
  include LICENSE
2
2
  include README.md
3
3
  include requirements.txt
4
- recursive-include sql_mcp *.py *.json
4
+ recursive-include sql_mcp *.py *.json *.md *.yaml *.yml
sql_mcp-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,416 @@
1
+ Metadata-Version: 2.4
2
+ Name: sql-mcp
3
+ Version: 1.0.1
4
+ Summary: Generic SQL database (Postgres, MySQL/MariaDB, MSSQL, Oracle, SQLite) API + MCP Server + A2A Server for Agentic AI!
5
+ Author-email: Audel Rouhi <knucklessg1@gmail.com>
6
+ License: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Environment :: Console
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: <3.15,>=3.11
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: agent-utilities>=1.0.0
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Requires-Dist: sqlalchemy>=2.0.0
18
+ Provides-Extra: mcp
19
+ Requires-Dist: agent-utilities[mcp]>=1.0.0; extra == "mcp"
20
+ Provides-Extra: agent
21
+ Requires-Dist: agent-utilities[agent,logfire]>=1.0.0; extra == "agent"
22
+ Provides-Extra: postgres
23
+ Requires-Dist: psycopg[binary]>=3.1.0; extra == "postgres"
24
+ Provides-Extra: mysql
25
+ Requires-Dist: pymysql>=1.1.0; extra == "mysql"
26
+ Provides-Extra: mssql
27
+ Requires-Dist: pyodbc>=5.0.0; extra == "mssql"
28
+ Provides-Extra: oracle
29
+ Requires-Dist: oracledb>=2.0.0; extra == "oracle"
30
+ Provides-Extra: all
31
+ Requires-Dist: sql-mcp[agent,logfire,mcp,mssql,mysql,oracle,postgres]>=1.0.0; extra == "all"
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest-xdist>=3.6.0; extra == "test"
34
+ Requires-Dist: pytest; extra == "test"
35
+ Requires-Dist: pytest-asyncio; extra == "test"
36
+ Requires-Dist: pytest-cov; extra == "test"
37
+ Dynamic: license-file
38
+
39
+ # Sql Mcp
40
+ ## API | MCP Server | A2A Agent
41
+
42
+ ![PyPI - Version](https://img.shields.io/pypi/v/sql-mcp)
43
+ ![MCP Server](https://badge.mcpx.dev?type=server 'MCP Server')
44
+ ![PyPI - Downloads](https://img.shields.io/pypi/dd/sql-mcp)
45
+ ![GitHub Repo stars](https://img.shields.io/github/stars/Knuckles-Team/sql-mcp)
46
+ ![GitHub forks](https://img.shields.io/github/forks/Knuckles-Team/sql-mcp)
47
+ ![GitHub contributors](https://img.shields.io/github/contributors/Knuckles-Team/sql-mcp)
48
+ ![PyPI - License](https://img.shields.io/pypi/l/sql-mcp)
49
+ ![GitHub](https://img.shields.io/github/license/Knuckles-Team/sql-mcp)
50
+ ![GitHub last commit (by committer)](https://img.shields.io/github/last-commit/Knuckles-Team/sql-mcp)
51
+ ![GitHub pull requests](https://img.shields.io/github/issues-pr/Knuckles-Team/sql-mcp)
52
+ ![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/Knuckles-Team/sql-mcp)
53
+ ![GitHub issues](https://img.shields.io/github/issues/Knuckles-Team/sql-mcp)
54
+ ![GitHub top language](https://img.shields.io/github/languages/top/Knuckles-Team/sql-mcp)
55
+ ![GitHub language count](https://img.shields.io/github/languages/count/Knuckles-Team/sql-mcp)
56
+ ![GitHub repo size](https://img.shields.io/github/repo-size/Knuckles-Team/sql-mcp)
57
+ ![PyPI - Wheel](https://img.shields.io/pypi/wheel/sql-mcp)
58
+ ![PyPI - Implementation](https://img.shields.io/pypi/implementation/sql-mcp)
59
+
60
+ Generic SQL database **API + MCP Server + A2A Agent** for the agent-utilities
61
+ ecosystem — one connector for **PostgreSQL, MySQL/MariaDB, Microsoft SQL Server,
62
+ Oracle, and SQLite** over SQLAlchemy 2.x Core.
63
+
64
+ *Version: 1.0.1*
65
+
66
+ > **Documentation** — Installation, deployment, and usage across the API, CLI, and
67
+ > MCP interfaces are maintained in [`docs/`](docs/index.md).
68
+
69
+ ## Table of Contents
70
+
71
+ - [Overview](#overview)
72
+ - [What it provides](#what-it-provides)
73
+ - [MCP tools](#mcp-tools)
74
+ - [Dialects & extras](#dialects--extras)
75
+ - [Configuration (environment)](#configuration-environment)
76
+ - [Installation](#installation)
77
+ - [Usage](#usage)
78
+ - [MCP config](#mcp-config)
79
+ - [Docker deployment](#docker-deployment)
80
+ - [Safety model](#safety-model)
81
+ - [Tests](#tests)
82
+
83
+ ## Overview
84
+
85
+ `sql-mcp` exposes read-only queries, gated DML/DDL, schema reflection, and
86
+ connection administration as typed, deterministic MCP tools, and ships an optional
87
+ Pydantic-AI agent server. It is **read-only by default**: every query passes a
88
+ statement-type allowlist, every result is bounded by a row cap and a timeout, and
89
+ all values travel as bound parameters — never interpolated into SQL strings.
90
+
91
+ ## What it provides
92
+
93
+ - **`SqlApi`** (`sql_mcp.api.api_client_sql`) — a SQLAlchemy 2.x Core facade with
94
+ named multi-connection support, lazy engine creation, the read-only statement
95
+ gate, row-cap/timeout enforcement, and bounded result envelopes
96
+ (`{columns, rows, row_count, truncated}`).
97
+ - **Four MCP tools** (`sql-mcp` console script): `sql_query` (execute/explain),
98
+ `sql_execute` (execute/script — gated by `SQL_ALLOW_WRITES`), `sql_schema`
99
+ (schemas/tables/views/columns/indexes/foreign_keys/ddl/sample), and `sql_admin`
100
+ (ping/version/active_connections/connections/dialects). See
101
+ [`docs/usage.md`](docs/usage.md) for the full action surface.
102
+ - **A dialect registry** (`sql_mcp.dialects`) — per-engine driver, URL scheme, pip
103
+ extra, EXPLAIN prefix, and admin SQL. Core ships SQLite only; the other drivers
104
+ install via extras.
105
+ - **An A2A agent server** (`sql-agent` console script) — a Pydantic-AI graph agent
106
+ wired to the MCP server via `MCP_URL`.
107
+
108
+ ## MCP tools
109
+
110
+ The table below is auto-generated from the MCP server — do not edit by hand.
111
+
112
+ <!-- MCP-TOOLS-TABLE:START -->
113
+
114
+ #### Condensed action-routed tools (default — `MCP_TOOL_MODE=condensed`)
115
+
116
+ | MCP Tool | Toggle Env Var | Description |
117
+ |----------|----------------|-------------|
118
+ | `sql_admin` | `SQLTOOL` | Connection health, server version, sessions, and registry info. |
119
+ | `sql_schema` | `SQLTOOL` | Inspect schemas, tables, views, columns, indexes, FKs, and DDL. |
120
+
121
+ #### Verbose 1:1 API-mapped tools (`MCP_TOOL_MODE=verbose` or `both`)
122
+
123
+ <details>
124
+ <summary>22 per-operation tools — one per public API method (click to expand)</summary>
125
+
126
+ | MCP Tool | Toggle Env Var | Description |
127
+ |----------|----------------|-------------|
128
+ | `sql_active_connections` | `SQL_APITOOL` | List active server sessions where the dialect supports it. |
129
+ | `sql_connection_names` | `SQL_APITOOL` | Names of all configured connections. |
130
+ | `sql_default_connection` | `SQL_APITOOL` | The sole/first configured connection — used when none is named. |
131
+ | `sql_describe_connections` | `SQL_APITOOL` | Describe configured connections with passwords redacted. |
132
+ | `sql_dialect_spec` | `SQL_APITOOL` | The registered :class:`DialectSpec` for a connection, if any. |
133
+ | `sql_dispose` | `SQL_APITOOL` | Dispose all pooled engines. |
134
+ | `sql_engine` | `SQL_APITOOL` | Lazily create (and cache) the Engine for a named connection. |
135
+ | `sql_execute` | `SQLTOOL` | Execute one DML/DDL statement in a transaction (writes gate applies). |
136
+ | `sql_execute_script` | `SQL_APITOOL` | Run several statements in ONE transaction (all-or-nothing). |
137
+ | `sql_explain` | `SQL_APITOOL` | Return the dialect's query plan for a read-only statement. |
138
+ | `sql_list_columns` | `SQL_APITOOL` | Describe a table's columns: name, type, nullable, default. |
139
+ | `sql_list_foreign_keys` | `SQL_APITOOL` | List a table's foreign keys (columns -> referred table/columns). |
140
+ | `sql_list_indexes` | `SQL_APITOOL` | List a table's indexes (name, columns, uniqueness). |
141
+ | `sql_list_schemas` | `SQL_APITOOL` | List schema names. |
142
+ | `sql_list_tables` | `SQL_APITOOL` | List table names (optionally within a schema). |
143
+ | `sql_list_views` | `SQL_APITOOL` | List view names (optionally within a schema). |
144
+ | `sql_ping` | `SQL_APITOOL` | Connection test: ``SELECT 1`` round-trip with latency. |
145
+ | `sql_query` | `SQLTOOL` | Execute a read-only SELECT/CTE with bound parameters. |
146
+ | `sql_resolve_connection` | `SQL_APITOOL` | Map an optional connection name to a configured one (or raise). |
147
+ | `sql_sample_rows` | `SQL_APITOOL` | Return up to ``limit`` rows from a table (cap still applies). |
148
+ | `sql_server_version` | `SQL_APITOOL` | Report the server version (dialect SQL, else SQLAlchemy's probe). |
149
+ | `sql_table_ddl` | `SQL_APITOOL` | Reflect a table and render its CREATE TABLE DDL for this dialect. |
150
+
151
+ </details>
152
+
153
+ _2 action-routed tool(s) (default) · 22 verbose 1:1 tool(s). Each is enabled unless its `<DOMAIN>TOOL` toggle is set false; `MCP_TOOL_MODE` selects the surface (`condensed` default · `verbose` 1:1 · `both`). Auto-generated — do not edit._
154
+ <!-- MCP-TOOLS-TABLE:END -->
155
+
156
+ Every tool takes `action`, `params_json`, and an optional `connection` naming one
157
+ of the configured connections. The whole set is toggled with `SQLTOOL`.
158
+
159
+ ## Dialects & extras
160
+
161
+ | Dialect | SQLAlchemy scheme | Driver | Install |
162
+ |---|---|---|---|
163
+ | SQLite | `sqlite+pysqlite` | stdlib | `pip install sql-mcp` (core) |
164
+ | PostgreSQL | `postgresql+psycopg` | psycopg 3 | `pip install sql-mcp[postgres]` |
165
+ | MySQL / MariaDB | `mysql+pymysql` | PyMySQL | `pip install sql-mcp[mysql]` |
166
+ | SQL Server | `mssql+pyodbc` | pyodbc | `pip install sql-mcp[mssql]` |
167
+ | Oracle | `oracle+oracledb` | python-oracledb | `pip install sql-mcp[oracle]` |
168
+
169
+ `pip install sql-mcp[all]` pulls every driver plus the MCP and agent extras.
170
+
171
+ ## Configuration (environment)
172
+
173
+ | Var | Default | Meaning |
174
+ |---|---|---|
175
+ | `SQL_CONNECTIONS` | _(empty)_ | JSON map of named connections: DSN strings or `{dialect, host, port, username, password, database, options}` objects |
176
+ | `SQL_URL` | _(empty)_ | Single DSN registered as connection `default` |
177
+ | `SQL_DIALECT` / `SQL_HOST` / `SQL_PORT` / `SQL_USERNAME` / `SQL_PASSWORD` / `SQL_DATABASE` / `SQL_OPTIONS` | _(empty)_ | Discrete fields for a single `default` connection |
178
+ | `SQL_ALLOW_WRITES` | `False` | Enable `sql_execute` (DML/DDL). **Read-only by default** |
179
+ | `SQL_MAX_ROWS` | `500` | Per-call row cap; tool requests are clamped to it |
180
+ | `SQL_TIMEOUT_SECONDS` | `30` | Per-statement timeout |
181
+ | `SQLTOOL` | `True` | Register the SQL tool set |
182
+
183
+ With nothing configured the server registers a zero-infra in-memory SQLite
184
+ connection named `memory`, so it works out of the box. Tools take an optional
185
+ `connection` parameter naming one of the configured connections; it defaults to
186
+ the sole/first one. Passwords are parsed into `sqlalchemy.URL` objects and only
187
+ ever rendered redacted. Copy [`.env.example`](.env.example) to `.env` and
188
+ populate only what you use.
189
+
190
+ ## Installation
191
+
192
+ Pick the extra that matches what you want to run. DB-driver extras
193
+ (`postgres` / `mysql` / `mssql` / `oracle`) are **additive** — combine them with
194
+ `[mcp]` or `[agent]`, e.g. `sql-mcp[mcp,postgres]` (see [Dialects & extras](#dialects--extras)).
195
+
196
+ | Extra | Installs | Use when |
197
+ |-------|----------|----------|
198
+ | `sql-mcp[mcp]` | Slim MCP server only (`agent-utilities[mcp]` — FastMCP/FastAPI) | You only run the **MCP server** (smallest install / image) |
199
+ | `sql-mcp[agent]` | Full agent runtime (`agent-utilities[agent,logfire]` — Pydantic AI + the epistemic-graph engine) | You run the **integrated agent** |
200
+ | `sql-mcp[all]` | Everything (`mcp` + `agent` + **every** DB driver + `logfire`) | Development / both surfaces |
201
+
202
+ ```bash
203
+ pip install sql-mcp # core (SQLite only, MCP server, API)
204
+ pip install "sql-mcp[mcp]" # slim MCP server (add drivers: [mcp,postgres])
205
+ pip install "sql-mcp[agent]" # full agent runtime (Pydantic AI + engine)
206
+ pip install "sql-mcp[all]" # every driver + MCP + agent extras
207
+ pip install -e . # from source
208
+ ```
209
+
210
+ ### Container images (`:mcp` vs `:agent`)
211
+
212
+ One multi-stage `docker/Dockerfile` builds two right-sized images, selected by `--target`:
213
+
214
+ | Image tag | Build target | Contents | Entrypoint |
215
+ |-----------|--------------|----------|------------|
216
+ | `knucklessg1/sql-mcp:mcp` | `--target mcp` | `sql-mcp[mcp]` — **slim**, no engine/`pydantic-ai`/`dspy`/`llama-index`/`tree-sitter` | `sql-mcp` |
217
+ | `knucklessg1/sql-mcp:latest` | `--target agent` (default) | `sql-mcp[agent]` — **full** agent runtime + epistemic-graph engine | `sql-agent` |
218
+
219
+ ```bash
220
+ docker pull knucklessg1/sql-mcp:mcp # slim MCP server
221
+ docker build --target mcp -t knucklessg1/sql-mcp:mcp docker/ # build slim MCP server
222
+ docker build --target agent -t knucklessg1/sql-mcp:latest docker/ # build full agent
223
+ ```
224
+
225
+ `docker/mcp.compose.yml` runs the slim `:mcp` server; `docker/agent.compose.yml` runs the
226
+ agent (`:latest`) with a co-located `:mcp` sidecar.
227
+
228
+ ### Knowledge-graph database (`epistemic-graph`)
229
+
230
+ The **full agent** (`[agent]` / `:latest`) embeds the **epistemic-graph** engine (pulled in
231
+ transitively via `agent-utilities[agent]`). For production — or to share one knowledge graph
232
+ across multiple agents — run **epistemic-graph as its own database container** and point the
233
+ agent at it instead of embedding it. Deployment recipes (single-node + Raft HA), connection
234
+ config, and the full database architecture (with diagrams) are documented in the
235
+ [epistemic-graph deployment guide](https://knuckles-team.github.io/epistemic-graph/deployment/).
236
+ The slim `[mcp]` server does **not** require the database.
237
+
238
+ ## Usage
239
+
240
+ ```bash
241
+ sql-mcp # stdio MCP server (default transport)
242
+ sql-mcp --transport streamable-http --host 0.0.0.0 --port 8000
243
+ ```
244
+
245
+ Point it at a database:
246
+
247
+ ```bash
248
+ export SQL_URL="postgresql+psycopg://svc:****@db.example.com:5432/app"
249
+ sql-mcp
250
+ ```
251
+
252
+ Or several:
253
+
254
+ ```bash
255
+ export SQL_CONNECTIONS='{
256
+ "warehouse": "postgresql+psycopg://svc:****@dw.example.com:5432/dw",
257
+ "erp": {"dialect": "mysql", "host": "erp.example.com", "username": "svc",
258
+ "password": "****", "database": "erp"}
259
+ }'
260
+ sql-mcp
261
+ ```
262
+
263
+ Run the agent server against a live MCP server:
264
+
265
+ ```bash
266
+ sql-agent --mcp-url http://localhost:8000/mcp --host 0.0.0.0 --port 8080
267
+ ```
268
+
269
+ ## MCP config
270
+
271
+ > **Install the slim `[mcp]` extra.** For MCP-server hosting install
272
+ > `sql-mcp[mcp]` (add DB-driver extras as needed, e.g. `sql-mcp[mcp,postgres]`) —
273
+ > the MCP-server extra pulls only the FastMCP / FastAPI tooling
274
+ > (`agent-utilities[mcp]`). It deliberately **excludes** the heavy agent runtime
275
+ > (the epistemic-graph engine, `pydantic-ai`, `dspy`, `llama-index`, `tree-sitter`),
276
+ > so `uvx`/container installs are dramatically smaller and faster. Use the full
277
+ > `[agent]` extra only when you need the integrated Pydantic AI agent (see
278
+ > [Installation](#installation)).
279
+
280
+ ```json
281
+ {
282
+ "mcpServers": {
283
+ "sql-mcp": {
284
+ "command": "uv",
285
+ "args": ["run", "sql-mcp"],
286
+ "env": {
287
+ "SQL_URL": "postgresql+psycopg://svc:****@db.example.com:5432/app",
288
+ "SQL_ALLOW_WRITES": "False"
289
+ }
290
+ }
291
+ }
292
+ }
293
+ ```
294
+
295
+ <!-- BEGIN GENERATED: additional-deployment-options -->
296
+ ### Additional Deployment Options
297
+
298
+ `sql-mcp` can also run as a **local container** (Docker / Podman / `uv`) or be
299
+ consumed from a **remote deployment**. The
300
+ [Deployment guide](https://knuckles-team.github.io/sql-mcp/deployment/) has full, copy-paste
301
+ `mcp_config.json` for all four transports — **stdio**, **streamable-http**,
302
+ **local container / uv**, and **remote URL**:
303
+
304
+ - **Local container / uv** — launch the server from `mcp_config.json` via `uvx`,
305
+ `docker run`, or `podman run`, or point at a local streamable-http container by `url`.
306
+ - **Remote URL** — connect to a server deployed behind Caddy at
307
+ `http://sql-mcp.arpa/mcp` using the `"url"` key.
308
+ <!-- END GENERATED: additional-deployment-options -->
309
+
310
+ ## Docker deployment
311
+
312
+ ```bash
313
+ docker compose -f docker/mcp.compose.yml up -d # MCP server only
314
+ docker compose -f docker/agent.compose.yml up -d # MCP + A2A agent
315
+ curl -s http://localhost:8000/health # {"status":"OK"}
316
+ ```
317
+
318
+ Both services read configuration from `../.env` (copy
319
+ [`.env.example`](.env.example)); see [`docs/deployment.md`](docs/deployment.md).
320
+
321
+ ## Safety model
322
+
323
+ - **Read-only by default** — `sql_execute` refuses to run unless the *server* was
324
+ started with `SQL_ALLOW_WRITES=True`; agents cannot flip the flag per call.
325
+ - **Statement allowlist** — `sql_query` accepts only `SELECT`/`WITH`/`EXPLAIN`/
326
+ `SHOW`/`DESCRIBE`/`PRAGMA`/`VALUES`; CTEs are inspected at paren depth zero so
327
+ `WITH ... INSERT` cannot smuggle a write, `SELECT INTO` is rejected, and
328
+ multi-statement payloads are refused.
329
+ - **Bounded results** — per-call row caps clamp to `SQL_MAX_ROWS`; statements run
330
+ under `SQL_TIMEOUT_SECONDS` on a worker thread.
331
+ - **Parameterized only** — values bind via `:name` parameters; identifiers are
332
+ quoted by SQLAlchemy reflection, never hand-interpolated.
333
+
334
+ ## Tests
335
+
336
+ ```bash
337
+ python -m pytest # full suite against in-memory SQLite (no live DBs)
338
+ pre-commit run --all-files
339
+ ```
340
+
341
+
342
+ <!-- BEGIN agent-os-genesis-deploy (generated; do not edit between markers) -->
343
+
344
+ ## Deploy with `agent-os-genesis`
345
+
346
+ This package can be provisioned for you — skill-guided — by the **`agent-os-genesis`**
347
+ universal skill (its *single-package deploy mode*): it picks your install method, seeds
348
+ secrets to OpenBao/Vault (or `.env`), trusts your enterprise CA, registers the MCP
349
+ server, and verifies it — the same machinery that stands up the whole Agent OS, narrowed
350
+ to just this package. Ask your agent to **"deploy `sql-mcp` with agent-os-genesis"**.
351
+
352
+ | Install mode | Command |
353
+ |------|---------|
354
+ | Bare-metal, prod (PyPI) | `uvx sql-mcp` · or `uv tool install sql-mcp` |
355
+ | Bare-metal, dev (editable) | `uv pip install -e ".[all]"` · or `pip install -e ".[all]"` |
356
+ | Container, prod | deploy `knucklessg1/sql-mcp:latest` via docker-compose / swarm / podman / podman-compose / kubernetes |
357
+ | Container, dev (editable) | deploy `docker/compose.dev.yml` (source-mounted at `/src`; edits live on restart) |
358
+
359
+ Secrets are read-existing + seeded via `vault_sync` — you are only prompted for what's missing.
360
+
361
+ <!-- END agent-os-genesis-deploy -->
362
+
363
+ ## Environment Variables
364
+
365
+ <!-- ENV-VARS-TABLE:START -->
366
+
367
+ #### Package environment variables
368
+
369
+ | Variable | Example | Description |
370
+ |----------|---------|-------------|
371
+ | `HOST` | `0.0.0.0` | |
372
+ | `PORT` | `8000` | |
373
+ | `TRANSPORT` | `stdio` | options: stdio, streamable-http, sse |
374
+ | `ENABLE_OTEL` | `True` | |
375
+ | `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:8080/api/public/otel` | |
376
+ | `OTEL_EXPORTER_OTLP_PUBLIC_KEY` | `pk-...` | |
377
+ | `OTEL_EXPORTER_OTLP_SECRET_KEY` | `sk-...` | |
378
+ | `OTEL_EXPORTER_OTLP_PROTOCOL` | `http/protobuf` | |
379
+ | `EUNOMIA_TYPE` | `none` | options: none, embedded, remote |
380
+ | `EUNOMIA_POLICY_FILE` | `mcp_policies.json` | |
381
+ | `EUNOMIA_REMOTE_URL` | `http://eunomia-server:8000` | |
382
+ | `SQL_CONNECTIONS` | `{"warehouse": "postgresql+psycopg://svc:password@db:5432/dw"}` | password, database, options} objects. Takes priority over SQL_URL. |
383
+ | `SQL_URL` | `postgresql+psycopg://svc:password@db.example.com:5432/app` | Single connection (registered as "default") |
384
+ | `SQL_DIALECT` | `postgres` | ... or discrete fields for a single "default" connection |
385
+ | `SQL_HOST` | `db.example.com` | |
386
+ | `SQL_PORT` | `5432` | |
387
+ | `SQL_USERNAME` | `svc` | |
388
+ | `SQL_PASSWORD` | — | |
389
+ | `SQL_DATABASE` | `app` | |
390
+ | `SQL_OPTIONS` | `{"sslmode": "require"}` | |
391
+ | `SQL_ALLOW_WRITES` | `False` | Policy (read-only by default) |
392
+ | `SQL_MAX_ROWS` | `500` | |
393
+ | `SQL_TIMEOUT_SECONDS` | `30` | |
394
+ | `SQLTOOL` | `True` | |
395
+
396
+ #### Inherited agent-utilities variables (apply to every connector)
397
+
398
+ | Variable | Example | Description |
399
+ |----------|---------|-------------|
400
+ | `MCP_TOOL_MODE` | `condensed` | Tool surface: `condensed` | `verbose` | `both` |
401
+ | `MCP_ENABLED_TOOLS` | — | Comma-separated tool allow-list |
402
+ | `MCP_DISABLED_TOOLS` | — | Comma-separated tool deny-list |
403
+ | `MCP_ENABLED_TAGS` | — | Comma-separated tag allow-list |
404
+ | `MCP_DISABLED_TAGS` | — | Comma-separated tag deny-list |
405
+ | `MCP_CLIENT_AUTH` | — | Outbound MCP auth (`oidc-client-credentials` for fleet calls) |
406
+ | `OIDC_CLIENT_ID` | — | OIDC client id (service-account auth) |
407
+ | `OIDC_CLIENT_SECRET` | — | OIDC client secret (service-account auth) |
408
+ | `DEBUG` | `False` | Verbose logging |
409
+ | `PYTHONUNBUFFERED` | `1` | Unbuffered stdout (recommended in containers) |
410
+ | `MCP_URL` | `http://localhost:8000/mcp` | URL of the MCP server the agent connects to |
411
+ | `PROVIDER` | `openai` | LLM provider for the agent |
412
+ | `MODEL_ID` | `gpt-4o` | Model id for the agent |
413
+ | `ENABLE_WEB_UI` | `True` | Serve the AG-UI web interface |
414
+
415
+ _24 package + 14 inherited variable(s). Auto-generated from `.env.example` + the shared agent-utilities set — do not edit._
416
+ <!-- ENV-VARS-TABLE:END -->