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?
| Question | SDK path | MCP path |
|---|---|---|
| Latency | A 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 model | One process: your agent opens the DuckDB file. | Two processes: the client spawns the server over stdio, with no network and no port. |
| Language | Python only. | Any language that has an MCP client. |
| Who owns the loop | Your 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 it | You 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
| Guide | Path | What you wire |
|---|---|---|
| Docker Agent | MCP | An MCP toolset in the agent YAML. |
| LangChain | SDK, or MCP in the last section | A @tool that wraps store.query. |
| LangGraph | SDK, or MCP in the last section | A retrieval node in a graph. |
| Hermes | SDK, or MCP in the last section | A plugin that imports the SDK. |
| n8n | SDK, or MCP behind a bridge | A Code node that calls store.query. |
| Strands Agents | SDK, or MCP in the last section | A @tool that wraps store.query. |
| Pydantic AI | SDK, or MCP in the last section | A tool registered on an Agent. |
| Kilo Code | MCP | An MCP server entry in the editor settings. |
| Kiro | MCP | A user-level MCP entry and a global skill. |
| OpenCode | MCP | An MCP server in the global configuration. |
| Your first agent | SDK | A 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:
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:
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
- Your first agent builds a self-contained agent image around this wrapper.
- MCP reference lists the tools that an MCP client sees.