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.
$ 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):
| Tool | Does |
|---|---|
search | Hybrid semantic + keyword search over the knowledge base; returns a JSON array of ranked chunks (chunk_id, text, source, title, metadata, score) |
report | Meta-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:
toolsets:
- type: mcp
command: duckdb-vectors
args: ["mcp"]
env:
DUCKDB_VECTORS_DATABASE: /app/vectors.duckdbSee 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:
| Field | Type | Meaning |
|---|---|---|
chunk_id | string | Stable identifier of the chunk, derived from its source and position at index time. |
text | string | The passage itself, to read or quote as grounding. |
source | string | The folder-relative path of the file the chunk came from. |
title | string | The section heading for Markdown, or Page N for a PDF page. |
metadata | object | The front matter of the source document, plus the section_path of the heading for Markdown. Empty when the document had none. |
score | number | The fused Reciprocal Rank Fusion score, higher is better. It is not a probability: compare scores within one result set only. |
[
{
"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:
| Field | Type | Meaning |
|---|---|---|
db_path | string | Path of the DuckDB file behind the index. |
backend | string | The embedding backend that produced the vectors. Queries embed with the same backend. |
dimensions | integer | The width of the embedding vectors. |
chunks | integer | The number of chunks in the index. Zero means an empty index. |
sources | array of strings | The sorted list of distinct source values. |
{
"db_path": "vectors.duckdb",
"backend": "local:minishlab/potion-multilingual-128M",
"dimensions": 256,
"chunks": 1204,
"sources": ["faq/billing.md", "faq/limits.md"]
}See also
- Connect to your agent or editor: when to pick MCP, and when to call the library.
- CLI reference: the
mcpverb and its options.