Skip to main content
Glama
mittalpk

mcp-server-pgvector

by mittalpk

mcp-server-pgvector

CI

An MCP server that gives LLM agents first-class access to pgvector-backed embedding tables in PostgreSQL: similarity search, hybrid (vector + full-text) search, upserts, and HNSW/IVFFlat index management.

Generic Postgres MCP servers expose raw SQL or schema introspection; this one speaks pgvector specifically — nearest-neighbor search, distance metrics, and ANN index tuning are first-class tools, not something the model has to hand-write SQL for.

Tools

Tool

Description

list_vector_tables

Discover every vector column in the database, with its dimensionality

describe_vector_table

Columns, indexes, and approximate row count for a table

similarity_search

k-NN search over a vector column (cosine / L2 / inner product), with structured metadata filters

hybrid_search

Weighted blend of vector similarity and Postgres full-text search (ts_rank_cd)

upsert_embedding

Insert or update a row's embedding + metadata

create_vector_index

Create an HNSW or IVFFlat index with tunable parameters

explain_similarity_query

EXPLAIN ANALYZE a similarity query to confirm the ANN index is used

Related MCP server: ilma

Safety

  • Every table/column name is validated against information_schema / pg_catalog before being interpolated into SQL — an LLM can only ever reference identifiers that already exist. Values are always bound parameters.

  • Metadata filters are a closed {column, op, value} allowlist, not a raw SQL fragment.

  • Set MCP_PGVECTOR_READ_ONLY=true to disable upsert_embedding and create_vector_index, leaving only read/search tools available — useful when pointing the server at a production database.

  • Every query runs with a per-command timeout (MCP_PGVECTOR_COMMAND_TIMEOUT_SECONDS, default 30s) so one expensive query can't occupy a pool connection — and stall every other caller — indefinitely. Set it to 0 to disable.

Installation

uvx mcp-server-pgvector

Or with pip:

pip install mcp-server-pgvector
python -m mcp_server_pgvector

Configuration

The server reads its connection string from DATABASE_URL (or PGVECTOR_DATABASE_URL):

{
  "mcpServers": {
    "pgvector": {
      "command": "uvx",
      "args": ["mcp-server-pgvector"],
      "env": {
        "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb",
        "MCP_PGVECTOR_READ_ONLY": "false",
        "MCP_PGVECTOR_COMMAND_TIMEOUT_SECONDS": "30"
      }
    }
  }
}

Production readiness

Covered:

  • Identifier-safe SQL (every table/column checked against pg_catalog before use) and a closed filter-operator allowlist — no path from tool arguments to raw SQL.

  • Per-query timeout, so one runaway query can't monopolize the (small, 5-connection) pool.

  • 60+ tests, including dimension-mismatch and injection-attempt regressions, run in CI on every push/PR against a real pgvector container across Python 3.10–3.13. A separate CI job builds the package and runs twine check on the result.

  • Connection failures surface as plain ConnectionRefusedError/asyncpg exceptions — verified these don't leak the DSN's credentials into error text.

Known limitations, honestly:

  • No per-tool authorization — access control is whatever the Postgres role in DATABASE_URL can do. If you need different agents to have different permissions, give them different connection strings backed by different Postgres roles, not different server instances of this same DSN.

  • hybrid_search's full-text side is hardcoded to Postgres's 'english' text search configuration; there's no parameter to change it yet.

  • No structured logging — failures are exceptions surfaced through the MCP error channel, not written to a log you can tail. Fine for a single-user desktop MCP client, a real gap if you're running this as a shared service.

  • The connection pool is fixed at 1–5 connections and isn't configurable via environment variable yet.

Development

uv sync --dev

# Bring up an isolated pgvector instance for local testing
docker compose -f docker-compose.dev.yml up -d

export DATABASE_URL=postgresql://postgres:postgres@localhost:5434/postgres
uv run pytest

uv run ruff check .
uv run pyright

Contributing

See CONTRIBUTING.md. See CHANGELOG.md for release history.

License

MIT — see LICENSE.

Available Tools

7 tools
create_vector_indexB

Create an HNSW or IVFFlat approximate-nearest-neighbor index on a vector column.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes
columnYes
hnsw_mNo
methodNohnsw
metricNocosine
schemaNopublic
ivfflat_listsNo
hnsw_ef_constructionNo

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.3/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure, but it only states that the tool creates an index. It fails to mention important details like potential table locking, the need for the column to have the vector type, or that this is an DDL operation that modifies the schema. The description adds no context beyond the bare action.

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

