Skip to main content
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.
In this article, you learn how to connect a knowledge base in Foundry IQ to an agent in Foundry Agent Service. The connection uses the Model Context Protocol (MCP) to facilitate tool calls. When invoked by the agent, the knowledge base orchestrates the following operations:
  • 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.
The agent uses the response to ground its answers in enterprise data or web sources, ensuring factual accuracy and transparency through source attribution. For an end-to-end example of integrating Azure AI Search and Foundry Agent Service for knowledge retrieval, see the agentic-retrieval-pipeline-example Python sample on GitHub.

Usage support

Prerequisites

Authentication and permissions

We recommend role-based access control for production deployments. If roles aren’t feasible, skip this section and use key-based authentication instead.
  • 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.
  • 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.
We recommend you store the project endpoint, search endpoint, and knowledge base name in a .env file for local development.

Create a project connection

Create a RemoteTool 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.

Optimize agent instructions for knowledge retrieval

To improve knowledge base invocations and produce citation-backed answers, start with instructions like the following:
This instruction template optimizes for:
  • 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.
While this template provides a strong foundation, evaluate and iterate on the instructions based on your specific use case and objectives. Test different variations to find what works best for your scenario.

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.

Connect to a remote SharePoint knowledge source

In this preview, Foundry Agent Service doesn’t support per-request headers for MCP tools. Headers set in agent definitions apply to all invocations and can’t vary by user or request.For per-user authorization, use the Azure OpenAI Responses API instead.
Optionally, if your knowledge base includes a remote SharePoint knowledge source, you must also include the x-ms-query-source-authorization header in the MCP tool connection. For more information, see Enforce permissions at query time (preview).

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.
The output should be similar to the following (truncated for brevity):

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_endpoint is the Azure AI Search service URL, such as https://<name>.search.windows.net.
  • Confirm knowledge_base_name matches the knowledge base you created in Azure AI Search.
  • Confirm you use the 2026-05-01-preview API version for the knowledge base MCP endpoint.

The agent doesn’t ground answers

  • Confirm the agent has the MCP tool configured and allowed_tools includes knowledge_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.