sql-mcp 0.5.0__tar.gz → 2.3.2__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.
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/MANIFEST.in +1 -1
- sql_mcp-2.3.2/PKG-INFO +381 -0
- sql_mcp-2.3.2/README.md +345 -0
- sql_mcp-2.3.2/pyproject.toml +83 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/requirements.txt +1 -1
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/__init__.py +23 -16
- sql_mcp-2.3.2/sql_mcp/__main__.py +4 -0
- sql_mcp-2.3.2/sql_mcp/api/api_client_sql.py +1680 -0
- sql_mcp-2.3.2/sql_mcp/auth.py +316 -0
- sql_mcp-2.3.2/sql_mcp/connectors/__init__.py +0 -0
- sql_mcp-2.3.2/sql_mcp/connectors/mcp_source_presets.json +3 -0
- sql_mcp-2.3.2/sql_mcp/connectors/tool_schema_fingerprints.json +6 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/dialects.py +13 -3
- sql_mcp-2.3.2/sql_mcp/kg_ingest.py +306 -0
- sql_mcp-2.3.2/sql_mcp/kg_pgwire.py +125 -0
- sql_mcp-2.3.2/sql_mcp/mcp/mcp_sql.py +625 -0
- sql_mcp-2.3.2/sql_mcp/mcp_config.json +26 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/mcp_server.py +21 -11
- sql_mcp-2.3.2/sql_mcp/ontology/__init__.py +8 -0
- sql_mcp-2.3.2/sql_mcp/ontology/certification.json +36 -0
- sql_mcp-2.3.2/sql_mcp/ontology/database.ttl +122 -0
- sql_mcp-2.3.2/sql_mcp/ontology/fixtures/records.json +17 -0
- sql_mcp-2.3.2/sql_mcp/ontology/mappings/source.yaml +20 -0
- sql_mcp-2.3.2/sql_mcp/ontology/migrations/manifest.json +6 -0
- sql_mcp-2.3.2/sql_mcp/ontology/shapes/connector.shacl.ttl +104 -0
- sql_mcp-2.3.2/sql_mcp/prompts/__init__.py +0 -0
- sql_mcp-2.3.2/sql_mcp/prompts/database_specialist.json +44 -0
- sql_mcp-2.3.2/sql_mcp/safety.py +372 -0
- sql_mcp-2.3.2/sql_mcp/skills/__init__.py +0 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-knowledge-graph-ingestion/SKILL.md +89 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-knowledge-graph-ingestion/WORKFLOW.md +78 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-operations/SKILL.md +33 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-operations/agents/openai.yaml +4 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-operations/references/catalog.md +7 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-query-execution/SKILL.md +93 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-query-execution/WORKFLOW.md +79 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-schema-inspection/SKILL.md +88 -0
- sql_mcp-2.3.2/sql_mcp/skills/sql-mcp-schema-inspection/WORKFLOW.md +75 -0
- sql_mcp-2.3.2/sql_mcp/sql_input_models.py +129 -0
- sql_mcp-2.3.2/sql_mcp/sql_response_models.py +49 -0
- sql_mcp-2.3.2/sql_mcp.egg-info/PKG-INFO +381 -0
- sql_mcp-2.3.2/sql_mcp.egg-info/SOURCES.txt +62 -0
- sql_mcp-2.3.2/sql_mcp.egg-info/entry_points.txt +14 -0
- sql_mcp-2.3.2/sql_mcp.egg-info/requires.txt +27 -0
- sql_mcp-2.3.2/tests/test_api_wrapper.py +746 -0
- sql_mcp-2.3.2/tests/test_auth.py +379 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/tests/test_dialect_paths.py +67 -1
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/tests/test_dialects.py +4 -3
- sql_mcp-2.3.2/tests/test_identity_context_scoping.py +84 -0
- sql_mcp-2.3.2/tests/test_kg_ingest.py +287 -0
- sql_mcp-2.3.2/tests/test_kg_pgwire.py +59 -0
- sql_mcp-2.3.2/tests/test_package_getattr.py +76 -0
- sql_mcp-2.3.2/tests/test_safety.py +207 -0
- sql_mcp-2.3.2/tests/test_sql_mcp_validation.py +406 -0
- sql_mcp-2.3.2/tests/test_startup.py +72 -0
- sql_mcp-2.3.2/tests/test_verify_api_integration.py +266 -0
- sql_mcp-0.5.0/PKG-INFO +0 -257
- sql_mcp-0.5.0/README.md +0 -219
- sql_mcp-0.5.0/pyproject.toml +0 -61
- sql_mcp-0.5.0/sql_mcp/__main__.py +0 -4
- sql_mcp-0.5.0/sql_mcp/agent_server.py +0 -71
- sql_mcp-0.5.0/sql_mcp/api/api_client_sql.py +0 -469
- sql_mcp-0.5.0/sql_mcp/auth.py +0 -142
- sql_mcp-0.5.0/sql_mcp/main_agent.json +0 -14
- sql_mcp-0.5.0/sql_mcp/mcp/mcp_sql.py +0 -224
- sql_mcp-0.5.0/sql_mcp/mcp_config.json +0 -33
- sql_mcp-0.5.0/sql_mcp/safety.py +0 -173
- sql_mcp-0.5.0/sql_mcp/sql_input_models.py +0 -63
- sql_mcp-0.5.0/sql_mcp/sql_response_models.py +0 -51
- sql_mcp-0.5.0/sql_mcp.egg-info/PKG-INFO +0 -257
- sql_mcp-0.5.0/sql_mcp.egg-info/SOURCES.txt +0 -36
- sql_mcp-0.5.0/sql_mcp.egg-info/entry_points.txt +0 -3
- sql_mcp-0.5.0/sql_mcp.egg-info/requires.txt +0 -30
- sql_mcp-0.5.0/tests/test_api_wrapper.py +0 -272
- sql_mcp-0.5.0/tests/test_auth.py +0 -160
- sql_mcp-0.5.0/tests/test_concept_parity.py +0 -28
- sql_mcp-0.5.0/tests/test_safety.py +0 -98
- sql_mcp-0.5.0/tests/test_sql_mcp_validation.py +0 -187
- sql_mcp-0.5.0/tests/test_startup.py +0 -30
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/LICENSE +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/setup.cfg +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/api/__init__.py +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/api_client.py +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp/mcp/__init__.py +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp.egg-info/dependency_links.txt +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/sql_mcp.egg-info/top_level.txt +0 -0
- {sql_mcp-0.5.0 → sql_mcp-2.3.2}/tests/test_init_dynamics.py +0 -0
sql_mcp-2.3.2/PKG-INFO
ADDED
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sql-mcp
|
|
3
|
+
Version: 2.3.2
|
|
4
|
+
Summary: Generic SQL database (Postgres, MySQL/MariaDB, MSSQL, Oracle, SQLite) API + MCP Server for Agentic AI!
|
|
5
|
+
Author-email: Project Maintainers <maintainers@users.noreply.github.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.12
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: agent-connector-sdk[mcp]<1.0.0,>=0.3.5
|
|
16
|
+
Requires-Dist: python-dotenv>=1.2.4
|
|
17
|
+
Requires-Dist: sqlalchemy>=2.1.5
|
|
18
|
+
Provides-Extra: mcp
|
|
19
|
+
Requires-Dist: agent-connector-sdk[mcp]<1.0.0,>=0.3.5; extra == "mcp"
|
|
20
|
+
Provides-Extra: postgres
|
|
21
|
+
Requires-Dist: psycopg[binary]>=3.3.6; extra == "postgres"
|
|
22
|
+
Provides-Extra: mysql
|
|
23
|
+
Requires-Dist: pymysql>=1.2.3; extra == "mysql"
|
|
24
|
+
Provides-Extra: mssql
|
|
25
|
+
Requires-Dist: pyodbc>=5.3.0; extra == "mssql"
|
|
26
|
+
Provides-Extra: oracle
|
|
27
|
+
Requires-Dist: oracledb>=26.0.1; extra == "oracle"
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: sql-mcp[mcp,mssql,mysql,oracle,postgres]>=1.0.0; extra == "all"
|
|
30
|
+
Provides-Extra: test
|
|
31
|
+
Requires-Dist: pytest-xdist>=3.8.0; extra == "test"
|
|
32
|
+
Requires-Dist: pytest>=9.1.1; extra == "test"
|
|
33
|
+
Requires-Dist: pytest-asyncio>=1.4.0; extra == "test"
|
|
34
|
+
Requires-Dist: pytest-cov>=7.1.0; extra == "test"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Sql Mcp
|
|
38
|
+
## Table of Contents
|
|
39
|
+
|
|
40
|
+
- [Overview](#overview)
|
|
41
|
+
- [What it provides](#what-it-provides)
|
|
42
|
+
- [MCP tools](#mcp-tools)
|
|
43
|
+
- [Dialects & extras](#dialects--extras)
|
|
44
|
+
- [Configuration (environment)](#configuration-environment)
|
|
45
|
+
- [Installation](#installation)
|
|
46
|
+
- [Usage](#usage)
|
|
47
|
+
- [MCP config](#mcp-config)
|
|
48
|
+
- [Docker deployment](#docker-deployment)
|
|
49
|
+
- [Safety model](#safety-model)
|
|
50
|
+
- [Tests](#tests)
|
|
51
|
+
|
|
52
|
+
## Overview
|
|
53
|
+
|
|
54
|
+
`sql-mcp` exposes read-only queries, gated DML/DDL, schema reflection, and
|
|
55
|
+
connection administration as typed, deterministic MCP tools, and ships an optional
|
|
56
|
+
statement-type allowlist, every result is bounded by a row cap and a timeout, and
|
|
57
|
+
all values travel as bound parameters — never interpolated into SQL strings.
|
|
58
|
+
|
|
59
|
+
## What it provides
|
|
60
|
+
|
|
61
|
+
- **`SqlApi`** (`sql_mcp.api.api_client_sql`) — a SQLAlchemy 2.x Core facade with
|
|
62
|
+
named multi-connection support, lazy engine creation, the read-only statement
|
|
63
|
+
gate, row-cap/timeout enforcement, and bounded result envelopes
|
|
64
|
+
(`{columns, rows, row_count, truncated}`).
|
|
65
|
+
- **Four MCP tools** (`sql-mcp` console script): `sql_query` (run/explain),
|
|
66
|
+
`sql_execute` (run/script — gated by `SQL_ALLOW_WRITES`), `sql_schema`
|
|
67
|
+
(schemas/tables/views/columns/indexes/foreign_keys/ddl/sample), and `sql_admin`
|
|
68
|
+
(ping/version/active_connections/connections/dialects). See
|
|
69
|
+
[`docs/usage.md`](docs/usage.md) for the full action surface.
|
|
70
|
+
- **A dialect registry** (`sql_mcp.dialects`) — per-engine driver, URL scheme, pip
|
|
71
|
+
extra, EXPLAIN prefix, and admin SQL. Core ships SQLite only; the other drivers
|
|
72
|
+
install via extras.
|
|
73
|
+
wired to the MCP server via `MCP_URL`.
|
|
74
|
+
|
|
75
|
+
## MCP tools
|
|
76
|
+
|
|
77
|
+
The table below is auto-generated from the MCP server — do not edit by hand.
|
|
78
|
+
|
|
79
|
+
<!-- MCP-TOOLS-TABLE:START -->
|
|
80
|
+
|
|
81
|
+
#### Condensed action-routed tools (default — `MCP_TOOL_MODE=condensed`)
|
|
82
|
+
|
|
83
|
+
| MCP Tool | Toggle Env Var | Description |
|
|
84
|
+
|----------|----------------|-------------|
|
|
85
|
+
| `sql_admin` | `SQLTOOL` | Connection health, server version, sessions, and registry info. |
|
|
86
|
+
| `sql_schema` | `SQLTOOL` | Inspect schemas, tables, views, columns, indexes, FKs, and DDL. |
|
|
87
|
+
|
|
88
|
+
#### Verbose 1:1 API-mapped tools (`MCP_TOOL_MODE=verbose` or `both`)
|
|
89
|
+
|
|
90
|
+
<details>
|
|
91
|
+
<summary>22 per-operation tools — one per public API method (click to expand)</summary>
|
|
92
|
+
|
|
93
|
+
| MCP Tool | Toggle Env Var | Description |
|
|
94
|
+
|----------|----------------|-------------|
|
|
95
|
+
| `sql_active_connections` | `SQL_APITOOL` | List active server sessions where the dialect supports it. |
|
|
96
|
+
| `sql_connection_names` | `SQL_APITOOL` | Names of all configured connections. |
|
|
97
|
+
| `sql_default_connection` | `SQL_APITOOL` | The sole/first configured connection — used when none is named. |
|
|
98
|
+
| `sql_describe_connections` | `SQL_APITOOL` | Describe configured connections with passwords redacted. |
|
|
99
|
+
| `sql_dialect_spec` | `SQL_APITOOL` | The registered :class:`DialectSpec` for a connection, if any. |
|
|
100
|
+
| `sql_dispose` | `SQL_APITOOL` | Dispose all pooled engines. |
|
|
101
|
+
| `sql_engine` | `SQL_APITOOL` | Lazily create (and cache) the Engine for a named connection. |
|
|
102
|
+
| `sql_execute` | `SQLTOOL` | Execute one DML/DDL statement in a transaction (writes gate applies). |
|
|
103
|
+
| `sql_execute_script` | `SQL_APITOOL` | Run several statements in ONE transaction (all-or-nothing). |
|
|
104
|
+
| `sql_explain` | `SQL_APITOOL` | Return the dialect's query plan for a read-only statement. |
|
|
105
|
+
| `sql_list_columns` | `SQL_APITOOL` | Describe a table's columns: name, type, nullable, default. |
|
|
106
|
+
| `sql_list_foreign_keys` | `SQL_APITOOL` | List a table's foreign keys (columns -> referred table/columns). |
|
|
107
|
+
| `sql_list_indexes` | `SQL_APITOOL` | List a table's indexes (name, columns, uniqueness). |
|
|
108
|
+
| `sql_list_schemas` | `SQL_APITOOL` | List schema names. |
|
|
109
|
+
| `sql_list_tables` | `SQL_APITOOL` | List table names (optionally within a schema). |
|
|
110
|
+
| `sql_list_views` | `SQL_APITOOL` | List view names (optionally within a schema). |
|
|
111
|
+
| `sql_ping` | `SQL_APITOOL` | Connection test: ``SELECT 1`` round-trip with latency. |
|
|
112
|
+
| `sql_query` | `SQLTOOL` | Execute a read-only SELECT/CTE with bound parameters. |
|
|
113
|
+
| `sql_resolve_connection` | `SQL_APITOOL` | Map an optional connection name to a configured one (or raise). |
|
|
114
|
+
| `sql_sample_rows` | `SQL_APITOOL` | Return up to ``limit`` rows from a table (cap still applies). |
|
|
115
|
+
| `sql_server_version` | `SQL_APITOOL` | Report the server version (dialect SQL, else SQLAlchemy's probe). |
|
|
116
|
+
| `sql_table_ddl` | `SQL_APITOOL` | Reflect a table and render its CREATE TABLE DDL for this dialect. |
|
|
117
|
+
|
|
118
|
+
</details>
|
|
119
|
+
|
|
120
|
+
_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._
|
|
121
|
+
<!-- MCP-TOOLS-TABLE:END -->
|
|
122
|
+
|
|
123
|
+
Every tool takes `action`, `params_json`, and an optional `connection` naming one
|
|
124
|
+
of the configured connections. The whole set is toggled with `SQLTOOL`.
|
|
125
|
+
|
|
126
|
+
## Dialects & extras
|
|
127
|
+
|
|
128
|
+
| Dialect | SQLAlchemy scheme | Driver | Install |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| SQLite | `sqlite+pysqlite` | stdlib | `pip install sql-mcp` (core) |
|
|
131
|
+
| PostgreSQL | `postgresql+psycopg` | psycopg 3 | `pip install sql-mcp[postgres]` |
|
|
132
|
+
| MySQL / MariaDB | `mysql+pymysql` | PyMySQL | `pip install sql-mcp[mysql]` |
|
|
133
|
+
| SQL Server | `mssql+pyodbc` | pyodbc | `pip install sql-mcp[mssql]` |
|
|
134
|
+
| Oracle | `oracle+oracledb` | python-oracledb | `pip install sql-mcp[oracle]` |
|
|
135
|
+
|
|
136
|
+
`pip install sql-mcp[all]` pulls every driver plus the MCP and agent extras.
|
|
137
|
+
|
|
138
|
+
## Configuration (environment)
|
|
139
|
+
|
|
140
|
+
| Var | Default | Meaning |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `SQL_CONNECTIONS` | _(empty)_ | JSON map of named connections: DSN strings or `{dialect, host, port, username, password, database, options}` objects |
|
|
143
|
+
| `SQL_URL` | _(empty)_ | Single DSN registered as connection `default` |
|
|
144
|
+
| `SQL_DIALECT` / `SQL_HOST` / `SQL_PORT` / `SQL_USERNAME` / `SQL_PASSWORD` / `SQL_DATABASE` / `SQL_OPTIONS` | _(empty)_ | Discrete fields for a single `default` connection |
|
|
145
|
+
| `SQL_ALLOW_WRITES` | `False` | Enable `sql_execute` (DML/DDL). **Read-only by default** |
|
|
146
|
+
| `SQL_MAX_ROWS` | `500` | Per-call row cap; tool requests are clamped to it |
|
|
147
|
+
| `SQL_TIMEOUT_SECONDS` | `30` | Per-statement timeout |
|
|
148
|
+
| `SQLTOOL` | `True` | Register the SQL tool set |
|
|
149
|
+
|
|
150
|
+
With nothing configured the server registers a zero-infra in-memory SQLite
|
|
151
|
+
connection named `memory`, so it works by default. Tools take an optional
|
|
152
|
+
`connection` parameter naming one of the configured connections; it defaults to
|
|
153
|
+
the sole/first one. Passwords are parsed into `sqlalchemy.URL` objects and only
|
|
154
|
+
ever rendered redacted. Copy [`.env.example`](.env.example) to `.env` and
|
|
155
|
+
populate only what the operator use.
|
|
156
|
+
|
|
157
|
+
## Installation
|
|
158
|
+
|
|
159
|
+
Pick the extra that matches what the operator want to run. DB-driver extras
|
|
160
|
+
(`postgres` / `mysql` / `mssql` / `oracle`) are **additive** — combine them with
|
|
161
|
+
|
|
162
|
+
| Extra | Installs | Use when |
|
|
163
|
+
|-------|----------|----------|
|
|
164
|
+
| `sql-mcp[mcp]` | Connector-focused MCP server (`agent-connector-sdk` — FastMCP/FastAPI + `epistemic-graph[full]`) | The operator only run the **MCP server** (smallest install / image) |
|
|
165
|
+
| `sql-mcp[all]` | Everything (`mcp` + `agent` + **every** DB driver + `logfire`) | Development / both surfaces |
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pip install sql-mcp # core (SQLite only, MCP server, API)
|
|
169
|
+
pip install "sql-mcp[mcp]" # connector-focused MCP server (add drivers: [mcp,postgres])
|
|
170
|
+
pip install "sql-mcp[all]" # every driver + MCP + agent extras
|
|
171
|
+
pip install -e . # from source
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Container images (`:mcp`)
|
|
175
|
+
|
|
176
|
+
One multi-stage `docker/Dockerfile` builds the MCP-only image (`--target mcp`):
|
|
177
|
+
|
|
178
|
+
| Image tag | Build target | Contents | Entrypoint |
|
|
179
|
+
|-----------|--------------|----------|------------|
|
|
180
|
+
| `example/sql-mcp:mcp` | `--target mcp` | `sql-mcp[mcp]` — **connector-focused**, includes `epistemic-graph[full]`; no model-orchestration stack | `sql-mcp` |
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
docker pull example/sql-mcp:mcp # connector-focused MCP server
|
|
184
|
+
docker build --target mcp -t example/sql-mcp:mcp docker/ # build MCP server
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
agent (`immutable agent digest`) with a co-located `:mcp` sidecar.
|
|
188
|
+
|
|
189
|
+
### Knowledge-graph database (`epistemic-graph`)
|
|
190
|
+
|
|
191
|
+
Agent Connector SDK core dependency (`epistemic-graph[full]`). The `[mcp]` extra keeps
|
|
192
|
+
deployments can use the bundled engine. For production or shared state, run
|
|
193
|
+
**epistemic-graph as a dedicated database service** and configure the runtime to use it.
|
|
194
|
+
Deployment recipes (single-node + Raft HA), connection configuration, and architecture
|
|
195
|
+
diagrams are documented in the
|
|
196
|
+
[epistemic-graph deployment guide](https://knuckles-team.github.io/epistemic-graph/deployment/).
|
|
197
|
+
|
|
198
|
+
## Usage
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
sql-mcp # stdio MCP server (default transport)
|
|
202
|
+
sql-mcp --transport streamable-http --host 0.0.0.0 --port 8000
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Point it at a database:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
export SQL_URL="postgresql+psycopg://svc:****@db.example.com:5432/app"
|
|
209
|
+
sql-mcp
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Or multiple:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
export SQL_CONNECTIONS='{
|
|
216
|
+
"warehouse": "postgresql+psycopg://svc:****@dw.example.com:5432/dw",
|
|
217
|
+
"erp": {"dialect": "mysql", "host": "erp.example.com", "username": "svc",
|
|
218
|
+
"password": "****", "database": "erp"}
|
|
219
|
+
}'
|
|
220
|
+
sql-mcp
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## MCP config
|
|
224
|
+
|
|
225
|
+
> **Install the connector-focused `[mcp]` extra.** Examples use `sql-mcp[mcp]` to add
|
|
226
|
+
> FastMCP / FastAPI through `agent-connector-sdk`; the required Agent Connector SDK core
|
|
227
|
+
> enables model orchestration.
|
|
228
|
+
> Combine it with the database-driver extras needed by the deployment.
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"mcpServers": {
|
|
233
|
+
"sql-mcp": {
|
|
234
|
+
"command": "uv",
|
|
235
|
+
"args": ["run", "sql-mcp"],
|
|
236
|
+
"env": {
|
|
237
|
+
"SQL_URL": "postgresql+psycopg://svc:****@db.example.com:5432/app",
|
|
238
|
+
"SQL_ALLOW_WRITES": "False"
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
<!-- BEGIN GENERATED: additional-deployment-options -->
|
|
246
|
+
### Additional Deployment Options
|
|
247
|
+
|
|
248
|
+
`sql-mcp` can run as a local stdio process or container, or behind a remote
|
|
249
|
+
network boundary. The
|
|
250
|
+
[Deployment guide](https://knuckles-team.github.io/sql-mcp/deployment/) carries
|
|
251
|
+
the detailed transport contract.
|
|
252
|
+
|
|
253
|
+
- **Local container** — launch a reviewed immutable image as a least-privilege
|
|
254
|
+
stdio child with no listener or published port.
|
|
255
|
+
- **Remote URL** — connect through an operator-supplied authenticated HTTPS
|
|
256
|
+
ingress. Keep its URL, outbound identity references, trust profile, and exact
|
|
257
|
+
`MCP_ALLOWED_HOSTS` in `AgentConfig`.
|
|
258
|
+
<!-- END GENERATED: additional-deployment-options -->
|
|
259
|
+
|
|
260
|
+
## Docker deployment
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
docker compose -f docker/mcp.compose.yml up -d # MCP server only
|
|
264
|
+
curl -s http://localhost:8000/health # {"status":"OK"}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Both services read configuration from `../.env` (copy
|
|
268
|
+
[`.env.example`](.env.example)); see [`docs/deployment.md`](docs/deployment.md).
|
|
269
|
+
|
|
270
|
+
## Safety model
|
|
271
|
+
|
|
272
|
+
- **Read-only by default** — `sql_execute` refuses to run unless the *server* was
|
|
273
|
+
started with `SQL_ALLOW_WRITES=True`; agents cannot flip the flag per call.
|
|
274
|
+
- **Statement allowlist** — `sql_query` accepts only `SELECT`/`WITH`/`EXPLAIN`/
|
|
275
|
+
`SHOW`/`DESCRIBE`/`PRAGMA`/`VALUES`; CTEs are inspected at paren depth zero so
|
|
276
|
+
`WITH ... INSERT` cannot smuggle a write, `SELECT INTO` is rejected, and
|
|
277
|
+
multi-statement payloads are refused.
|
|
278
|
+
- **Bounded results** — per-call row caps clamp to `SQL_MAX_ROWS`; statements run
|
|
279
|
+
under `SQL_TIMEOUT_SECONDS` on a worker thread.
|
|
280
|
+
- **Parameterized only** — values bind via `:name` parameters; identifiers are
|
|
281
|
+
quoted by SQLAlchemy reflection, never hand-interpolated.
|
|
282
|
+
|
|
283
|
+
## Tests
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
python -m pytest # full suite against in-memory SQLite (no live DBs)
|
|
287
|
+
pre-commit run --all-files
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
<!-- BEGIN agent-connector-sdk-deployment (generated; do not edit between markers) -->
|
|
291
|
+
|
|
292
|
+
## Deploy with `agent-connector-sdk-deployment`
|
|
293
|
+
|
|
294
|
+
Provision this package with the consolidated **`agent-connector-sdk-deployment`**
|
|
295
|
+
workflow. It selects an installed-package, editable-source, or immutable-container
|
|
296
|
+
path; records only runtime secret and TLS-profile references in `AgentConfig`; and
|
|
297
|
+
runs doctor, registration, policy, observability, and rollback gates. Ask your agent
|
|
298
|
+
to **"deploy `sql-mcp` with agent-connector-sdk-deployment"**.
|
|
299
|
+
|
|
300
|
+
| Install mode | Command |
|
|
301
|
+
|------|---------|
|
|
302
|
+
| Installed package | `uv tool install "sql-mcp[mcp]"`, then run `sql-mcp` |
|
|
303
|
+
| Immutable container | deploy `registry.example.invalid/sql-mcp@sha256:<digest>` through the operator-selected orchestrator |
|
|
304
|
+
|
|
305
|
+
The repository embeds no deployment profile, credential value, certificate path, or
|
|
306
|
+
environment-specific endpoint. Supply those at runtime through `AgentConfig` and the
|
|
307
|
+
configured secret provider.
|
|
308
|
+
|
|
309
|
+
<!-- END agent-connector-sdk-deployment -->
|
|
310
|
+
|
|
311
|
+
## Environment Variables
|
|
312
|
+
|
|
313
|
+
<!-- ENV-VARS-TABLE:START -->
|
|
314
|
+
|
|
315
|
+
#### Package environment variables
|
|
316
|
+
|
|
317
|
+
| Variable | Example | Description |
|
|
318
|
+
|----------|---------|-------------|
|
|
319
|
+
| `HOST` | `0.0.0.0` | |
|
|
320
|
+
| `PORT` | `8000` | |
|
|
321
|
+
| `TRANSPORT` | `stdio` | options: stdio, streamable-http, sse |
|
|
322
|
+
| `ENABLE_OTEL` | `True` | |
|
|
323
|
+
| `OTEL_EXPORTER_OTLP_ENDPOINT` | `http://localhost:8080/api/public/otel` | |
|
|
324
|
+
| `OTEL_EXPORTER_OTLP_PUBLIC_KEY` | secret-injected | |
|
|
325
|
+
| `OTEL_EXPORTER_OTLP_SECRET_KEY` | secret-injected | |
|
|
326
|
+
| `OTEL_EXPORTER_OTLP_PROTOCOL` | `http/protobuf` | |
|
|
327
|
+
| `EUNOMIA_TYPE` | `none` | options: none, embedded, remote |
|
|
328
|
+
| `EUNOMIA_POLICY_FILE` | `mcp_policies.json` | |
|
|
329
|
+
| `EUNOMIA_REMOTE_URL` | `http://eunomia-server:8000` | |
|
|
330
|
+
| `SQL_CONNECTIONS` | `{"warehouse": "postgresql+psycopg://svc:password@db:5432/dw"}` | Named connections (JSON). DSN strings or {dialect, host, port, username, password, database, options} objects. Takes priority over SQL_URL. |
|
|
331
|
+
| `SQL_URL` | `postgresql+psycopg://svc:password@db.example.com:5432/app` | Single connection (registered as "default") |
|
|
332
|
+
| `SQL_DIALECT` | `postgres` | ... or discrete fields for a single "default" connection |
|
|
333
|
+
| `SQL_HOST` | `db.example.com` | |
|
|
334
|
+
| `SQL_PORT` | `5432` | |
|
|
335
|
+
| `SQL_USERNAME` | `svc` | |
|
|
336
|
+
| `SQL_PASSWORD` | secret-injected | |
|
|
337
|
+
| `SQL_DATABASE` | `app` | |
|
|
338
|
+
| `SQL_OPTIONS` | `{"sslmode": "require"}` | |
|
|
339
|
+
| `SQL_ALLOW_WRITES` | `False` | Policy (read-only by default) |
|
|
340
|
+
| `SQL_MAX_ROWS` | `500` | |
|
|
341
|
+
| `SQL_TIMEOUT_SECONDS` | `30` | |
|
|
342
|
+
| `SQLTOOL` | `True` | |
|
|
343
|
+
|
|
344
|
+
#### Inherited agent-connector-sdk variables (apply to every connector)
|
|
345
|
+
|
|
346
|
+
| Variable | Example | Description |
|
|
347
|
+
|----------|---------|-------------|
|
|
348
|
+
| `MCP_TOOL_MODE` | `intent` | Tool surface: `intent` \| `condensed` \| `verbose` \| `both` |
|
|
349
|
+
| `MCP_ENABLED_TOOLS` | — | Comma-separated tool allow-list |
|
|
350
|
+
| `MCP_DISABLED_TOOLS` | — | Comma-separated tool deny-list |
|
|
351
|
+
| `MCP_ENABLED_TAGS` | — | Comma-separated tag allow-list |
|
|
352
|
+
| `MCP_DISABLED_TAGS` | — | Comma-separated tag deny-list |
|
|
353
|
+
| `MCP_CLIENT_AUTH` | — | Outbound MCP child auth: `oidc-client-credentials` \| `basic` \| `none` |
|
|
354
|
+
| `OIDC_CLIENT_ID` | — | OIDC client id (service-account auth) |
|
|
355
|
+
| `OIDC_CLIENT_SECRET_REF` | `secret://identity/oidc-client-secret` | Runtime secret reference for the OIDC service account |
|
|
356
|
+
| `MCP_BASIC_AUTH_USERNAME` | — | HTTP Basic username (`MCP_CLIENT_AUTH=basic`) |
|
|
357
|
+
| `MCP_BASIC_AUTH_PASSWORD_REF` | `secret://identity/mcp-basic-password` | Runtime secret reference for HTTP Basic auth (`MCP_CLIENT_AUTH=basic`) |
|
|
358
|
+
| `DEBUG` | `False` | Verbose logging |
|
|
359
|
+
| `PYTHONUNBUFFERED` | `1` | Unbuffered stdout (recommended in containers) |
|
|
360
|
+
| `MCP_URL` | `http://localhost:8000/mcp` | URL of the MCP server the agent connects to |
|
|
361
|
+
| `PROVIDER` | `openai` | LLM provider for the agent |
|
|
362
|
+
| `MODEL_ID` | `gpt-4o` | Model id for the agent |
|
|
363
|
+
|
|
364
|
+
_24 package + 16 inherited variable(s). Auto-generated from `.env.example` + the shared agent-connector-sdk set — do not edit._
|
|
365
|
+
<!-- ENV-VARS-TABLE:END -->
|
|
366
|
+
|
|
367
|
+
<!-- GOVERNED-CAPABILITY:START -->
|
|
368
|
+
## Governed capability contract
|
|
369
|
+
|
|
370
|
+
This package ships a compact canonical skill surface with specialist procedures
|
|
371
|
+
kept as referenced workflows. The current MCP tools, skill metadata,
|
|
372
|
+
`connector_manifest.yml`, ontology, mappings, shapes, fixtures, migrations,
|
|
373
|
+
tool-schema fingerprints, and certification metadata form one versioned
|
|
374
|
+
capability contract. Validate them together; do not rely on stale tool names or
|
|
375
|
+
historical per-task skill wrappers.
|
|
376
|
+
|
|
377
|
+
Runtime endpoints, credentials, certificate trust, tenant identity, retention,
|
|
378
|
+
and observability policy are deployment inputs and are never packaged values.
|
|
379
|
+
See [Configuration, trust, and privacy](docs/configuration.md) before enabling a
|
|
380
|
+
network transport, connector ingestion, Arbora delegation, or trace export.
|
|
381
|
+
<!-- GOVERNED-CAPABILITY:END -->
|