Conciseness5/5

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

The description is a single sentence that is front-loaded with the core purpose, containing no filler or redundant information. It is appropriately sized for a high-level tool overview, though other dimensions suffer from lack of detail.

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

Completeness2/5

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

The tool is a DDL operation with 8 parameters, no annotations, and no schema descriptions, yet the description provides only a one-line overview. It fails to mention prerequisites, side effects, or index selection guidance, making it insufficient for agents to understand the full operational context. Even though an output schema exists, the tool's complexity demands a more complete description.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate by explaining parameters. It only mentions 'HNSW or IVFFlat', which maps to the 'method' parameter, but leaves parameters like hnsw_m, metric, schema, and ivfflat_lists unexplained. The description adds minimal semantic value beyond what the schema already exposes through names and defaults.

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 the action ('Create'), the specific resource ('vector index'), and the index methods ('HNSW or IVFFlat'), making the tool's purpose unmistakable. It distinguishes itself from sibling tools like list_vector_tables and similarity_search, which perform different operations on vector data.

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

Usage Guidelines3/5

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

The description implies when to use the tool (when you need an approximate-nearest-neighbor index on a vector column), but it does not provide explicit when/when-not guidance or mention prerequisites such as the pgvector extension or the column already containing vector data. No alternatives are discussed because the siblings are for different operations, but the lack of exclusion criteria leaves room for ambiguity.

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

describe_vector_tableA

Get columns, indexes, and an approximate row count for a table.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes
schemaNopublic

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It does disclose that the row count is 'approximate,' which is a useful behavioral detail. However, it does not explicitly state non-destructive nature or any requirements, though 'Get' implies read-only. Some behavioral context is present but incomplete.

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

Conciseness5/5

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

The description is a single sentence of 11 words, front-loaded with the action and object. Every word earns its place with no fluff or repetition.

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

Completeness4/5

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

For a simple metadata-description tool with an output schema available, the description adequately covers what the tool returns and hints at the approximate nature of the row count. It lacks explicit parameter clarifications, but the overall simplicity and presence of output schema make it nearly complete.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for lack of parameter documentation. It does not explain the 'schema' parameter or its default behavior, and only indirectly references 'table.' The parameter names are self-explanatory, but the description adds no meaning beyond the raw schema fields.

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 uses a specific verb ('Get') and clearly identifies the resource ('columns, indexes, and an approximate row count') and target ('a table'). It is immediately distinguishable from sibling tools such as list_vector_tables and hybrid_search, which serve different purposes.

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

Usage Guidelines3/5

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

The description implies usage when one needs table metadata, but it does not explicitly state when to use this tool versus alternatives. No exclusions or alternative tool references are provided, so guidance is only implicit.

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

explain_similarity_queryB

Run EXPLAIN ANALYZE on a similarity query to confirm an ANN index is used.

ParametersJSON Schema
NameRequiredDescriptionDefault
kNo
tableYes
metricNocosine
schemaNopublic
query_embeddingYes
embedding_columnYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the key behavior (running EXPLAIN ANALYZE), but does not disclose potential side effects such as the query actually being executed, performance implications, required privileges, or the format of the output. This is a minimal but not misleading disclosure.

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

Conciseness5/5

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

The description is a single, front-loaded sentence with no filler. It efficiently communicates the tool's purpose without wasting words.

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

Completeness2/5

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

Despite having six parameters, no annotations, and an output schema, the description is extremely minimal. It does not explain how the similarity query is constructed, the role of metric or k, or what the EXPLAIN ANALYZE output will contain. This leaves significant gaps for an AI agent trying to invoke the tool correctly.

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

Parameters1/5

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

The description provides no explanation of the six parameters. Schema description coverage is 0%, and the tool description does not compensate by explaining the role of table, embedding_column, query_embedding, k, metric, or schema. Relying on parameter names alone is insufficient.

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 the tool's function: 'Run EXPLAIN ANALYZE on a similarity query to confirm an ANN index is used.' It uses a specific verb ('Run EXPLAIN ANALYZE') and a resource ('similarity query'), and the intent is explicit. This differentiates it from sibling tools like similarity_search (runs the query) and create_vector_index (creates an index).

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

