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
+65-2Lines changed: 65 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -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,12 @@ 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
+
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
72
77
73
78
```bash
74
79
curl --request POST \
@@ -81,9 +86,11 @@ curl --request POST \
81
86
"mcp": [
82
87
{
83
88
"server_label": "<the same unique name you provided during agent creation>",
89
+
"require_approval": "always" #always by default
84
90
"headers": {
85
91
"Authorization": "Bearer <token>",
86
92
}
93
+
87
94
}
88
95
]
89
96
},
@@ -97,6 +104,62 @@ curl --request GET \
97
104
-H "Authorization: Bearer $AGENT_TOKEN"
98
105
```
99
106
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.
0 commit comments