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.
- 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
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 |
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.
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"
}
}-
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
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.
-
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.