Some agentic retrieval features are generally available in the 2026-04-01 REST API. However, this article uses the 2026-05-01-preview to demonstrate the full feature set, including features that remain in preview. Preview features are provided without a service-level agreement and aren’t recommended for production workloads. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
These features and functionality are part of the 2026-05-01-preview REST API. The 2026-05-01-preview is licensed to you as part of your Azure subscription and is subject to the terms applicable to “Previews” in the Microsoft Product Terms, the Microsoft Products and Services Data Protection Addendum (“DPA”), and the Supplemental Terms of Use for Microsoft Azure Previews.The 2026-05-01-preview supports connections to other Microsoft services and third-party services. Use of these services is subject to their respective terms and might result in data processing or storage outside of the Azure compliance boundary, as well as data flowing into the Azure compliance boundary.It’s your responsibility to manage whether your data will flow outside of your organization’s compliance and geographic boundaries and any related implications, and that appropriate permissions, boundaries, and approvals are provisioned.MCP implementations are susceptible to risks, such as attacks, cascading failures, and loss of human oversight. You can mitigate these risks by vetting MCP servers for security and reliability, following Microsoft’s recommended practices and industry best practices, and implementing approval mechanisms and monitoring cascading behaviors.You’re responsible for carefully reviewing and testing applications you build in the context of your specific use cases and making all appropriate decisions and customizations. This includes implementing your own responsible AI mitigations, such as metaprompts, content filters, or other safety systems, and ensuring your applications meet appropriate quality, reliability, security, and trustworthiness standards. For more information, see the Azure AI Search Transparency Note.
- Plans and decomposes a user query into subqueries.
- Processes the subqueries simultaneously using keyword, vector, or hybrid techniques.
- Applies semantic reranking to identify the most relevant results.
- Synthesizes the results into a unified 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-05-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 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
(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-05-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.