Usage Guidelines3/5

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

The description implies usage when one needs to confirm ANN index utilization, but it does not explicitly state when to use this tool versus alternatives, nor does it mention exclusions or prerequisites. Sibling tools such as similarity_search or hybrid_search are not referenced, leaving the decision contextual rather than explicit.

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

list_vector_tablesA

List every column of type vector in the database, with its table and dimensionality.

ParametersJSON Schema
NameRequiredDescriptionDefault
schemaNoRestrict to one schema, or all schemas if omitted

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

With no annotations, the description carries the full burden. It specifies that it lists 'every column' and includes table and dimensionality, which provides concrete behavioral expectations. It doesn't mention permissions or performance, but for a read-only listing tool this is acceptable.

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

Conciseness5/5

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

A single, front-loaded sentence conveys the purpose and key details without waste. Every word earns its place.

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?

For a simple listing tool with one optional parameter and an output schema, the description provides enough context. It clearly states what is listed and what fields are included, so the agent can invoke it correctly.

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?

The schema already fully documents the single parameter with a good description, so the tool description adds no additional parameter semantics. Baseline 3 is appropriate given 100% 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 uses the specific verb 'List' and identifies the exact resource: columns of type `vector`. It also states what is returned (table and dimensionality), clearly distinguishing it from sibling tools like `describe_vector_table` or `hybrid_search`.

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 implies use for discovering all vector columns in the database, and the optional schema parameter clarifies scope. It doesn't explicitly name exclusions or alternatives, but the intent is clear enough given the sibling set.

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

upsert_embeddingB

Insert a row or update it in place if id_value already exists (upsert).

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes
schemaNopublic
id_valueYes
metadataNoOther column values to set, keyed by column name
embeddingYes
id_columnYes
embedding_columnYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

B3.3/5.0
Behavior3/5

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

The description discloses the core upsert behavior (insert or update in place). However, it does not explain whether the update is partial (only provided columns) or full, nor does it disclose any side effects on unspecified columns. With no annotations, the description carries the full burden but only conveys the basic write operation.

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

Conciseness5/5

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

The description is a single, front-loaded sentence with no filler. It immediately states the operation and the key condition, earning its place efficiently.

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

Completeness2/5

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

For a 7-parameter mutation tool with no annotations, this description is too thin. It omits operational context like how `schema` defaults to 'public', how metadata interacts with the row update, and what the output schema contains. The presence of an output schema does not compensate for the missing parameter and behavior details.

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

Parameters2/5

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

Schema description coverage is only 14% (only `metadata` has a description). The description adds meaning for `id_value` (the existence check) but does not clarify the roles of `table`, `id_column`, `embedding`, `embedding_column`, `schema`, or the metadata object, leaving most parameters under-specified.

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 states a specific action ('Insert a row or update it in place') with a clear resource (row) and condition (`id_value` already exists). This clearly distinguishes it from sibling read/query tools like similarity_search or describe_vector_table.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It does not mention that it is for writing/updating embedding rows or that search tools should be used for querying, despite the sibling tool names making this somewhat implicit.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 7 tool updatesv0.1.0
    • First observedcreate_vector_index
    • First observeddescribe_vector_table
    • First observedexplain_similarity_query
    • First observedhybrid_search
    • First observedlist_vector_tables
    • First observedsimilarity_search
    • First observedupsert_embedding

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a clearly distinct role: discovery (list_vector_tables, describe_vector_table), search (similarity_search, hybrid_search), data modification (upsert_embedding), indexing (create_vector_index), and diagnostics (explain_similarity_query). No two tools overlap in purpose.

Naming Consistency5/5

All tools follow a consistent verb_noun snake_case pattern (list_, describe_, create_, upsert_, explain_) or use noun_verb for search operations. The naming style is uniform and predictable.

Tool Count5/5

Seven tools is well within the ideal 3-15 range. Each tool earns its place, covering discovery, search, ingestion, indexing, and query analysis without redundancy.

Completeness4/5

The toolkit covers the core pgvector workflow: list tables, describe schema, create index, upsert vectors, search, and explain query plans. Minor gaps like a delete_embedding or drop_index tool are missing, but they are not essential for the primary use case.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

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/mittalpk/mcp-server-pgvector'

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