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
Copy file name to clipboardExpand all lines: articles/ai-foundry/agents/how-to/tools/model-context-protocol-samples.md
+67-3Lines changed: 67 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ ms.custom: azure-ai-agents-code
17
17
18
18
Use this article to find step-by-step instructions and code samples for connecting Foundry Agent service with MCP.
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
22
23
23
## Create an Agent with the MCP tool enabled
@@ -35,7 +35,7 @@ curl --request POST \
35
35
"type": "mcp",
36
36
"server_label": "<unique name for your MCP server>",
37
37
"server_url": "<your MCP server url>",
38
-
"require_approval": "never",
38
+
"allowed_tools": ["<tool_name>"], # optional
39
39
}
40
40
],
41
41
"name": "my-assistant",
@@ -68,7 +68,13 @@ 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.
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:
73
+
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
72
78
73
79
```bash
74
80
curl --request POST \
@@ -81,9 +87,11 @@ curl --request POST \
81
87
"mcp": [
82
88
{
83
89
"server_label": "<the same unique name you provided during agent creation>",
90
+
"require_approval": "always" #always by default
84
91
"headers": {
85
92
"Authorization": "Bearer <token>",
86
93
}
94
+
87
95
}
88
96
]
89
97
},
@@ -97,6 +105,62 @@ curl --request GET \
97
105
-H "Authorization: Bearer $AGENT_TOKEN"
98
106
```
99
107
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.
109
+
```bash
110
+
{
111
+
"id": "run_123",
112
+
"object": "thread.run",
113
+
...
114
+
"status": "requires_action",
115
+
...
116
+
"required_action": {
117
+
"type": "submit_tool_approval",
118
+
"submit_tool_approval": {
119
+
"tool_calls": [
120
+
{
121
+
"id": "call_123",
122
+
"type": "mcp",
123
+
"arguments": "{...}",
124
+
"name": "<tool_name>",
125
+
"server_label": "<server_label_you_provided>"
126
+
}
127
+
]
128
+
}
129
+
},
130
+
...
131
+
"tools": [
132
+
{
133
+
"type": "mcp",
134
+
"server_label": "<server_label_you_provided>",
135
+
"server_url": "<server_url_you_provided>",
136
+
"allowed_tools": null
137
+
}
138
+
],
139
+
...
140
+
}
141
+
```
142
+
Make sure you carefully reviewed the tool and argument(s) to be passed and make an informed decision for approval.
143
+
144
+
## 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.
0 commit comments