Pgvector MCP Server

Similarity search, hybrid search, and index management for pgvector-backed PostgreSQL tables

Local serverstdioPython

What is the Pgvector MCP server?

Similarity search, hybrid search, and index management for pgvector-backed PostgreSQL tables. That is what the pgvector mcp server brings to an AI assistant: the same capability, reachable through the Model Context Protocol rather than a separate app or dashboard.

The short version

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.

The tools it exposes

The server publishes 7 tools. What each one is for:

  • 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

Getting it running

mcp-server-pgvector on PyPI is all you need. Most clients run it directly, so configuration is a few lines and a restart.

What it needs from you

Configuration is passed through the environment: DATABASE_URL, MCP_PGVECTOR_READ_ONLY, MCP_PGVECTOR_COMMAND_TIMEOUT_SECONDS, PGVECTOR_DATABASE_URL. Treat anything key-shaped as a real credential — scope it to the minimum the server needs, and rotate it if it ever lands in a shared config.

How it compares

This sits in the database access group, where several servers overlap in what they claim to do but differ sharply once you actually set them up. Pgvector's toolset — list_vector_tables, describe_vector_table, similarity_search and 4 more — is a fair guide to whether it matches your workflow. It is maintained by mittalpk; worth a glance at recent repository activity before you build anything load-bearing on it.

We check each listing at SyncDev against the project's documentation before it goes live — if something here drifts out of date, it is a bug worth reporting.

Things to watch

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • Keep per-call confirmation enabled while you learn its behaviour; it is the cheapest safeguard you have.

Available tools

ToolWhat it does
list_vector_tablesDiscover every vector column in the database, with its dimensionality
describe_vector_tableColumns, indexes, and approximate row count for a table
similarity_searchk-NN search over a vector column (cosine / L2 / inner product), with structured metadata filters
hybrid_searchWeighted blend of vector similarity and Postgres full-text search (ts_rank_cd)
upsert_embeddingInsert or update a row's embedding + metadata
create_vector_indexCreate an HNSW or IVFFlat index with tunable parameters
explain_similarity_queryEXPLAIN ANALYZE a similarity query to confirm the ANN index is used

How to install the Pgvector MCP server

{
  "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"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
DATABASE_URLEndpoint or connection string the server talks to.Yes
MCP_PGVECTOR_READ_ONLYConfiguration value read at startup.Optional
MCP_PGVECTOR_COMMAND_TIMEOUT_SECONDSConfiguration value read at startup.Optional
PGVECTOR_DATABASE_URLEndpoint or connection string the server talks to.Yes

Example prompts to try

  • Use Pgvector to list vector tables.
  • Use Pgvector to describe vector table.
  • Use Pgvector to similarity search.

Frequently asked questions

It connects Pgvector to MCP-compatible AI assistants such as Claude and Cursor, exposing 7 tools (list_vector_tables, describe_vector_table, similarity_search, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Pgvector directly.