Features, capabilities, or properties marked (preview) aren’t covered by a service-level agreement, aren’t recommended for production workloads, and might change or be constrained before they become generally available. The Azure AI Search preview terms apply to all preview functionality, whether it’s standalone or part of a generally available feature.
- Use LLM-based query planning (preview) to decompose a user query into subqueries.
- Process the subqueries simultaneously by using keyword, vector, or hybrid search.
- Apply semantic reranking to identify the most relevant results.
- Use answer synthesis (preview) to combine the results into a natural-language response with source references.
Usage support
Prerequisites
- An Azure AI Search service with a knowledge base containing one or more knowledge sources.
-
A Microsoft Foundry project with an LLM deployment, such as
gpt-4.1-mini. Hub-based projects aren’t supported. - Authentication and permissions on your search service and project.
-
The latest preview Python SDK (version 2.0.0 or later) or the 2026-08-01-preview REST API version.
Authentication and permissions
We recommend role-based access control for production deployments. To assign the roles in this section, you need the Owner or User Access Administrator role on both resources, or another role that grantsMicrosoft.Authorization/roleAssignments/write. If roles aren’t feasible, skip this section and use key-based authentication instead.
- Microsoft Foundry
- Azure AI Search
- On the parent resource of your project, you need the Foundry User role to access model deployments and create agents. Owners automatically get this role when they create the resource. Other users need a specific role assignment. For more information, see Role-based access control in Foundry portal.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
- On the parent resource of your project, you need the Foundry Project Manager role to create a project connection for MCP authentication and either Foundry User or Foundry Project Manager to use the MCP tool in agents.
- (Conditional) On the parent resource of your project, assign the Cognitive Services User role to your search service’s system-assigned managed identity. This step is required only if your knowledge base specifies an LLM. Depending on its configuration, the knowledge base uses this identity to call the LLM for query planning, answer synthesis, or both. For more information, see Connect to Azure AI Search using a managed identity.
- On your project, create a system-assigned managed identity for interactions with Azure AI Search.
Required values
Use the following values in the code samples.Create a project connection
Create aRemoteTool connection (preview) on your Microsoft Foundry project. This connection uses the project’s managed identity to target the MCP endpoint of the knowledge base, allowing the agent to securely communicate with Azure AI Search for retrieval operations.
The
RemoteTool category and ProjectManagedIdentity authentication type are specific to Microsoft Foundry project connections.- Python
- REST
Optimize agent instructions for knowledge retrieval
To improve knowledge base invocations and produce citation-backed answers, start with instructions like the following:- Higher MCP tool invocation rates: Explicit directives ensure the agent consistently calls the knowledge base tool rather than relying on its training data.
- Clear source attribution: Citations make it easier to validate where information came from.
Create an agent with the MCP tool
Create an agent that integrates the knowledge base as an MCP tool. The agent uses a system prompt to instruct when and how to call the knowledge base. It follows instructions on how to answer questions and automatically maintains its tool configuration and settings across conversation sessions. Add the knowledge base MCP tool with the project connection you previously created. This tool orchestrates query planning, decomposition, and retrieval across configured knowledge sources. The agent uses this tool to answer queries.Azure AI Search knowledge bases expose the
knowledge_base_retrieve MCP tool for agent integration. This is the only tool currently supported for use with Foundry Agent Service.- Python
- REST
Create the agent with the .NET SDK
Install the prerelease packages withdotnet add package Azure.AI.Projects --prerelease and dotnet add package Azure.Identity.
(Optional) Enforce permissions with per-request headers
If any of your knowledge sources contain permission-protected content, the retrieval engine can filter results so that each user sees only the documents they’re authorized to access. To enable this filtering, forward the signed-in user’s identity token in thex-ms-query-source-authorization header of the MCP tool connection. Without the token, permission-enabled sources return results unfiltered. For more information, see Enforce permissions at query time (preview).
To vary MCP headers per request, such as passing a different user’s token on each call, declare a structured input in the agent definition and reference it as a {{placeholder}} in the tool’s headers. The caller supplies the value on each invocation. This approach works for MCP tools bound to a project connection.
For per-user authorization against an MCP server, you can also use OAuth identity passthrough.
- Python
- REST
Update the agent from the previous step so the MCP tool reads its authorization header from a structured input:When you invoke the agent, supply an Azure AI Search token in
structured_inputs. This example resolves a token from the current credential. For a multi-user app, pass the token of each signed-in user instead. For example, use a token obtained through an on-behalf-of flow so the retrieval engine can filter results for that user.Invoke the agent with a query
Create a conversation session and send a user query to the agent. When appropriate, the agent orchestrates calls to the MCP tool to retrieve relevant content from the knowledge base. The agent then synthesizes this content into a natural-language response that cites the source documents. Citation URLs in agent responses vary by knowledge source. For example, blob knowledge sources return the original document URL, while search index knowledge sources fall back to the MCP endpoint of your knowledge base.- Python
- REST
Delete the agent and project connection
Deleting your agent and project connection doesn’t delete your knowledge base or its knowledge sources. You must delete these objects separately on your Azure AI Search service. For more information, see Delete a knowledge base and Delete a knowledge source.
Troubleshooting
This section helps you troubleshoot common issues when connecting Foundry Agent Service to a Foundry IQ knowledge base.Authorization failures (401/403)
- If you get a 403 from Azure AI Search, confirm the project’s managed identity has the Search Index Data Reader role on the search service (and Search Index Data Contributor if you write to indexes).
- If you get a 403 from Azure Resource Manager when you create or delete the project connection, confirm your user or service principal has permissions on the Microsoft Foundry resource and project.
- If you use keyless authentication, confirm your environment is signed in to the correct tenant and subscription.
MCP endpoint errors (400/404)
- Confirm
search_service_endpointis the Azure AI Search service URL, such ashttps://<name>.search.windows.net. - Confirm
knowledge_base_namematches the knowledge base you created in Azure AI Search. - Confirm you use the
2026-08-01-previewAPI version for the knowledge base MCP endpoint.
The agent doesn’t ground answers
- Confirm the agent has the MCP tool configured and
allowed_toolsincludesknowledge_base_retrieve. - Update your agent instructions to explicitly require using the knowledge base and to return “I don’t know” when retrieval doesn’t contain the answer.