diff --git a/Dockerfile b/Dockerfile index 76cf45e..305d003 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --frozen --no-dev -FROM python:3.13-slim-bookworm +FROM python:3.12-slim-bookworm # It is important to use the image that matches the builder, as the path to the # Python executable must be the same, e.g., using `python:3.11-slim-bookworm` # will fail. diff --git a/src/postgres_mcp/resources/database_resources.py b/src/postgres_mcp/resources/database_resources.py index cb3ed42..0f957f1 100644 --- a/src/postgres_mcp/resources/database_resources.py +++ b/src/postgres_mcp/resources/database_resources.py @@ -35,13 +35,16 @@ async def get_database_schema() -> str: # pyright: ignore[reportUnusedFunction] sql_driver: Any = await get_sql_driver_func() # Query information_schema for tables + # Use pg_class directly to avoid ::regclass issues with views tables_query = """ SELECT t.table_schema, t.table_name, t.table_type, - obj_description((t.table_schema||'.'||t.table_name)::regclass) as table_comment + obj_description(c.oid, 'pg_class') as table_comment FROM information_schema.tables t + LEFT JOIN pg_namespace n ON n.nspname = t.table_schema + LEFT JOIN pg_class c ON c.relnamespace = n.oid AND c.relname = t.table_name WHERE t.table_schema NOT IN ('pg_catalog', 'information_schema') ORDER BY t.table_schema, t.table_name """ diff --git a/src/postgres_mcp/sql/safe_sql.py b/src/postgres_mcp/sql/safe_sql.py index 2726531..99f47a6 100644 --- a/src/postgres_mcp/sql/safe_sql.py +++ b/src/postgres_mcp/sql/safe_sql.py @@ -306,6 +306,9 @@ class SafeSqlDriver(SqlDriver): "unicode_version", "icu_unicode_version", # Database object information functions + "obj_description", + "col_description", + "shobj_description", "pg_column_size", "pg_column_compression", "pg_column_toast_chunk_id",