Skip to main content
Glama
devopam

MCPg - Production-grade PostgreSQL MCP Server

Migrate vector to halfvec

migrate_vector_to_halfvec
Read-only

Generate a DDL plan to convert a pgvector vector(N) column to halfvec(N), halving per-element storage with minimal recall impact. Includes index handling and rollback SQL.

Instructions

Generate a DDL plan that converts a pgvector vector(N) column to halfvec(N) — halving per-element storage (4 → 2 bytes) with typically negligible recall impact at d ≥ 768. Reads the column's current type + dimension from the catalog, finds every index on the column, and emits an ordered migration_sql plan: DROP each affected index, ALTER COLUMN to halfvec(N) via a USING cast, then recreate each index with its halfvec opclass. Also returns a mirror rollback_sql that restores the original vector(N) type plus the original index definitions. Nothing is executed — feed the plan through the shadow-migration workflow (prepare_migration / validate_migration_schema) before applying. Returns already_halfvec=true (and an empty plan) when the column is already halfvec, and refuses any index whose opclass has no halfvec sibling rather than rewriting it incorrectly. Requires the vector extension.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tableYes
columnYes
schemaYes
databaseNoOptional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
notesYes
indexesYes
availableYes
dimensionYes
row_countYes
column_typeYes
rollback_sqlYes
migration_sqlYes
already_halfvecYes
estimated_total_bytes_savedYes
estimated_bytes_per_row_afterYes
estimated_bytes_per_row_beforeYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description details read-only behavior (nothing executed), catalog reading, index handling, and error conditions. It adds value beyond annotations (readOnlyHint) without contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single dense paragraph that front-loads the main purpose. It's efficient but could benefit from slight structuring for readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description explains the output (migration_sql, rollback_sql, already_halfvec) and error handling, which is comprehensive given the tool's complexity. The presence of an output schema further supports completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is only 25% (only database parameter documented). The description mentions the required parameters implicitly but doesn't elaborate on each. It provides some context but doesn't fully compensate for low schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Generate a DDL plan that converts a pgvector vector(N) column to halfvec(N)', specifying the verb (generate) and resource (column conversion). It distinguishes from sibling tools by its migration-plan focus, contrasting with analysis or execution tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explains the workflow: 'feed the plan through the shadow-migration workflow' and notes when the column is already halfvec. It doesn't explicitly state when not to use it, but the context of plan generation vs. execution is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/devopam/MCPg'

If you have feedback or need assistance with the MCP directory API, please join our Discord server