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.
Files changed (72) hide show
  1. mcpg/__init__.py +3 -0
  2. mcpg/__main__.py +37 -0
  3. mcpg/_vendor/LICENSE +21 -0
  4. mcpg/_vendor/README.md +37 -0
  5. mcpg/_vendor/__init__.py +6 -0
  6. mcpg/_vendor/sql/__init__.py +31 -0
  7. mcpg/_vendor/sql/bind_params.py +816 -0
  8. mcpg/_vendor/sql/extension_utils.py +246 -0
  9. mcpg/_vendor/sql/index.py +52 -0
  10. mcpg/_vendor/sql/safe_sql.py +1036 -0
  11. mcpg/_vendor/sql/sql_driver.py +276 -0
  12. mcpg/advisors.py +713 -0
  13. mcpg/audit.py +1190 -0
  14. mcpg/audit_trail.py +230 -0
  15. mcpg/composite.py +475 -0
  16. mcpg/config.py +551 -0
  17. mcpg/context.py +20 -0
  18. mcpg/cron.py +114 -0
  19. mcpg/cursors.py +296 -0
  20. mcpg/cypher.py +253 -0
  21. mcpg/data_movement.py +737 -0
  22. mcpg/database.py +207 -0
  23. mcpg/diagrams.py +183 -0
  24. mcpg/diesel.py +247 -0
  25. mcpg/drizzle.py +414 -0
  26. mcpg/ecto.py +287 -0
  27. mcpg/ent.py +324 -0
  28. mcpg/extensions.py +83 -0
  29. mcpg/graph.py +170 -0
  30. mcpg/graph_diagram.py +157 -0
  31. mcpg/graph_mgmt.py +116 -0
  32. mcpg/health.py +147 -0
  33. mcpg/http_runtime.py +364 -0
  34. mcpg/indexing.py +155 -0
  35. mcpg/introspection.py +1214 -0
  36. mcpg/io_stats.py +129 -0
  37. mcpg/jooq.py +180 -0
  38. mcpg/listen.py +378 -0
  39. mcpg/liveops.py +108 -0
  40. mcpg/locks.py +163 -0
  41. mcpg/maintenance.py +66 -0
  42. mcpg/middleware/rate_limit.py +92 -0
  43. mcpg/migrations.py +694 -0
  44. mcpg/naming.py +201 -0
  45. mcpg/nl2sql.py +506 -0
  46. mcpg/observability.py +163 -0
  47. mcpg/oidc.py +181 -0
  48. mcpg/partman.py +124 -0
  49. mcpg/policy.py +67 -0
  50. mcpg/prisma.py +415 -0
  51. mcpg/query.py +231 -0
  52. mcpg/replicas.py +360 -0
  53. mcpg/rls.py +198 -0
  54. mcpg/schema_diff.py +259 -0
  55. mcpg/server.py +153 -0
  56. mcpg/shell.py +262 -0
  57. mcpg/sqlalchemy_export.py +435 -0
  58. mcpg/sqlc.py +169 -0
  59. mcpg/tenancy.py +166 -0
  60. mcpg/test_data.py +219 -0
  61. mcpg/textsearch.py +738 -0
  62. mcpg/timescaledb.py +269 -0
  63. mcpg/tools.py +1974 -0
  64. mcpg/vector_tuning.py +263 -0
  65. mcpg/workload.py +213 -0
  66. mcpg/write.py +215 -0
  67. mcpg-0.5.1.dist-info/METADATA +201 -0
  68. mcpg-0.5.1.dist-info/RECORD +72 -0
  69. mcpg-0.5.1.dist-info/WHEEL +4 -0
  70. mcpg-0.5.1.dist-info/entry_points.txt +2 -0
  71. mcpg-0.5.1.dist-info/licenses/LICENSE +21 -0
  72. mcpg-0.5.1.dist-info/licenses/src/mcpg/_vendor/LICENSE +21 -0
mcpg/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """MCPg — a PostgreSQL Model Context Protocol server."""
2
+
3
+ __version__ = "0.5.1"
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.
@@ -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
+ ]