* Python: .NET Samples - Restructure and Improve Samples (Feature Branch) (#4091) * Moved by agent (#4094) * Fix readme links * .NET Samples - Create `04-hosting` learning path step (#4098) * Agent move * Agent reorderd * Remove A2A section from README Removed A2A section from the Getting Started README. * Agent fixed links * Fix broken sample links in durable-agents README (#4101) * Initial plan * Fix broken internal links in documentation Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Revert template link changes; keep only durable-agents README fix Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * .NET Samples - Create `03-workflows` learning path step (#4102) * Fix solution project path * Python: Fix broken markdown links to repo resources (outside /docs) (#4105) * Initial plan * Fix broken markdown links to repo resources Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Update README to rename .NET Workflows Samples section --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * .NET Samples - Create `02-agents` learning path step (#4107) * .NET: Fix broken relative link in GroupChatToolApproval README (#4108) * Initial plan * Fix broken link in GroupChatToolApproval README Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Update labeler configuration for workflow samples * .NET - Reorder Agents samples to start from Step01 instead of Step04 (#4110) * Fix solution * Resolve new sample paths * Move new AgentSkills and AgentWithMemory_Step04 samples * Fix link * Fix readme path * fix: update stale dotnet/samples/Durable path reference in AGENTS.md Co-authored-by: crickman <66376200+crickman@users.noreply.github.com> * Moved new sample * Update solution * Resolve merge (new sample) * Sync to new sample - FoundryAgents_Step21_BingCustomSearch * Updated README * .NET Samples - Configuration Naming Update (#4149) * .NET: Restore AzureFunctions index parity with ConsoleApps under DurableAgents samples (#4221) * Clean-up `05_host_your_agent` * Config setting consistency * Refine samples * AGENTS.md * Move new samples * Re-order samples * Move new project and fixup solution * Fixup model config * Fix up new UT project --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Agent as MCP Tool Sample
This sample demonstrates how to configure AI agents to be accessible as both HTTP endpoints and Model Context Protocol (MCP) tools, enabling flexible integration patterns for AI agent consumption.
Key Concepts Demonstrated
- Multi-trigger Agent Configuration: Configure agents to support HTTP triggers, MCP tool triggers, or both
- Microsoft Agent Framework Integration: Use the framework to define AI agents with specific roles and capabilities
- Flexible Agent Registration: Register agents with customizable trigger configurations
- MCP Server Hosting: Expose agents as MCP tools for consumption by MCP-compatible clients
Sample Architecture
This sample creates three agents with different trigger configurations:
| Agent | Role | HTTP Trigger | MCP Tool Trigger | Description |
|---|---|---|---|---|
| Joker | Comedy specialist | ✅ Enabled | ❌ Disabled | Accessible only via HTTP requests |
| StockAdvisor | Financial data | ❌ Disabled | ✅ Enabled | Accessible only as MCP tool |
| PlantAdvisor | Indoor plant recommendations | ✅ Enabled | ✅ Enabled | Accessible via both HTTP and MCP |
Environment Setup
See the README.md file in the parent directory for complete setup instructions, including:
- Prerequisites installation
- Azure OpenAI configuration
- Durable Task Scheduler setup
- Storage emulator configuration
For this sample, you'll also need to install node.js in order to use the MCP Inspector tool.
Configuration
Update your local.settings.json with your Azure OpenAI credentials:
{
"Values": {
"AZURE_OPENAI_ENDPOINT": "https://your-resource.openai.azure.com/",
"AZURE_OPENAI_DEPLOYMENT_NAME": "your-deployment-name",
"AZURE_OPENAI_API_KEY": "your-api-key-if-not-using-rbac"
}
}
Running the Sample
-
Start the Function App:
cd dotnet/samples/04-hosting/DurableAgents/AzureFunctions/07_AgentAsMcpTool func start -
Note the MCP Server Endpoint: When the app starts, you'll see the MCP server endpoint in the terminal output. It will look like:
MCP server endpoint: http://localhost:7071/runtime/webhooks/mcp
Testing MCP Tool Integration
Any MCP-compatible client can connect to the server endpoint and utilize the exposed agent tools. The agents will appear as callable tools within the MCP protocol.
Using MCP Inspector
-
Run the MCP Inspector from the command line:
npx @modelcontextprotocol/inspector -
Connect using the MCP server endpoint from your terminal output
- For Transport Type, select "Streamable HTTP"
- For URL, enter the MCP server endpoint
http://localhost:7071/runtime/webhooks/mcp - Click the Connect button
-
Click the List Tools button to see the available MCP tools. You should see the
StockAdvisorandPlantAdvisortools. -
Test the available MCP tools:
- StockAdvisor - Set "MSFT ATH" (ATH is "all time high") as the query and click the Run Tool button.
- PlantAdvisor - Set "Low light in Seattle" as the query and click the Run Tool button.
You'll see the results of the tool calls in the MCP Inspector interface under the Tool Results section. You should also see the results in the terminal where you ran the func start command.