Skip to content

Commit ef6e262

Browse files
committed
edit pass: azure-ai-foundry-agent-service-mcp-documentation
1 parent edac404 commit ef6e262

File tree

2 files changed

+79
-58
lines changed

2 files changed

+79
-58
lines changed

articles/ai-foundry/agents/how-to/tools/model-context-protocol-samples.md

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: 'MCP tool code samples'
2+
title: Code Samples for Model Context Protocol Tools
33
titleSuffix: Azure AI Foundry
4-
description: Find code samples to connect Foundry Agent service with MCP.
4+
description: Find code samples to connect Azure AI Foundry Agent Service with MCP servers.
55
services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
@@ -13,24 +13,24 @@ zone_pivot_groups: selection-mcp-code
1313
ms.custom: azure-ai-agents-code
1414
---
1515

16-
# How to use the Model Context Protocol (MCP) tool
16+
# Code samples for Model Context Protocol tools
1717

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.
1919

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`.
2121

22+
## Create an agent with the MCP tool enabled
2223

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:
2425

25-
To make the MCP tool available to your agent, initialize a tool with the server endpoint, server label and more
2626
```bash
2727
curl --request POST \
2828
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/assistants?api-version=$API_VERSION \
2929
-H "Authorization: Bearer $AGENT_TOKEN" \
3030
-H "Content-Type: application/json" \
3131
-d "{
32-
"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": [
3434
{
3535
"type": "mcp",
3636
"server_label": "<unique name for your MCP server>",
@@ -68,26 +68,27 @@ curl --request POST \
6868

6969
## Create a run and check the output
7070

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.
7372

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.
7879

7980
```bash
8081
curl --request POST \
8182
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs?api-version=$API_VERSION \
8283
-H "Authorization: Bearer $AGENT_TOKEN" \
8384
-H "Content-Type: application/json" \
8485
-d '{
85-
"assistant_id": "<agent_id>",
86-
"tool_resources": {
86+
"assistant_id": "<agent_id>",
87+
"tool_resources": {
8788
"mcp": [
8889
{
8990
"server_label": "<the same unique name you provided during agent creation>",
90-
"require_approval": "always" #always by default
91+
"require_approval": "always" #always by default
9192
"headers": {
9293
"Authorization": "Bearer <token>",
9394
}
@@ -97,6 +98,7 @@ curl --request POST \
9798
},
9899
}'
99100
```
101+
100102
## Retrieve the status of the run
101103

102104
```bash
@@ -105,7 +107,8 @@ curl --request GET \
105107
-H "Authorization: Bearer $AGENT_TOKEN"
106108
```
107109

108-
If the model is trying to invoke a tool in your MCP server with approval required, you get a run with `require_action` status.
110+
If the model tries to invoke a tool in your MCP server with approval required, you get a run with `requires_action` status:
111+
109112
```bash
110113
{
111114
"id": "run_123",
@@ -139,17 +142,20 @@ If the model is trying to invoke a tool in your MCP server with approval require
139142
...
140143
}
141144
```
142-
Make sure you carefully reviewed the tool and argument(s) to be passed and make an informed decision for approval.
145+
146+
Carefully review the tool and arguments to be passed so that you can make an informed decision for approval.
143147

144148
## Submit your approval
145-
If you decide to approve, you need to set the `approve` parameter to be `true` with the `id` for the preceding tool calls.
149+
150+
If you decide to approve, set the `approve` parameter to `true` with the `id` value for the preceding tool calls:
151+
146152
```bash
147153
curl --request POST \
148154
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123/submit_tool_outputs?api-version=$API_VERSION \
149155
-H "Authorization: Bearer $AGENT_TOKEN" \
150156
-H "Content-Type: application/json" \
151157
-d '{
152-
"tool_approvals": [
158+
"tool_approvals": [
153159
{
154160
"tool_call_id": "call_abc123",
155161
"approve": true,
@@ -160,7 +166,6 @@ curl --request POST \
160166
}
161167
```
162168
163-
164169
## Retrieve the agent response
165170
166171
```bash
Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
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
33
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.
55
services: cognitive-services
66
manager: nitinme
77
ms.service: azure-ai-agent-service
@@ -11,53 +11,69 @@ author: aahill
1111
ms.author: aahi
1212
ms.custom: references_regions
1313
---
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.
1614

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)
1816

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.
2230

2331
## 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)
2732

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`.
3346
3447
## Usage support
3548

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 |
3750
|:---------:|:---------:|:---------:|:---------:|:---------:|:---------:|---------:|
3851
| - | - | - | - | ✔️ | ✔️ | ✔️ |
3952

40-
## Setup
41-
1. Create an Azure AI Foundry Agent by following the steps in the [quickstart](../../quickstart.md).
53+
## Setup
4254

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.
4762

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.
5672

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.
5874

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`.
6076

61-
## Next steps
77+
## Related content
6278

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

Comments
 (0)