Skip to content

Commit a53a9ec

Browse files
committed
Updates to use toolset
1 parent 9619e9b commit a53a9ec

2 files changed

Lines changed: 16 additions & 31 deletions

File tree

Instructions/03c-use-agent-tools-with-mcp.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ In this task, you'll connect to a remote MCP server, prepare the AI agent, and r
123123
# Add references
124124
from azure.identity import DefaultAzureCredential
125125
from azure.ai.agents import AgentsClient
126-
from azure.ai.agents.models import McpTool
126+
from azure.ai.agents.models import McpTool, ToolSet
127127
```
128128
129129
1. Find the comment **Connect to the agents client** and add the following code to connect to the Azure AI project using the current Azure credentials.
@@ -144,25 +144,29 @@ In this task, you'll connect to a remote MCP server, prepare the AI agent, and r
144144
```python
145145
# Initialize agent MCP tool
146146
mcp_tool = McpTool(
147-
server_label=mcp_server_label,
148-
server_url=mcp_server_url,
147+
server_label=mcp_server_label,
148+
server_url=mcp_server_url,
149149
)
150+
151+
mcp_tool.set_approval_mode("never")
152+
153+
toolset = ToolSet()
154+
toolset.add(mcp_tool)
150155
```
151156
152157
This code will connect to the Microsft Learn Docs remote MCP server. This is a cloud-hosted service that enables clients to access trusted and up-to-date information directly from Microsoft's official documentation.
153158
154-
1. Under the comment **Create a new agent with the mcp tool definitions** and add the following code:
159+
1. Under the comment **Create a new agent** and add the following code:
155160
156161
```python
157-
# Create a new agent with the mcp tool definitions
162+
# Create a new agent
158163
agent = agents_client.create_agent(
159164
model=model_deployment,
160165
name="my-mcp-agent",
161166
instructions="""
162167
You have access to an MCP server called `microsoft.docs.mcp` - this tool allows you to
163168
search through Microsoft's latest official documentation. Use the available MCP tools
164-
to answer questions and perform tasks.""",
165-
tools=mcp_tool.definitions,
169+
to answer questions and perform tasks."""
166170
)
167171
```
168172
@@ -188,25 +192,11 @@ In this task, you'll connect to a remote MCP server, prepare the AI agent, and r
188192
print(f"Created message, ID: {message.id}")
189193
```
190194
191-
1. Under the comment **Update mcp tool headers**, add the following code:
192-
193-
```python
194-
# Update mcp tool headers
195-
mcp_tool.update_headers("SuperSecret", "123456")
196-
```
197-
198-
1. Locate the comment **Set approval mode** and add the following code:
199-
200-
```python
201-
# Set approval mode
202-
mcp_tool.set_approval_mode("never")
203-
```
204-
205-
1. Locate the comment **Create and process agent run in thread with MCP tools** and add the following code:
195+
1. Find the comment **Create and process agent run in thread with MCP tools** and add the following code:
206196
207197
```python
208198
# Create and process agent run in thread with MCP tools
209-
run = agents_client.runs.create_and_process(thread_id=thread.id, agent_id=agent.id, tool_resources=mcp_tool.resources)
199+
run = agents_client.runs.create_and_process(thread_id=thread.id, agent_id=agent.id, toolset=toolset)
210200
print(f"Created run, ID: {run.id}")
211201
```
212202
@@ -259,8 +249,9 @@ In this task, you'll connect to a remote MCP server, prepare the AI agent, and r
259249
---
260250
261251
### **1. Create a Resource Group**
262-
azurecli
252+
'''azurecli
263253
az group create --name myResourceGroup --location eastus
254+
'''
264255
265256
266257
{{continued...}}

Labfiles/03c-use-agent-tools-with-mcp/Python/client.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Create agent with MCP tool and process agent run
2323
with agents_client:
2424

25-
# Create a new agent with the mcp tool definitions
25+
# Create a new agent
2626

2727

2828
# Log info
@@ -35,12 +35,6 @@
3535
# Create a message on the thread
3636

3737

38-
# Update mcp tool headers
39-
40-
41-
# Set approval mode
42-
43-
4438
# Create and process agent run in thread with MCP tools
4539

4640

0 commit comments

Comments
 (0)