Skip to content

Commit fb5178a

Browse files
authored
Update model-context-protocol-samples.md
1 parent 86a25d6 commit fb5178a

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

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

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ curl --request POST \
3535
"type": "mcp",
3636
"server_label": "<unique name for your MCP server>",
3737
"server_url": "<your MCP server url>",
38-
"require_approval": "never",
38+
"allowed_tools": ["<tool_name>"], # optional
3939
}
4040
],
4141
"name": "my-assistant",
@@ -68,7 +68,12 @@ 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.
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+
1. `always` by default
74+
2. `never` meaning no approval is required
75+
3. `{"never":[<tool_name_1>, <tool_name_2>]}` you can also provide a list of tools without required approval
76+
4. `{"always":[<tool_name_1>, <tool_name_2>]}` you can provide a list of tools with required approval
7277

7378
```bash
7479
curl --request POST \
@@ -81,9 +86,11 @@ curl --request POST \
8186
"mcp": [
8287
{
8388
"server_label": "<the same unique name you provided during agent creation>",
89+
"require_approval": "always" #always by default
8490
"headers": {
8591
"Authorization": "Bearer <token>",
8692
}
93+
8794
}
8895
]
8996
},
@@ -97,6 +104,62 @@ curl --request GET \
97104
-H "Authorization: Bearer $AGENT_TOKEN"
98105
```
99106

107+
If the model is trying to invoke a tool in your MCP server with approval required, you will get a run with `require_action` status.
108+
```bash
109+
{
110+
"id": "run_123",
111+
"object": "thread.run",
112+
...
113+
"status": "requires_action",
114+
...
115+
"required_action": {
116+
"type": "submit_tool_approval",
117+
"submit_tool_approval": {
118+
"tool_calls": [
119+
{
120+
"id": "call_123",
121+
"type": "mcp",
122+
"arguments": "{...}",
123+
"name": "<tool_name>",
124+
"server_label": "<server_label_you_provided>"
125+
}
126+
]
127+
}
128+
},
129+
...
130+
"tools": [
131+
{
132+
"type": "mcp",
133+
"server_label": "<server_label_you_provided>",
134+
"server_url": "<server_url_you_provided>",
135+
"allowed_tools": null
136+
}
137+
],
138+
...
139+
}
140+
```
141+
Make sure you carefully reviewed the tool and argument(s) to be passed and make an informed decision for approval.
142+
143+
## Submit your approval
144+
If you decide to approve, you need to set the `approve` parameter to be `true` with the `id` for tool calls above.
145+
```bash
146+
curl --request POST \
147+
--url $AZURE_AI_FOUNDRY_PROJECT_ENDPOINT/threads/thread_abc123/runs/run_abc123/submit_tool_outputs?api-version=$API_VERSION \
148+
-H "Authorization: Bearer $AGENT_TOKEN" \
149+
-H "Content-Type: application/json" \
150+
-d '{
151+
"tool_approvals": [
152+
{
153+
"tool_call_id": "call_abc123",
154+
"approve": true,
155+
"headers": {
156+
}
157+
}
158+
]
159+
}
160+
```
161+
162+
100163
## Retrieve the agent response
101164
102165
```bash

0 commit comments

Comments
 (0)