Skip to content

MCP ​

The third surface turns retrieval into a tool an agent can call over the Model Context Protocol. duckdb-vectors mcp starts a Model Context Protocol server over stdio: it reads JSON-RPC from stdin and writes to stdout, so any MCP client — Docker Agent, Claude Desktop, Claude Code, Cursor — spawns it as a local subprocess and talks to it in-process, with no network and no port. It is the same serving path as the SDK and CLI, exposed as callable tools.

shell
$ duckdb-vectors mcp                       # serve over stdio (reads a baked index)

The server exposes two query-only tools, backed by a VectorStore resolved from the usual configuration (--database / --embeddings or the DUCKDB_VECTORS_* environment variables):

ToolDoes
searchHybrid semantic + keyword search over the knowledge base; returns a JSON array of ranked chunks (chunk_id, text, source, title, metadata, score)
reportMeta-information about the knowledge base: database path, backend, dimensions, chunk count, sources

The server is self-describing at the initialize handshake: alongside the per-tool descriptions it returns a server-level description and an instructions block that frame the two tools as a pair — scope the index with report, then ground answers with search; neither changes the indexed documents (opening the index can create an empty database file) and both return JSON — so a client gets that guidance even with no skill or docs wired in.

A client wires it in by command, not by discovery. For example, a Docker Agent mcp toolset points at the command directly:

yaml
toolsets:
  - type: mcp
    command: duckdb-vectors
    args: ["mcp"]
    env:
      DUCKDB_VECTORS_DATABASE: /app/vectors.duckdb

See the Docker Agent guide for a complete, runnable integration. Transport is stdio today, which fits the co-located subprocess model; a networked (HTTP) transport is a possible future addition for cross-container use.

The shape of a search result ​

search takes a query string and an optional top_k (default 20, the top_k setting of the server). It returns a JSON array of the top-ranked chunks, best first. Each element is an object with these fields:

FieldTypeMeaning
chunk_idstringStable identifier of the chunk, derived from its source and position at index time.
textstringThe passage itself, to read or quote as grounding.
sourcestringThe folder-relative path of the file the chunk came from.
titlestringThe section heading for Markdown, or Page N for a PDF page.
metadataobjectThe front matter of the source document, plus the section_path of the heading for Markdown. Empty when the document had none.
scorenumberThe fused Reciprocal Rank Fusion score, higher is better. It is not a probability: compare scores within one result set only.
json
[
  {
    "chunk_id": "faq/billing.md:0",
    "text": "Refunds are processed within 14 days of the request.",
    "source": "faq/billing.md",
    "title": "Refund window",
    "metadata": {"kind": "faq", "section_path": "Refund window"},
    "score": 0.0328
  }
]

The shape of a report result ​

report takes no argument. It returns one JSON object:

FieldTypeMeaning
db_pathstringPath of the DuckDB file behind the index.
backendstringThe embedding backend that produced the vectors. Queries embed with the same backend.
dimensionsintegerThe width of the embedding vectors.
chunksintegerThe number of chunks in the index. Zero means an empty index.
sourcesarray of stringsThe sorted list of distinct source values.
json
{
  "db_path": "vectors.duckdb",
  "backend": "local:minishlab/potion-multilingual-128M",
  "dimensions": 256,
  "chunks": 1204,
  "sources": ["faq/billing.md", "faq/limits.md"]
}

See also ​