Skip to content

Commit e34effa

Browse files
committed
Doc updates
1 parent 19572ad commit e34effa

7 files changed

Lines changed: 217 additions & 20 deletions

File tree

agent-framework/tutorials/agents/TOC.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
href: multi-turn-conversation.md
77
- name: Using function tools with an agent
88
href: function-tools.md
9-
- name: Using function tools with human in the loop approvals
10-
href: function-tools-approvals.md
119
- name: Producing Structured Output with agents
1210
href: structured-output.md
1311
- name: Using an agent as a function tool
1412
href: agent-as-function-tool.md
15-
- name: Exposing an agent as an MCP tool
16-
href: agent-as-mcp-tool.md
1713
- name: Enabling observability for agents
1814
href: enable-observability.md
1915
- name: Adding middleware to agents

agent-framework/tutorials/workflows/TOC.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
- name: Handle requests and responses in workflows
1010
href: requests-and-responses.md
1111
- name: Checkpointing and resuming workflows
12-
href: checkpointing-and-resuming.md
13-
- name: Visualizing workflows
14-
href: visualization.md
12+
href: checkpointing-and-resuming.md

agent-framework/user-guide/model-context-protocol/using-mcp-tools.md

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,122 @@ The full source code and instructions to run this sample is available [here](htt
129129
::: zone-end
130130
::: zone pivot="programming-language-python"
131131

132-
Coming soon.
132+
The Python Agent Framework provides comprehensive support for integrating with Model Context Protocol (MCP) servers through multiple connection types. This allows your agents to access external tools and services seamlessly.
133+
134+
## MCP Tool Types
135+
136+
The Agent Framework supports three types of MCP connections:
137+
138+
### MCPStdioTool - Local MCP Servers
139+
140+
Use `MCPStdioTool` to connect to MCP servers that run as local processes using standard input/output:
141+
142+
```python
143+
import asyncio
144+
from agent_framework import ChatAgent, MCPStdioTool
145+
from agent_framework.openai import OpenAIChatClient
146+
147+
async def local_mcp_example():
148+
"""Example using a local MCP server via stdio."""
149+
async with (
150+
MCPStdioTool(
151+
name="calculator",
152+
command="uvx",
153+
args=["mcp-server-calculator"]
154+
) as mcp_server,
155+
ChatAgent(
156+
chat_client=OpenAIChatClient(),
157+
name="MathAgent",
158+
instructions="You are a helpful math assistant that can solve calculations.",
159+
) as agent,
160+
):
161+
result = await agent.run(
162+
"What is 15 * 23 + 45?",
163+
tools=mcp_server
164+
)
165+
print(result)
166+
167+
if __name__ == "__main__":
168+
asyncio.run(local_mcp_example())
169+
```
170+
171+
### MCPStreamableHTTPTool - HTTP/SSE MCP Servers
172+
173+
Use `MCPStreamableHTTPTool` to connect to MCP servers over HTTP with Server-Sent Events:
174+
175+
```python
176+
import asyncio
177+
from agent_framework import ChatAgent, MCPStreamableHTTPTool
178+
from agent_framework.azure import AzureAIAgentClient
179+
from azure.identity.aio import AzureCliCredential
180+
181+
async def http_mcp_example():
182+
"""Example using an HTTP-based MCP server."""
183+
async with (
184+
AzureCliCredential() as credential,
185+
MCPStreamableHTTPTool(
186+
name="Microsoft Learn MCP",
187+
url="https://learn.microsoft.com/api/mcp",
188+
headers={"Authorization": "Bearer your-token"},
189+
) as mcp_server,
190+
ChatAgent(
191+
chat_client=AzureAIAgentClient(async_credential=credential),
192+
name="DocsAgent",
193+
instructions="You help with Microsoft documentation questions.",
194+
) as agent,
195+
):
196+
result = await agent.run(
197+
"How to create an Azure storage account using az cli?",
198+
tools=mcp_server
199+
)
200+
print(result)
201+
202+
if __name__ == "__main__":
203+
asyncio.run(http_mcp_example())
204+
```
205+
206+
### MCPWebsocketTool - WebSocket MCP Servers
207+
208+
Use `MCPWebsocketTool` to connect to MCP servers over WebSocket connections:
209+
210+
```python
211+
import asyncio
212+
from agent_framework import ChatAgent, MCPWebsocketTool
213+
from agent_framework.openai import OpenAIChatClient
214+
215+
async def websocket_mcp_example():
216+
"""Example using a WebSocket-based MCP server."""
217+
async with (
218+
MCPWebsocketTool(
219+
name="realtime-data",
220+
url="wss://api.example.com/mcp",
221+
) as mcp_server,
222+
ChatAgent(
223+
chat_client=OpenAIChatClient(),
224+
name="DataAgent",
225+
instructions="You provide real-time data insights.",
226+
) as agent,
227+
):
228+
result = await agent.run(
229+
"What is the current market status?",
230+
tools=mcp_server
231+
)
232+
print(result)
233+
234+
if __name__ == "__main__":
235+
asyncio.run(websocket_mcp_example())
236+
```
237+
238+
## Popular MCP Servers
239+
240+
Common MCP servers you can use with Python Agent Framework:
241+
242+
- **Calculator**: `uvx mcp-server-calculator` - Mathematical computations
243+
- **Filesystem**: `uvx mcp-server-filesystem` - File system operations
244+
- **GitHub**: `npx @modelcontextprotocol/server-github` - GitHub repository access
245+
- **SQLite**: `uvx mcp-server-sqlite` - Database operations
246+
247+
Each server provides different tools and capabilities that extend your agent's functionality while maintaining the security and standardization benefits of the Model Context Protocol.
133248

134249
::: zone-end
135250

agent-framework/user-guide/model-context-protocol/using-mcp-with-foundry-agents.md

Lines changed: 99 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,107 @@ await persistentAgentsClient.Administration.DeleteAgentAsync(agent.Id);
144144
::: zone-end
145145
::: zone pivot="programming-language-python"
146146

147-
Coming soon.
147+
## Python Azure AI Foundry MCP Integration
148148

149-
::: zone-end
149+
Azure AI Foundry provides seamless integration with Model Context Protocol (MCP) servers through the Python Agent Framework. The service manages the MCP server hosting and execution, eliminating infrastructure management while providing secure, controlled access to external tools.
150+
151+
### Environment Setup
152+
153+
Configure your Azure AI Foundry project credentials through environment variables:
154+
155+
```python
156+
import os
157+
from azure.identity.aio import AzureCliCredential
158+
from agent_framework.azure import AzureAIAgentClient
159+
160+
# Required environment variables
161+
os.environ["AZURE_AI_PROJECT_ENDPOINT"] = "https://<your-project>.cognitiveservices.azure.com"
162+
os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"] = "gpt-4o-mini" # Optional, defaults to this
163+
```
150164

151-
To learn more refer to the [Azure AI Foundry Model Context Protocol documentation](/azure/ai-foundry/agents/how-to/tools/model-context-protocol).
165+
### Basic MCP Integration
166+
167+
Create an Azure AI Foundry agent with hosted MCP tools:
168+
169+
```python
170+
import asyncio
171+
from agent_framework import HostedMCPTool
172+
from agent_framework.azure import AzureAIAgentClient
173+
from azure.identity.aio import AzureCliCredential
174+
175+
async def basic_foundry_mcp_example():
176+
"""Basic example of Azure AI Foundry agent with hosted MCP tools."""
177+
async with (
178+
AzureCliCredential() as credential,
179+
AzureAIAgentClient(async_credential=credential) as chat_client,
180+
):
181+
# Enable Azure AI observability (optional but recommended)
182+
await chat_client.setup_azure_ai_observability()
183+
184+
# Create agent with hosted MCP tool
185+
agent = chat_client.create_agent(
186+
name="MicrosoftLearnAgent",
187+
instructions="You answer questions by searching Microsoft Learn content only.",
188+
tools=HostedMCPTool(
189+
name="Microsoft Learn MCP",
190+
url="https://learn.microsoft.com/api/mcp",
191+
),
192+
)
193+
194+
# Simple query without approval workflow
195+
result = await agent.run(
196+
"Please summarize the Azure AI Agent documentation related to MCP tool calling?"
197+
)
198+
print(result)
199+
200+
if __name__ == "__main__":
201+
asyncio.run(basic_foundry_mcp_example())
202+
```
203+
204+
### Multi-Tool MCP Configuration
205+
206+
Use multiple hosted MCP tools with a single agent:
207+
208+
```python
209+
async def multi_tool_mcp_example():
210+
"""Example using multiple hosted MCP tools."""
211+
async with (
212+
AzureCliCredential() as credential,
213+
AzureAIAgentClient(async_credential=credential) as chat_client,
214+
):
215+
await chat_client.setup_azure_ai_observability()
216+
217+
# Create agent with multiple MCP tools
218+
agent = chat_client.create_agent(
219+
name="MultiToolAgent",
220+
instructions="You can search documentation and access GitHub repositories.",
221+
tools=[
222+
HostedMCPTool(
223+
name="Microsoft Learn MCP",
224+
url="https://learn.microsoft.com/api/mcp",
225+
approval_mode="never_require", # Auto-approve documentation searches
226+
),
227+
HostedMCPTool(
228+
name="GitHub MCP",
229+
url="https://api.github.com/mcp",
230+
approval_mode="always_require", # Require approval for GitHub operations
231+
headers={"Authorization": "Bearer github-token"},
232+
),
233+
],
234+
)
235+
236+
result = await agent.run(
237+
"Find Azure documentation and also check the latest commits in microsoft/semantic-kernel"
238+
)
239+
print(result)
240+
241+
if __name__ == "__main__":
242+
asyncio.run(multi_tool_mcp_example())
243+
```
244+
245+
The Python Agent Framework provides seamless integration with Azure AI Foundry's hosted MCP capabilities, enabling secure and scalable access to external tools while maintaining the flexibility and control needed for production applications.
246+
247+
::: zone-end
152248

153249
## Next steps
154250

agent-framework/user-guide/workflows/TOC.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,4 @@
1212
href: request-and-response.md
1313
- name: Shared States
1414
href: shared-states.md
15-
- name: Checkpoints
16-
href: checkpoints.md
17-
- name: Observability
18-
href: observability.md
19-
- name: Visualization
20-
href: visualization.md
15+

agent-framework/user-guide/workflows/orchestrations/TOC.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
href: concurrent.md
55
- name: Sequential
66
href: sequential.md
7-
- name: Handoff
8-
href: handoff.md
97
- name: Magentic
108
href: magentic.md

agent-framework/user-guide/workflows/orchestrations/overview.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Traditional single-agent systems are limited in their ability to handle complex,
2222
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
2323
| [Concurrent](./concurrent.md) | Broadcasts a task to all agents, collects results independently. | Parallel analysis, independent subtasks, ensemble decision making. |
2424
| [Sequential](./sequential.md) | Passes the result from one agent to the next in a defined order. | Step-by-step workflows, pipelines, multi-stage processing. |
25-
| [Handoff](./handoff.md) | Dynamically passes control between agents based on context or rules. | Dynamic workflows, escalation, fallback, or expert handoff scenarios. |
2625
| [Magentic](./magentic.md) | Inspired by [MagenticOne](https://www.microsoft.com/en-us/research/articles/magentic-one-a-generalist-multi-agent-system-for-solving-complex-tasks/). | Complex, generalist multi-agent collaboration. |
2726

2827
## Next Steps

0 commit comments

Comments
 (0)