- Add a remote MCP server as a tool.
- Authenticate to an MCP server by using a project connection.
- Review and approve MCP tool calls.
- Troubleshoot common MCP integration issues.
Usage support
The following table shows SDK and setup support for MCP connections.| Microsoft Foundry support | Python SDK | C# SDK | JavaScript SDK | Java SDK | REST API | Basic agent setup | Standard agent setup |
|---|---|---|---|---|---|---|---|
| ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Prerequisites
Before you begin, make sure you have:- An Azure subscription with an active Microsoft Foundry project.
- Azure role-based access control (RBAC): Contributor or Owner role on the Foundry project.
- The latest SDK package for your language. The .NET SDK is currently in preview. For installation details, see the quickstart.
- Azure credentials configured for authentication (such as
DefaultAzureCredential). - Access to a remote MCP server endpoint (such as GitHub’s MCP server at
https://api.githubcopilot.com/mcp).
Public and private MCP server endpoints
Agent Service supports both public and private MCP server endpoints:- Public endpoints: Connect to any publicly accessible remote MCP server. This option works with both Basic and Standard agent setups.
- Private endpoints: Connect to MCP servers that aren’t exposed to the public internet. Private MCP requires Standard Agent Setup with private networking and a dedicated MCP subnet within your virtual network.
Microsoft.App/environments. To get started, use the 19-private-network-agents-tools-setup template, which provisions the required network infrastructure including the MCP subnet.
For details about tool support in network-isolated environments, see Agent tools with network isolation.
Use Foundry Toolboxes as MCP endpoints
Foundry Toolboxes (preview) let you bundle multiple tools - such as Web Search, Code Interpreter, File Search, Azure AI Search, MCP servers, OpenAPI tools, and Agent-to-Agent connections - into a single MCP-compatible endpoint. Instead of configuring each tool separately on every agent, create a Toolbox in Foundry and point your agent to the Toolbox endpoint by using the standardmcp tool configuration (server_url and server_label).
Because the Toolbox endpoint is MCP-compatible, any runtime that can consume an MCP server can also consume a Toolbox. This compatibility includes Foundry Agent Service, Microsoft Agent Framework, LangGraph, GitHub Copilot SDK, and other MCP-enabled clients. You can add, remove, or reconfigure tools in the Toolbox without changing your agent code.
For setup steps, see Create and use a Foundry Toolbox.
Authentication
Many MCP servers require authentication. In Foundry Agent Service, use a project connection to store authentication details, such as API keys or bearer tokens, instead of hard-coding credentials in your app. To learn about supported authentication options, including key-based, Microsoft Entra identities, and OAuth identity passthrough, see MCP server authentication.Set
project_connection_id to the ID of your project connection.DefaultAzureCredential, and individual tool credentials don’t need to be passed by each agent. For Toolbox auth configuration, see Toolbox prerequisites.
Considerations for using non-Microsoft services and servers
You’re subject to the terms between you and the service provider when you use connected non-Microsoft services. When you connect to a non-Microsoft service, you pass some of your data, such as prompt content, to the non-Microsoft service, or your application might receive data from the non-Microsoft service. You’re responsible for your use of non-Microsoft services and data, along with any charges associated with that use. Third parties, not Microsoft, create the remote MCP servers that you decide to use with the MCP tool described in this article. Microsoft doesn’t test or verify these servers. Microsoft has no responsibility to you or others in relation to your use of any remote MCP servers. Carefully review and track what MCP servers you add to Foundry Agent Service. Rely on servers hosted by trusted service providers themselves rather than proxies. The MCP tool allows you to pass custom headers, such as authentication keys or schemas, that a remote MCP server might need. Review all data that you share with remote MCP servers and log the data for auditing purposes. Be aware of non-Microsoft practices for retention and location of data.Foundry Toolboxes are different from third-party MCP servers. Toolboxes are organization-governed resources that you create and manage within your Microsoft Foundry project. However, you’re still responsible for tool selection, data handling, and compliance when curating Toolbox contents.
Best practices
For general guidance on tool usage, see Best practices for using tools in Microsoft Foundry Agent Service. When you use MCP servers, follow these practices:- Use an allow list of tools by using
allowed_tools. - Require approval for high-risk operations, especially tools that write data or change resources.
- Review the requested tool name and arguments before you approve.
- Log approvals and tool calls for auditing and troubleshooting.
Create an agent in Python with the MCP tool
Use the following code sample to create an agent and call the function. The .NET SDK is currently in preview. See the quickstart for details.How it works
You need to bring a remote MCP server (an existing MCP server endpoint) to Foundry Agent Service. You can bring multiple remote MCP servers by adding them as tools. For each tool, you need to provide a uniqueserver_label value within the same agent and a server_url value that points to the remote MCP server. Be sure to carefully review which MCP servers you add to Foundry Agent Service.
In addition to connecting arbitrary remote MCP servers by URL, some MCP servers can be added directly from the Foundry Add Tools catalog. For example, Azure DevOps MCP Server (preview) is available as a catalog entry. Catalog entries simplify connection setup and align with the same approval and auditing mechanisms documented in this article.
For more information on using MCP, see:
- Security Best Practices on the Model Context Protocol website.
- Understanding and mitigating security risks in MCP implementations in the Microsoft Security Community Blog.
Set up the MCP connection
The following steps outline how to connect to a remote MCP server from Foundry Agent Service:- Find the remote MCP server that you want to connect to, such as the GitHub MCP server. Create or update a Foundry agent with an
mcptool by using the following information:server_url: The URL of the MCP server, such ashttps://api.githubcopilot.com/mcp/.server_label: A unique identifier of this MCP server to the agent, such asgithub.allowed_tools: An optional list of tools that this agent can access and use. If you don’t provide this value, the default value includes all of the tools in the MCP server.require_approval: Optionally determine whether approval is required. The default value isalways. Supported values are:always: A developer needs to provide approval for every call. If you don’t provide a value, this one is the default.never: No approval is required.{"never":[<tool_name_1>, <tool_name_2>]}: You provide a list of tools that don’t require approval.{"always":[<tool_name_1>, <tool_name_2>]}: You provide a list of tools that require approval.
project_connection_id: The project connection ID that stores authentication and other connection details for the MCP server.- If the model tries to invoke a tool in your MCP server with approval required, you get a response output item type as
mcp_approval_request. In the response output item, you can get more details on which tool in the MCP server is called and arguments to be passed. Review the tool and arguments so that you can make an informed decision for approval. - Submit your approval to the agent by using
previous_response_idand settingapprovetotrue.
Connect to Azure DevOps MCP Server
Azure DevOps MCP Server (preview) is available as a catalog entry in Foundry. To add it:- In Foundry portal, go to your project.
- Select Add Tools > Catalog and search for “Azure DevOps.”
- Select Azure DevOps MCP Server (preview) and select Create.
- Enter your Azure DevOps organization name and select Connect.
- Choose which Azure DevOps tools to expose to your agent. You can select a subset of tools to control exactly what the agent can access.
Known limitations
- Non-streaming MCP tool call timeout: Non-streaming MCP tool calls have a timeout of 100 seconds. If your MCP server takes longer than 100 seconds to respond, the call fails. To avoid timeouts, ensure that your MCP server responds within this limit. If your use case requires longer processing times, consider optimizing the server-side logic or breaking the operation into smaller steps.
- Private MCP requires Standard Agent Setup: Private MCP server connectivity is only available with Standard Agent Setup with private networking (BYO VNet). Basic agent setup doesn’t support private MCP endpoints.
- Private MCP hosting: Azure Container Apps on a dedicated MCP subnet is the tested configuration for private MCP servers. Function Apps or App Services as the private MCP server host might work but aren’t internally validated.
Common questions and errors
The following common issues might occur when you use MCP tools with Foundry Agent Service:-
“Invalid tool schema”:
This error usually happens if your MCP server definition includes
anyOforallOf, or if a parameter accepts multiple types of values. Update your MCP server definition and try again. - “Unauthorized” or “Forbidden” from the MCP server: Confirm the MCP server supports your authentication method, and verify the credentials stored in your project connection. For GitHub, use least-privilege tokens and rotate them regularly.
-
The model never calls your MCP tool:
Confirm your agent instructions encourage tool usage, and verify
server_label,server_url, andallowed_toolsvalues. If you setallowed_tools, make sure the tool name matches what the MCP server exposes. -
The agent never continues after approval:
Confirm you send a follow-up request with
previous_response_idset to the original response ID, and that you use the approval request item ID asapproval_request_id.
Host a local MCP server
The Agent Service runtime only accepts a remote MCP server endpoint. If you want to add tools from a local MCP server, you need to self-host it on Azure Container Apps or Azure Functions to get a remote MCP server endpoint. The remote endpoint can be either a public endpoint or a private endpoint within your VNet. For private MCP servers, deploy your Container App with internal-only ingress (--internal-only true) on a dedicated MCP subnet. See Public and private MCP server endpoints for setup details.
Consider the following factors when hosting local MCP servers in the cloud:
| Local MCP server setup | Hosting in Azure Container Apps | Hosting in Azure Functions |
|---|---|---|
| Transport | HTTP POST/GET endpoints required. | HTTP streamable required. |
| Code changes | Container rebuild required. | Azure Functions-specific configuration files required in the root directory. |
| Authentication | Custom authentication implementation required. | Key-based only. OAuth needs API Management. |
| Language | Any language that runs in Linux containers (Python, Node.js, .NET, TypeScript, Go). | Python, Node.js, Java, .NET only. |
| Container requirements | Linux (linux/amd64) only. No privileged containers. | Containerized servers aren’t supported. |
| Dependencies | All dependencies must be in container image. | OS-level dependencies (such as Playwright) aren’t supported. |
| State | Stateless only. | Stateless only. |
| UVX/NPX | Supported. | Not supported. npx start commands not supported. |
Related content
- Get started with agents using code
- MCP server authentication
- Build and register a Model Context Protocol (MCP) server
- Set up private networking for Foundry Agent Service
- Configure private link for Foundry
- MCP tool REST reference
- Security Best Practices for MCP
- Understanding and mitigating security risks in MCP implementations