mcpg 0.5.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.
- mcpg/__init__.py +3 -0
- mcpg/__main__.py +37 -0
- mcpg/_vendor/LICENSE +21 -0
- mcpg/_vendor/README.md +37 -0
- mcpg/_vendor/__init__.py +6 -0
- mcpg/_vendor/sql/__init__.py +31 -0
- mcpg/_vendor/sql/bind_params.py +816 -0
- mcpg/_vendor/sql/extension_utils.py +246 -0
- mcpg/_vendor/sql/index.py +52 -0
- mcpg/_vendor/sql/safe_sql.py +1036 -0
- mcpg/_vendor/sql/sql_driver.py +276 -0
- mcpg/advisors.py +713 -0
- mcpg/audit.py +1190 -0
- mcpg/audit_trail.py +230 -0
- mcpg/composite.py +475 -0
- mcpg/config.py +551 -0
- mcpg/context.py +20 -0
- mcpg/cron.py +114 -0
- mcpg/cursors.py +296 -0
- mcpg/cypher.py +253 -0
- mcpg/data_movement.py +737 -0
- mcpg/database.py +207 -0
- mcpg/diagrams.py +183 -0
- mcpg/diesel.py +247 -0
- mcpg/drizzle.py +414 -0
- mcpg/ecto.py +287 -0
- mcpg/ent.py +324 -0
- mcpg/extensions.py +83 -0
- mcpg/graph.py +170 -0
- mcpg/graph_diagram.py +157 -0
- mcpg/graph_mgmt.py +116 -0
- mcpg/health.py +147 -0
- mcpg/http_runtime.py +364 -0
- mcpg/indexing.py +155 -0
- mcpg/introspection.py +1214 -0
- mcpg/io_stats.py +129 -0
- mcpg/jooq.py +180 -0
- mcpg/listen.py +378 -0
- mcpg/liveops.py +108 -0
- mcpg/locks.py +163 -0
- mcpg/maintenance.py +66 -0
- mcpg/middleware/rate_limit.py +92 -0
- mcpg/migrations.py +694 -0
- mcpg/naming.py +201 -0
- mcpg/nl2sql.py +506 -0
- mcpg/observability.py +163 -0
- mcpg/oidc.py +181 -0
- mcpg/partman.py +124 -0
- mcpg/policy.py +67 -0
- mcpg/prisma.py +415 -0
- mcpg/query.py +231 -0
- mcpg/replicas.py +360 -0
- mcpg/rls.py +198 -0
- mcpg/schema_diff.py +259 -0
- mcpg/server.py +153 -0
- mcpg/shell.py +262 -0
- mcpg/sqlalchemy_export.py +435 -0
- mcpg/sqlc.py +169 -0
- mcpg/tenancy.py +166 -0
- mcpg/test_data.py +219 -0
- mcpg/textsearch.py +738 -0
- mcpg/timescaledb.py +269 -0
- mcpg/tools.py +1974 -0
- mcpg/vector_tuning.py +263 -0
- mcpg/workload.py +213 -0
- mcpg/write.py +215 -0
- mcpg-0.5.1.dist-info/METADATA +201 -0
- mcpg-0.5.1.dist-info/RECORD +72 -0
- mcpg-0.5.1.dist-info/WHEEL +4 -0
- mcpg-0.5.1.dist-info/entry_points.txt +2 -0
- mcpg-0.5.1.dist-info/licenses/LICENSE +21 -0
- mcpg-0.5.1.dist-info/licenses/src/mcpg/_vendor/LICENSE +21 -0
mcpg/__init__.py
ADDED
mcpg/__main__.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Console entry point for the MCPg server (``mcpg`` / ``python -m mcpg``)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
if sys.platform == "win32":
|
|
9
|
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
10
|
+
|
|
11
|
+
from mcpg import __version__
|
|
12
|
+
from mcpg.config import ConfigError, load_settings
|
|
13
|
+
from mcpg.server import run
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> int:
|
|
17
|
+
"""Load configuration from the environment and run the server.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
A process exit code: 0 on clean shutdown, 1 on a configuration error.
|
|
21
|
+
"""
|
|
22
|
+
# SECURITY.md asks bug reporters to include ``mcpg --version`` in
|
|
23
|
+
# their report; this is the surface that gives them an answer.
|
|
24
|
+
if len(sys.argv) > 1 and sys.argv[1] in {"--version", "-V"}:
|
|
25
|
+
print(f"mcpg {__version__}")
|
|
26
|
+
return 0
|
|
27
|
+
try:
|
|
28
|
+
settings = load_settings()
|
|
29
|
+
except ConfigError as exc:
|
|
30
|
+
print(f"mcpg: configuration error: {exc}", file=sys.stderr)
|
|
31
|
+
return 1
|
|
32
|
+
run(settings)
|
|
33
|
+
return 0
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if __name__ == "__main__": # pragma: no cover
|
|
37
|
+
sys.exit(main())
|
mcpg/_vendor/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Crystal Corp.
|
|
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.
|
mcpg/_vendor/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Vendored code
|
|
2
|
+
|
|
3
|
+
This directory contains third-party code vendored into MCPg. It is **not**
|
|
4
|
+
authored by the MCPg project and is excluded from the coverage gate and from
|
|
5
|
+
`mypy --strict`.
|
|
6
|
+
|
|
7
|
+
## `sql/` — PostgreSQL SQL-safety kernel
|
|
8
|
+
|
|
9
|
+
- **Source:** [`crystaldba/postgres-mcp`](https://github.com/crystaldba/postgres-mcp)
|
|
10
|
+
- **Pinned commit:** `07eb329c8c48e49640e0d1b5b35465d4d024c3ee` (2026-01-22)
|
|
11
|
+
- **Licence:** MIT — see [`LICENSE`](LICENSE) (Copyright (c) 2025, Crystal Corp.)
|
|
12
|
+
- **What it is:** the `pglast`-based SQL allowlist validator (`safe_sql.py`),
|
|
13
|
+
async connection pool / driver (`sql_driver.py`), parameter binding
|
|
14
|
+
(`bind_params.py`), and extension utilities. See ADR-0001 for why only this
|
|
15
|
+
subpackage was vendored.
|
|
16
|
+
|
|
17
|
+
### Local modifications
|
|
18
|
+
|
|
19
|
+
The source files are near-verbatim copies. Deliberate local changes:
|
|
20
|
+
|
|
21
|
+
- **Test import paths** (`tests/vendor/`): `postgres_mcp.sql` →
|
|
22
|
+
`mcpg._vendor.sql`. The `sql/` source files use relative imports and were
|
|
23
|
+
otherwise copied unchanged.
|
|
24
|
+
- **`sql_driver.py` — `DbConnPool` pool sizing (ADR-0003):** `__init__` gained
|
|
25
|
+
`min_size`/`max_size` parameters (defaulting to `1`/`5`, reproducing the
|
|
26
|
+
original behaviour), used in `pool_connect`. A ~3-line, behaviour-preserving
|
|
27
|
+
change; re-apply on re-sync. Marked in-file with `MCPg local modification`.
|
|
28
|
+
|
|
29
|
+
### Re-sync procedure
|
|
30
|
+
|
|
31
|
+
To pull upstream security fixes:
|
|
32
|
+
|
|
33
|
+
1. `git clone https://github.com/crystaldba/postgres-mcp /tmp/pg-mcp`
|
|
34
|
+
2. Diff `/tmp/pg-mcp/src/postgres_mcp/sql/` against `./sql/`.
|
|
35
|
+
3. Apply relevant changes; do not introduce new imports outside the subpackage.
|
|
36
|
+
4. Update the pinned commit above and note the change in `CHANGELOG.md`.
|
|
37
|
+
5. Run `tests/vendor/` to confirm behaviour is preserved.
|
mcpg/_vendor/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Vendored third-party code. See README.md for provenance and licence.
|
|
2
|
+
|
|
3
|
+
Code under this package is NOT authored by the MCPg project. It is a pinned
|
|
4
|
+
copy of an upstream project, kept verbatim except for import paths. Do not
|
|
5
|
+
hand-edit; re-sync via the procedure in README.md.
|
|
6
|
+
"""
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""SQL utilities."""
|
|
2
|
+
|
|
3
|
+
from .bind_params import ColumnCollector
|
|
4
|
+
from .bind_params import SqlBindParams
|
|
5
|
+
from .bind_params import TableAliasVisitor
|
|
6
|
+
from .extension_utils import check_extension
|
|
7
|
+
from .extension_utils import check_hypopg_installation_status
|
|
8
|
+
from .extension_utils import check_postgres_version_requirement
|
|
9
|
+
from .extension_utils import get_postgres_version
|
|
10
|
+
from .extension_utils import reset_postgres_version_cache
|
|
11
|
+
from .index import IndexDefinition
|
|
12
|
+
from .safe_sql import SafeSqlDriver
|
|
13
|
+
from .sql_driver import DbConnPool
|
|
14
|
+
from .sql_driver import SqlDriver
|
|
15
|
+
from .sql_driver import obfuscate_password
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"ColumnCollector",
|
|
19
|
+
"DbConnPool",
|
|
20
|
+
"IndexDefinition",
|
|
21
|
+
"SafeSqlDriver",
|
|
22
|
+
"SqlBindParams",
|
|
23
|
+
"SqlDriver",
|
|
24
|
+
"TableAliasVisitor",
|
|
25
|
+
"check_extension",
|
|
26
|
+
"check_hypopg_installation_status",
|
|
27
|
+
"check_postgres_version_requirement",
|
|
28
|
+
"get_postgres_version",
|
|
29
|
+
"obfuscate_password",
|
|
30
|
+
"reset_postgres_version_cache",
|
|
31
|
+
]
|