sql-query-mcp 0.1.1__py3-none-any.whl

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.
@@ -0,0 +1,235 @@
1
+ Metadata-Version: 2.4
2
+ Name: sql-query-mcp
3
+ Version: 0.1.1
4
+ Summary: Read-only SQL MCP server for PostgreSQL and MySQL.
5
+ Author: Andy Wang
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/andyWang1688/sql-query-mcp
8
+ Project-URL: Repository, https://github.com/andyWang1688/sql-query-mcp
9
+ Project-URL: Documentation, https://github.com/andyWang1688/sql-query-mcp/blob/main/README.md
10
+ Project-URL: Issues, https://github.com/andyWang1688/sql-query-mcp/issues
11
+ Keywords: mcp,mcp-server,sql,database,postgresql,mysql,cli,codex,chatgpt
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Database
19
+ Classifier: Environment :: Console
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: mcp>=1.12.4
24
+ Requires-Dist: PyMySQL>=1.1
25
+ Requires-Dist: psycopg[binary]>=3.2
26
+ Requires-Dist: psycopg-pool>=3.2
27
+ Requires-Dist: sqlglot>=25.20.2
28
+ Requires-Dist: tomli>=2; python_version < "3.11"
29
+ Dynamic: license-file
30
+
31
+ # sql-query-mcp
32
+
33
+ [中文版](README-zh.md)
34
+
35
+ A general-purpose MCP server that lets AI work with multiple databases within
36
+ clear boundaries.
37
+
38
+ ## Current database support
39
+
40
+ | Database | Status | Current availability |
41
+ | --- | --- | --- |
42
+ | PostgreSQL | Supported | Available today |
43
+ | MySQL | Supported | Available today |
44
+ | SQLite | Candidate | Not supported yet |
45
+ | SQL Server | Candidate | Not supported yet |
46
+ | ClickHouse | Candidate | Not supported yet |
47
+
48
+ ## Product value
49
+
50
+ `sql-query-mcp` helps AI clients discover schema, sample data, and analyze
51
+ read-only queries through one controlled MCP interface.
52
+
53
+ It keeps connection handling, namespace rules, SQL validation, and audit
54
+ logging on the server side, so you can expose useful database context to AI
55
+ without exposing raw connection strings or flattening engine-specific concepts.
56
+
57
+ ## What AI can do with it
58
+
59
+ The current tool set focuses on database discovery and controlled query
60
+ workflows. You can use it to help an AI assistant understand structure before
61
+ it generates or refines SQL.
62
+
63
+ MySQL supports `explain_query`, but not `explain_query(..., analyze=True)` in
64
+ the current implementation.
65
+
66
+ | Tool | PostgreSQL | MySQL | Purpose |
67
+ | --- | --- | --- | --- |
68
+ | `list_connections()` | Yes | Yes | List configured connections |
69
+ | `list_schemas(connection_id)` | Yes | No | List visible PostgreSQL schemas |
70
+ | `list_databases(connection_id)` | No | Yes | List visible MySQL databases |
71
+ | `list_tables(connection_id, schema?, database?)` | Yes | Yes | List tables and views |
72
+ | `describe_table(connection_id, table_name, schema?, database?)` | Yes | Yes | Inspect columns, keys, and indexes |
73
+ | `run_select(connection_id, sql, limit?)` | Yes | Yes | Run read-only queries |
74
+ | `explain_query(connection_id, sql, analyze?)` | Yes | Yes | Inspect query plans |
75
+ | `get_table_sample(connection_id, table_name, schema?, database?, limit?)` | Yes | Yes | Fetch small table samples |
76
+
77
+ These tools are useful for tasks such as listing namespaces, inspecting table
78
+ definitions, reviewing indexes, sampling records, and analyzing read-only
79
+ queries with `EXPLAIN`. For full request and response details, see
80
+ `docs/api-reference.md` (Chinese).
81
+
82
+ ## How boundaries are constrained
83
+
84
+ The product boundary is intentionally narrow today. Only PostgreSQL and MySQL
85
+ are available today, and the current tool set is fully read-only.
86
+
87
+ The service keeps those boundaries explicit in a few ways.
88
+
89
+ - Connections declare `engine` explicitly, so the server never guesses from
90
+ `connection_id`.
91
+ - PostgreSQL uses `schema`, and MySQL uses `database`, without collapsing both
92
+ into one vague namespace field.
93
+ - Real DSNs stay in environment variables, while config files store only the
94
+ environment variable names.
95
+ - Query execution passes through `sqlglot` validation before reaching the
96
+ database.
97
+ - The server accepts only `SELECT` and `WITH ... SELECT`, rejects comments and
98
+ multi-statement input, and records audit logs for each call.
99
+
100
+ For MySQL, `explain_query(..., analyze=True)` is not available in the current
101
+ implementation.
102
+
103
+ ## Quick start
104
+
105
+ If you want to get the server running first and explore the rest later, follow
106
+ these steps.
107
+
108
+ 1. Create a virtual environment and install the project.
109
+
110
+ ```bash
111
+ python3.10 -m venv .venv
112
+ source .venv/bin/activate
113
+ python -m pip install --upgrade pip
114
+ pip install sql-query-mcp
115
+ ```
116
+
117
+ Install a specific release with `pip install sql-query-mcp==X.Y.Z` if you want
118
+ to pin a version. Published release artifacts are also attached to each GitHub
119
+ Release.
120
+
121
+ 2. Copy the example connection config.
122
+
123
+ ```bash
124
+ cp config/connections.example.json config/connections.json
125
+ ```
126
+
127
+ 3. Export your database DSNs as environment variables.
128
+
129
+ These example names match the copied `config/connections.example.json` file.
130
+
131
+ ```bash
132
+ export PG_CONN_CRM_PROD_MUQIAO_RO='postgresql://user:password@host:5432/dbname'
133
+ export MYSQL_CONN_CRM_PROD_MUQIAO_RO='mysql://user:password@host:3306/crm'
134
+ export SQL_QUERY_MCP_CONFIG='/absolute/path/to/sql-query-mcp/config/connections.json'
135
+ ```
136
+
137
+ 4. Register the server in your MCP client.
138
+
139
+ - Codex: `docs/codex-setup.md` (Chinese)
140
+ - OpenCode: `docs/opencode-setup.md` (Chinese)
141
+
142
+ The console entry point is `sql-query-mcp`, which maps to
143
+ `sql_query_mcp.app:main`.
144
+
145
+ The PyPI install name is `sql-query-mcp`, and the Python package import path is
146
+ `sql_query_mcp`.
147
+
148
+ The default config path is `config/connections.json`. If you need a different
149
+ location, set `SQL_QUERY_MCP_CONFIG`.
150
+
151
+ The example config looks like this.
152
+
153
+ ```json
154
+ {
155
+ "settings": {
156
+ "default_limit": 200,
157
+ "max_limit": 1000,
158
+ "audit_log_path": "logs/audit.jsonl"
159
+ },
160
+ "connections": [
161
+ {
162
+ "connection_id": "crm_prod_muqiao_ro",
163
+ "engine": "postgres",
164
+ "label": "CRM PostgreSQL production / Muqiao / read-only",
165
+ "env": "prod",
166
+ "tenant": "muqiao",
167
+ "role": "ro",
168
+ "dsn_env": "PG_CONN_CRM_PROD_MUQIAO_RO",
169
+ "enabled": true,
170
+ "default_schema": "public"
171
+ },
172
+ {
173
+ "connection_id": "crm_mysql_prod_muqiao_ro",
174
+ "engine": "mysql",
175
+ "label": "CRM MySQL production / Muqiao / read-only",
176
+ "env": "prod",
177
+ "tenant": "muqiao",
178
+ "role": "ro",
179
+ "dsn_env": "MYSQL_CONN_CRM_PROD_MUQIAO_RO",
180
+ "enabled": true,
181
+ "default_database": "crm"
182
+ }
183
+ ]
184
+ }
185
+ ```
186
+
187
+ ## Documentation
188
+
189
+ If you want implementation details, setup guidance, or internal structure, use
190
+ these docs as your starting points.
191
+
192
+ - `docs/project-overview.md`: project goals, concepts, and code structure (Chinese)
193
+ - `docs/api-reference.md`: MCP tool reference (Chinese)
194
+ - `docs/codex-setup.md`: Codex setup steps (Chinese)
195
+ - `docs/opencode-setup.md`: OpenCode setup steps (Chinese)
196
+ - `docs/release-process.md`: PyPI and GitHub Release workflow (Chinese)
197
+ - `docs/git-workflow.md`: repository collaboration workflow (Chinese)
198
+
199
+ ## Development
200
+
201
+ If you want to modify or verify the project locally, use this shortest path.
202
+ Editable install remains the development path, and the local environment still
203
+ requires Python 3.10+.
204
+
205
+ ```bash
206
+ python3.10 -m venv .venv
207
+ source .venv/bin/activate
208
+ python -m pip install --upgrade pip
209
+ pip install -e .
210
+ PYTHONPATH=. python3 -m unittest discover -s tests
211
+ ```
212
+
213
+ The main entry point is `sql_query_mcp/app.py`. Core modules include:
214
+
215
+ - `sql_query_mcp/config.py`: config loading and validation
216
+ - `sql_query_mcp/validator.py`: read-only SQL validation
217
+ - `sql_query_mcp/introspection.py`: metadata inspection
218
+ - `sql_query_mcp/executor.py`: query execution and limits
219
+ - `sql_query_mcp/adapters/`: PostgreSQL and MySQL adapters
220
+
221
+ ## Contributing
222
+
223
+ If you want to contribute or review the repository workflow, start with these
224
+ pages.
225
+
226
+ - `CONTRIBUTING.md`
227
+ - `docs/roadmap.md`
228
+ - `docs/git-workflow.md` (Chinese)
229
+
230
+ Run `PYTHONPATH=. python3 -m unittest discover -s tests` before you submit
231
+ changes.
232
+
233
+ ## License
234
+
235
+ This project is released under the MIT License. See `LICENSE`.
@@ -0,0 +1,21 @@
1
+ sql_query_mcp/__init__.py,sha256=Eb_QoNJG5EBxNk4vA8H6ndIDD7qPpQ4iNi3yTsILaEo,79
2
+ sql_query_mcp/__main__.py,sha256=9SRp-Yw7ShGxc6DhSIXcDLKgGEdAVm3oBZ59rBOPjT0,62
3
+ sql_query_mcp/app.py,sha256=rivQ4No6KzpTQ8ewHDGye2pnbLv-sytPujQ5wzO-wo4,3180
4
+ sql_query_mcp/audit.py,sha256=VwTas2hugs8TsWgse3K56BVhPPCleWGNE8vYh-naxBk,1238
5
+ sql_query_mcp/config.py,sha256=EowPhas29uK0bzZu6Op65lnxCPPwdymr0d7XYHqPkYw,9002
6
+ sql_query_mcp/errors.py,sha256=cfZRUWl4iljfFahJGv1QjqxisUg-LL2d0pbM0nX9jHQ,825
7
+ sql_query_mcp/executor.py,sha256=yraGtfIfcbGjofvwnBZWy_djfnYuPe8hxyuS3eeE3jg,9211
8
+ sql_query_mcp/introspection.py,sha256=PZdZN1JwKny8jXIW9FFilFkH2nnGfzJiI5XhN0sp0ds,8360
9
+ sql_query_mcp/namespace.py,sha256=n1Lj6XgpQmMUpYeMywvINVa6UYHVcLa3hMRzsusdQSM,1639
10
+ sql_query_mcp/registry.py,sha256=lup8rkuP_kkU-M_T0omBifYVFrHUUwu5-LLNsj_2G6Y,2327
11
+ sql_query_mcp/release_metadata.py,sha256=b9q0SJr_zUfJunXTrZHx70FNKNY43yGQ2xz8bchuicI,2659
12
+ sql_query_mcp/validator.py,sha256=Sq0c9MaVnEezdU1AbrTfFoXmqVo9ug1-U0_KxyzKFyE,3859
13
+ sql_query_mcp/adapters/__init__.py,sha256=lEwMmaBnTDuLj3eXicd6rRCifkO4scYvCo8XQdlMm1g,361
14
+ sql_query_mcp/adapters/mysql.py,sha256=YiWmK8WG9kzsiaJmsaZ7f4l0cBcPqq98S6GmoPjM2i4,6101
15
+ sql_query_mcp/adapters/postgres.py,sha256=jBTkyPFu5oBmDQpNCXv1h8bwa2YKfSGA78ePv_8nl8U,6679
16
+ sql_query_mcp-0.1.1.dist-info/licenses/LICENSE,sha256=5CusFN4dwxPOZK9Zxz37uwXDSWDwCC4A8gHmnLqpOZ4,1066
17
+ sql_query_mcp-0.1.1.dist-info/METADATA,sha256=VxF4vVgY8_EY9NILzI38bTmD-PVWniQqyXG9bCXMeEM,8109
18
+ sql_query_mcp-0.1.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
19
+ sql_query_mcp-0.1.1.dist-info/entry_points.txt,sha256=mBOXnUfsGGV9bkZ-8xJq8UrKe_7V2kJRhAel0x2kxSs,57
20
+ sql_query_mcp-0.1.1.dist-info/top_level.txt,sha256=kiFI-HI7u7-YjgvF2PbHY4QTkcHlW8XS0jXOpWjL-H8,14
21
+ sql_query_mcp-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sql-query-mcp = sql_query_mcp.app:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andy Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ sql_query_mcp