What you will be able to do
- Walk through the RAG chain steps that run when a user sends a request
- Connect an agent to an AI Search index through the managed MCP server or VectorSearchRetrieverTool
- Show how retrieved chunks get into the LLM's context as tool results
- List the Unity Catalog privileges an agent or user needs to query an index it does not own
1.The RAG chain at request time
Once the index exists, every user request goes through the RAG chain. An optional preprocessing step can rewrite the request, put it into a template, or pull out keywords, producing a *retrieval query*. During retrieval, that query is embedded with the same model used for the chunks, compared against them (for example by cosine similarity), and the top-ranked results come back. Prompt augmentation builds the LLM prompt by putting the user's query and the retrieved context into a template that tells the model how to use each part. In generation, the LLM answers from that context. An optional post-processing step can add citations or apply business rules. Guardrails can apply at any step, including checking user permissions before the chain touches a data source.
Checkpoint 1 of 6· Put it in order
Put the RAG chain steps in order
- 1.(Optional) Post-processing adds citations or business logic
- 2.LLM generation produces a grounded response
- 3.(Optional) User query preprocessing produces a retrieval query
- 4.Retrieval embeds the query and returns the most similar chunks
- 5.Prompt augmentation combines the query and retrieved context in a template
Each step uses the previous step's output: the retrieval query drives retrieval, the retrieved chunks fill the prompt, and the prompt goes to the LLM.
“The output of this step is a retrieval query which will be used in the subsequent retrieval step.”Source: docs.databricks.com
Sources1
2.Give the agent a retriever over the index
An agent reaches the index through a tool. Databricks documents three ways to set one up, depending on where the index lives and how much control you need.
| Approach | When to use it | What you configure |
|---|---|---|
| Databricks-managed AI Search MCP server | Immediate access to a Databricks AI Search index built with Databricks-managed embeddings | The URL /api/2.0/mcp/ai-search/{catalog}/{schema}/{index_name} |
| AI Bridge retriever (databricks-langchain / databricks-openai) | Developing and testing a retriever tool locally | VectorSearchRetrieverTool with index_name, tool_name, tool_description |
| Custom retriever through a Unity Catalog connection | A vector index hosted outside Databricks | CREATE CONNECTION plus a retriever function returning List[Document] |
Checkpoint 2 of 6· Fill the gap
Which path segment completes the managed MCP server URL for an AI Search index?
mcp_client = DatabricksMCPClient(
server_url=f"{host}/api/2.0/mcp/ ? /<catalog>/<schema>/<index-name>",
workspace_client=workspace_client,
)
tools = mcp_client.list_tools()The current prefix is /api/2.0/mcp/ai-search/. The older vector-search prefix still works for backwards compatibility, but ai-search is the documented form.
Source: docs.databricks.comVectorSearchRetrieverTool lets you shape retrieval in code. You set how many chunks come back (num_results), which columns are returned, which filters apply, and whether the query is ANN or HYBRID. If the index is a Direct Vector Access Index, or a Delta Sync Index with self-managed embeddings, the tool cannot embed the query by itself. You must pass it a text_column and an embedding model.
vs_tool = VectorSearchRetrieverTool(
index_name="catalog.schema.index_name", # Index name in the format 'catalog.schema.index'
num_results=5, # Max number of documents to return
columns=["primary_key", "text_column"], # List of columns to include in the search
filters={"text_column LIKE": "Databricks"}, # Filters to apply to the query
query_type="ANN", # Query type ("ANN" or "HYBRID").
tool_name="name of the tool", # Used by the LLM to understand the purpose of the tool
tool_description="Purpose of the tool", # Used by the LLM to understand the purpose of the tool
text_column="text_column", # Specify text column for embeddings. Required for direct-access index or delta-sync index with self-managed embeddings.
embedding=embedding_model # The embedding model. Required for direct-access index or delta-sync index with self-managed embeddings.
)Checkpoint 3 of 6· Exam question
A data science team already computes embeddings for their documents using a proprietary in-house model and wants the RAG pipeline's AI Search index to use those exact vectors, without Databricks recomputing them from a specified embedding model. Which index configuration should they use?
Correct answer: A — Self-managed embeddings, storing the precomputed vectors as a column in the source Delta table so they sync to the index
- A. Correct. Self-managed embeddings let the team supply precomputed vectors as a column in the source Delta table, and the index syncs those vectors as-is instead of computing new ones.
- B. Incorrect. Databricks-managed embeddings compute vectors from a specified embedding model at index time, which is exactly what the team wants to avoid since they already have their own vectors.
- C. Incorrect. Delta Sync is a synchronization mode, not an embedding source; whether vectors are recomputed depends on the embedding configuration (managed vs. self-managed), not the sync mode itself.
- D. Incorrect. Genie spaces are a natural-language-to-SQL interface over tables and do not control how an AI Search index sources or stores embedding vectors.
Sources2
3.How retrieved chunks get into the agent's context
When retrieval is exposed as a tool, the LLM decides when to call it. Its description is the main signal for that decision, so write a specific tool_description. After the model calls the tool, your code runs the search and appends the results to the conversation as a tool message linked to the call ID. The model's next turn then sees the retrieved chunks next to the user's question. This is the augmentation step in practice.
messages.append(first_response.choices[0].message)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps(result)
})If you write your own retriever, follow the MLflow retriever schema: return a List[Document] and put attributes such as doc_uri and similarity_score in each Document's metadata field. Tracing can then record what was retrieved, and the generation step has what it needs to cite its sources.
Checkpoint 4 of 6· Check yourself
A custom retriever function returns plain strings. To conform to the MLflow retriever schema, what should it return?
The MLflow retriever schema expects Document objects, with attributes such as doc_uri and similarity_score in metadata.
“the retriever function should return a List[Document] object”Source: docs.databricks.com
4.Unity Catalog decides what the retriever can reach
An AI Search index is a Unity Catalog securable, so querying it follows the usual privilege chain. A user or principal that does not own the index needs USE CATALOG on its catalog, USE SCHEMA on its schema, and SELECT on the index. For the managed MCP server, the documentation says to grant the agent SELECT on the index's securable. This is how governance carries through to retrieval: the corpus lives in a governed table, the index is a governed object, and the agent can query only what it has been granted.
Checkpoint 5 of 6· Check yourself
A service principal has SELECT on prod.docs.policy_index, which it does not own, but its queries fail with a permissions error. What is the most likely cause?
A non-owner needs all three: USE CATALOG, USE SCHEMA and SELECT. CREATE TABLE is required to create an index, not to query one.
“USE SCHEMA on the schema that contains the AI Search index.”Source: docs.databricks.com
Checkpoint 6 of 6· Exam question
A team configures an AI Search index in Delta Sync (continuous) mode on a standard endpoint so the index automatically reflects new rows added to the source Delta table. After enabling sync, newly inserted rows are not appearing in the index. What is the most likely missing prerequisite?
Correct answer: A — Change Data Feed has not been enabled on the source Delta table
- A. Correct. Delta Sync on standard endpoints requires Change Data Feed to be enabled on the source Delta table so the index can detect and pull in row-level changes automatically.
- B. Incorrect. Delta tables and UC volumes are distinct object types; a Delta table is never "converted" into a volume, and AI Search indexes are built from Delta tables directly.
- C. Incorrect. The scenario states Delta Sync was already selected; Direct Vector Access is a different, manual-update mode and is not the cause of a Delta Sync index failing to pick up changes.
- D. Incorrect. Embedding model endpoints are configured on the AI Search index itself, and Genie spaces are unrelated to AI Search index synchronization.
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.Granting SELECT on the AI Search index is enough for a non-owner to query it.Why is that wrong?
A non-owner also needs USE CATALOG on the catalog and USE SCHEMA on the schema that contain the index.
Covered in Unity Catalog decides what the retriever can reach
2.VectorSearchRetrieverTool needs only index_name, whatever kind of index it points at.Why is that wrong?
For a Direct Vector Access Index, or a Delta Sync Index with self-managed embeddings, you must also give it a text column and an embedding model so it can embed the query.
Covered in Give the agent a retriever over the index
Practise it for real
Prototype a retriever tool over an AI Search index and confirm that an LLM calls it and uses the retrieved chunks.
1.Run %pip install --upgrade databricks-langchain in a notebook.
Why: This version includes Databricks AI Bridge, which provides VectorSearchRetrieverTool.
You should see: The package installs and you can import from databricks_langchain.
2.Create VectorSearchRetrieverTool(index_name="catalog.schema.my_databricks_docs_index", tool_name=..., tool_description=...) with your own index name and a specific description.
Why: The LLM uses tool_name and tool_description to decide when to call the retriever.
You should see: The tool object is created. If it fails with a permissions error, check USE CATALOG, USE SCHEMA and SELECT on the index.
3.Call vs_tool.invoke("<a question your corpus answers>").
Why: This checks retrieval by itself before an LLM is involved.
You should see: Relevant chunks from your index come back.
4.Create ChatDatabricks(endpoint="databricks-claude-sonnet-4-5"), call bind_tools([vs_tool]) on it, then invoke it with a question that starts "Based on the documentation…".
Why: This tests whether the model chooses to call the retriever and answers from the retrieved context.
You should see: The model makes a tool call to your retriever and answers from what the index returned.
Stuck? Get a nudge
If the index uses self-managed embeddings, the tool also needs text_column and an embedding model such as DatabricksEmbeddings(endpoint="databricks-bge-large-en").
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/fundamentals-inference-chain-ragOfficial docs
“using the same embedding model that was used to embed the document chunks during data preparation”
↩︎ The RAG chain at request time“checking user permissions before accessing data sources”
↩︎ The RAG chain at request time“The prompt that will be sent to the LLM is formed by augmenting the user's query with the retrieved context”
↩︎ How retrieved chunks get into the agent's context“determining how many chunks to retrieve in step 2 and how to combine them with the user's query”
↩︎ Prediction“The output of this step is a retrieval query which will be used in the subsequent retrieval step.”
↩︎ Checkpoint - 2.
“The legacy /api/2.0/mcp/vector-search/ URL prefix continues to work for backwards compatibility.”
↩︎ Give the agent a retriever over the index“First, create an index using Databricks-managed embeddings.”
↩︎ Give the agent a retriever over the index“Provide a descriptive tool_description to help the agent understand the tool and determine when to invoke it.”
↩︎ How retrieved chunks get into the agent's context“Grant the agent SELECT on the index's Unity Catalog securable.”
↩︎ Unity Catalog decides what the retriever can reach“you must configure the VectorSearchRetrieverTool and specify a custom embedding model and text column.”
↩︎ Exam trap 2“the retriever function should return a List[Document] object”
↩︎ Checkpoint - 3.
“SELECT on the AI Search index.”
↩︎ Unity Catalog decides what the retriever can reach“USE CATALOG on the catalog that contains the AI Search index.”
↩︎ Exam trap 1“USE SCHEMA on the schema that contains the AI Search index.”
↩︎ Checkpoint