Skip to content

Level: beginnerTime: 10 minutesPath: SDK or MCP

Connect to your agent or editor ​

An agent reaches duckdb-vectors along one of two paths. With the SDK path, your code imports VectorStore and calls query as a function. With the MCP path, the agent or editor starts duckdb-vectors mcp as a subprocess and calls its search and report tools. This page compares the two once, so that each integration guide does not have to.

SDK or MCP? ​

QuestionSDK pathMCP path
LatencyA local function call, in the process of your agent.About 45 ms per search after the first, and about 2 s for the first one, which loads the embedding model. The round trip and the opening of the store add about 20 ms to an in-process query.
Process modelOne process: your agent opens the DuckDB file.Two processes: the client spawns the server over stdio, with no network and no port.
LanguagePython only.Any language that has an MCP client.
Who owns the loopYour code decides when to call query and what to do with the chunks.The agent runtime or the editor sees the tools and decides when to call them.
When to pick itYou write the agent in Python and want the least moving parts, or you ship the index inside a container image.You use an editor or an agent runtime that speaks MCP, or an agent that is not written in Python.

The performance workbook has the measurements. The tools and the shape of their results are in the MCP reference, and the Python calls are in the Python API reference.

The integration guides ​

GuidePathWhat you wire
Docker AgentMCPAn MCP toolset in the agent YAML.
LangChainSDK, or MCP in the last sectionA @tool that wraps store.query.
LangGraphSDK, or MCP in the last sectionA retrieval node in a graph.
HermesSDK, or MCP in the last sectionA plugin that imports the SDK.
n8nSDK, or MCP behind a bridgeA Code node that calls store.query.
Strands AgentsSDK, or MCP in the last sectionA @tool that wraps store.query.
Pydantic AISDK, or MCP in the last sectionA tool registered on an Agent.
Kilo CodeMCPAn MCP server entry in the editor settings.
KiroMCPA user-level MCP entry and a global skill.
OpenCodeMCPAn MCP server in the global configuration.
Your first agentSDKA plain Python agent in a container image.

A generic SDK tool wrapper ​

For a framework that is not listed, open the store once at startup, call query for each user turn, and hand the chunks to the model as context. The same function becomes a tool in any framework that accepts a Python callable:

python
from duckdb_vectors import VectorStore

store = VectorStore(db_path="vectors.duckdb", backend="local:minishlab/potion-multilingual-128M")

def retrieve_context(question: str, k: int = 5) -> str:
    hits = store.query(question, top_k=k)
    return "\n\n".join(f"[{h.chunk.source}] {h.chunk.text}" for h in hits)

# Hand retrieve_context(question) to your LLM call as grounding, then let the
# model answer. duckdb-vectors stops at retrieval; the harness owns generation.

The front matter that you attached at index time rides back on every hit as hit.chunk.metadata, so the harness can label citations, filter by attribute, or route on it:

python
def retrieve_context(question: str, k: int = 5) -> str:
    blocks = []
    for h in store.query(question, top_k=k):
        kind = h.chunk.metadata.get("kind", "doc")
        blocks.append(f"[{kind}: {h.chunk.source}] {h.chunk.text}")
    return "\n\n".join(blocks)

Next steps ​