You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# How to use the Model Context Protocol (MCP) tool
16
+
# Code samples for Model Context Protocol tools
17
17
18
-
Use this article to find step-by-step instructions and code samples for connecting Foundry Agent service with MCP.
18
+
Use this article to find code samples for connecting Azure AI Foundry Agent Service with Model Context Protocol (MCP) servers.
19
19
20
-
Follow the [REST API Quickstart](../../quickstart.md?pivots=rest-api#api-call-information) to set the right values for the environment variables `AGENT_TOKEN`, `AZURE_AI_FOUNDRY_PROJECT_ENDPOINT`, and `API_VERSION`.
20
+
Follow the [REST API quickstart](../../quickstart.md?pivots=rest-api#api-call-information) to set the right values for the environment variables `AGENT_TOKEN`, `AZURE_AI_FOUNDRY_PROJECT_ENDPOINT`, and `API_VERSION`.
21
21
22
+
## Create an agent with the MCP tool enabled
22
23
23
-
## Create an Agent with the MCP tool enabled
24
+
To make the MCP tool available to your agent, initialize a tool with the server endpoint, server label, and more:
24
25
25
-
To make the MCP tool available to your agent, initialize a tool with the server endpoint, server label and more
"instructions": "You are a customer support chatbot. Use the tools provided and your knowledge base to best respond to customer queries.",
33
-
"tools": [
32
+
"instructions": "You are a customer support chatbot. Use the tools provided and your knowledge base to best respond to customer queries.",
33
+
"tools": [
34
34
{
35
35
"type": "mcp",
36
36
"server_label": "<unique name for your MCP server>",
@@ -68,26 +68,27 @@ curl --request POST \
68
68
69
69
## Create a run and check the output
70
70
71
-
Create a run to pass headers for the tool and observe that the model uses the Grounding with Bing Search tool to provide a response to the user's question.
72
-
`require_approval` parameter is optional. If not provided, `always` is the default value, meaning each time developer needs to approve before calling. Supported values:
71
+
Create a run to pass headers for the tool. Observe that the model uses the Grounding with Bing Search tool to provide a response to the user's question.
73
72
74
-
-`always` by default
75
-
-`never` meaning no approval is required
76
-
-`{"never":[<tool_name_1>, <tool_name_2>]}` you can also provide a list of tools without required approval
77
-
-`{"always":[<tool_name_1>, <tool_name_2>]}` you can provide a list of tools with required approval
73
+
The `require_approval` parameter is optional. Supported values are:
74
+
75
+
-`always`: A developer needs to provide approval for every call. If you don't provide a value, this one is the default.
76
+
-`never`: No approval is required.
77
+
-`{"never":[<tool_name_1>, <tool_name_2>]}`: You provide a list of tools that don't require approval.
78
+
-`{"always":[<tool_name_1>, <tool_name_2>]}`: You provide a list of tools that require approval.
title: 'How to connect to Model Context Protocol Server Endpoint in Azure AI Foundry Agent Service'
2
+
title: Connect to a Model Context Protocol Server Endpoint in Azure AI Foundry Agent Service
3
3
titleSuffix: Azure AI Foundry
4
-
description: Learn how to add MCP to Foundry Agent service.
4
+
description: Learn how to add MCP servers to Azure AI Foundry Agent Service.
5
5
services: cognitive-services
6
6
manager: nitinme
7
7
ms.service: azure-ai-agent-service
@@ -11,53 +11,69 @@ author: aahill
11
11
ms.author: aahi
12
12
ms.custom: references_regions
13
13
---
14
-
# Connect to Model Context Protocol (MCP) Servers (Preview)
15
-
You can extend the capabilities of your Foundry Agent by connecting it to tools hosted on remote Model Context Protocol (MCP) servers (bring your own MCP server endpoint). These servers are maintained by developers and organizations and expose tools that can be accessed by MCP-compatible clients, such as the Foundry Agent service.
16
14
17
-
[Model Context Protocol](https://modelcontextprotocol.io/introduction) (MCP) is an open standard that defines how applications provide tools and contextual data to large language models (LLMs). It enables consistent, scalable integration of external tools into model workflows.
15
+
# Connect to Model Context Protocol servers (preview)
18
16
19
-
> [!IMPORTANT]
20
-
> * Your use of connected non-Microsoft services is subject to the terms between you and the service provider. By connecting to a non-Microsoft service, some of your data, such as prompt content, is passed to the non-Microsoft service, and/or your application might receive data from the non-Microsoft service. You are responsible for your use (and any charges associated with your use) of non-Microsoft services and data.
21
-
> * The remote MCP servers you decide to use with this MCP tool were created by third parties, not Microsoft, and have not been tested or verified by Microsoft. Microsoft has no responsibility to you or others in relation to your use of any remote MCP servers. We recommend carefully reviewing and tracking what MCP servers you add to Foundry Agent service and relying on servers hosted by trusted service providers themselves rather than proxies. This MCP tool also allows you to pass custom headers such as authentication keys or schema as might be needed by a remote MCP server. We recommend reviewing all data being shared with remote MCP servers and optionally logging it for auditing purposes. Be cognizant of non-Microsoft practices for retention and location of data.
17
+
You can extend the capabilities of your Azure AI Foundry agent by connecting it to tools hosted on remote [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) servers (bring your own MCP server endpoint). Developers and organizations maintain these servers. The servers expose tools that MCP-compatible clients, such as Azure AI Foundry Agent Service, can access.
18
+
19
+
MCP is an open standard that defines how applications provide tools and contextual data to large language models (LLMs). It enables consistent, scalable integration of external tools into model workflows.
20
+
21
+
## Considerations for using non-Microsoft services and servers
22
+
23
+
Your use of connected non-Microsoft services is subject to the terms between you and the service provider. By connecting to a non-Microsoft service, some of your data (such as prompt content) is passed 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.
24
+
25
+
The remote MCP servers that you decide to use with the MCP tool described in this article were created by third parties, not Microsoft. Microsoft hasn't tested or verified these servers. Microsoft has no responsibility to you or others in relation to your use of any remote MCP servers.
26
+
27
+
We recommend that you carefully review and track what MCP servers you add to Foundry Agent Service. We also recommend that you rely on servers hosted by trusted service providers themselves rather than proxies.
28
+
29
+
The MCP tool allows you to pass custom headers, such as authentication keys or schemas, that a remote MCP server might need. We recommend that you review all data that's shared with remote MCP servers and that you log the data for auditing purposes. Be cognizant of non-Microsoft practices for retention and location of data.
22
30
23
31
## How it works
24
-
You can bring multiple remote MCP servers to Foundry Agent service by adding them as tools. For each tool, you need to provide a unique `server_label` within the same agent and `server_url` that points to the remote MCP server. The MCP tool supports custom headers, allowing you to connect to these servers using the authentication scheme they require or passing other headers required by the MCP server. You can only specify headers by including in `tool_resources` at each run such as API keys, OAuth access tokens, or other credentials directly in your request. The most commonly used header is the authorization header. For more information on using MCP, see:
25
-
*[Security best practices](https://modelcontextprotocol.io/specification/draft/basic/security_best_practices)
26
-
*[Understanding and mitigating security risks in MCP implementations](https://techcommunity.microsoft.com/blog/microsoft-security-blog/understanding-and-mitigating-security-risks-in-mcp-implementations/4404667)
27
32
28
-
> [!Note]
29
-
> * You need to bring a remote MCP server (an existing MCP server endpoint)
30
-
> * With current MCP tool in Foundry Agent, approval is required by default. Please review carefully what MCP server(s) you added to Foundry Agent service. We recommend reviewing all data being shared with remote MCP servers and optionally logging it for auditing purposes.
31
-
> * Supported regions: `westus`, `westus2`, `uaenorth`, `southindia` and `switzerlandnorth`
32
-
> * The MCP tool supports custom headers for a specific run, allowing you to pass headers as needed by MCP server, such as authentication schema. Headers you pass in will only be available for the current run and will not be persisted.
33
+
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 unique `server_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.
34
+
35
+
The MCP tool supports custom headers, so you can connect to the MCP servers by using the authentication schemas that they require or by passing other headers that the MCP servers require. You can specify headers only by including them in `tool_resources` at each run. In this way, you can put API keys, OAuth access tokens, or other credentials directly in your request.
36
+
37
+
The most commonly used header is the authorization header. Headers that you pass in are available only for the current run and aren't persisted.
38
+
39
+
For more information on using MCP, see:
40
+
41
+
*[Security Best Practices](https://modelcontextprotocol.io/specification/draft/basic/security_best_practices) on the Model Context Protocol website
42
+
*[Understanding and mitigating security risks in MCP implementations](https://techcommunity.microsoft.com/blog/microsoft-security-blog/understanding-and-mitigating-security-risks-in-mcp-implementations/4404667) in the Microsoft Security Community Blog
43
+
44
+
> [!NOTE]
45
+
> Supported regions are `westus`, `westus2`, `uaenorth`, `southindia` and `switzerlandnorth`.
33
46
34
47
## Usage support
35
48
36
-
|Azure AI foundry support | Python SDK |C# SDK | JavaScript SDK | REST API |Basic agent setup | Standard agent setup |
49
+
|Azure AI foundry support | Python SDK |C# SDK | JavaScript SDK | REST API |Basic agent setup | Standard agent setup |
1. Create an Azure AI Foundry Agent by following the steps in the [quickstart](../../quickstart.md).
53
+
## Setup
42
54
43
-
1. Find the remote MCP server you want to connect to, such as GitHub MCP Server. Create or update a Foundry Agent with a `mcp` tool with the following information:
44
-
1.`server_url`: the url of the MCP server, for example, `https://api.githubcopilot.com/mcp/`
45
-
2.`server_label`: a unique identifier of this MCP server to the agent, for example, `github`
46
-
3.`allowed_tools`: optional, a list of tools you want to allow without approval
55
+
1. Create an Azure AI Foundry agent by following the steps in the [quickstart](../../quickstart.md).
56
+
57
+
1. Find the remote MCP server that you want to connect to, such as the GitHub MCP server. Create or update an Azure AI Foundry agent with an `mcp` tool with the following information:
58
+
59
+
1.`server_url`: The URL of the MCP server; for example, `https://api.githubcopilot.com/mcp/`.
60
+
2.`server_label`: A unique identifier of this MCP server to the agent; for example, `github`.
61
+
3.`allowed_tools`: An optional list of tools that you want to allow without approval.
47
62
48
-
1. Create a run and pass additional information about the `mcp` tool in `tool_resources` with headers
49
-
1.`tool_label`: use the identifier you provided during create/update agent
50
-
2.`headers`: pass a set of headers required by the MCP server
51
-
3.`require_approval`: optional, if not provided, `always` is the default value, meaning each time developer needs to approve before calling. Supported values:
52
-
1.`always` by default
53
-
2.`never` meaning no approval is required
54
-
3.`{"never":[<tool_name_1>, <tool_name_2>]}` you can also provide a list of tools without required approval
55
-
4.`{"always":[<tool_name_1>, <tool_name_2>]}` you can provide a list of tools with required approval
63
+
1. Create a run and pass additional information about the `mcp` tool in `tool_resources` with headers:
64
+
65
+
1.`tool_label`: Use the identifier that you provided when you created the agent.
66
+
2.`headers`: Pass a set of headers that the MCP server requires.
67
+
3.`require_approval`: Optionally determine whether approval is required. Supported values are:
68
+
*`always`: A developer needs to provide approval for every call. If you don't provide a value, this one is the default.
69
+
*`never`: No approval is required.
70
+
*`{"never":[<tool_name_1>, <tool_name_2>]}`: You provide a list of tools that don't require approval.
71
+
*`{"always":[<tool_name_1>, <tool_name_2>]}`: You provide a list of tools that require approval.
56
72
57
-
1. If the model is trying to invoke a tool in your MCP server with approval required, you will get Run status as`require_action`. Within `require_action` field, you can get more details on which tool in MCP server to be called, argument(s) to be passed and `call_id`. Make sur eyou review the tool, argument(s) and make an informed decision for approval.
73
+
1. If the model tries to invoke a tool in your MCP server with approval required, you get a run status of`require_action`. In the `requires_action` field, you can get more details on which tool in MCP server is called, arguments to be passed, and `call_id` value. Review the tool and arguments so that you can make an informed decision for approval.
58
74
59
-
1. Submit your approval to the agent with `call_id` by setting `approve` to `true.
75
+
1. Submit your approval to the agent with `call_id` by setting `approve` to `true`.
60
76
61
-
## Next steps
77
+
## Related content
62
78
63
-
*[How to use the MCP tool](./model-context-protocol-samples.md)
79
+
*[Code samples for Model Context Protocol tools](./model-context-protocol-samples.md)
0 commit comments