Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Deploy, evaluate, and manage AI agents end-to-end on Microsoft Azure AI Foundry
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
foundry-agent/create/references/tool-mcp.md
1# MCP Tool (Model Context Protocol)23Connect agents to remote MCP servers to extend capabilities with external tools and data sources. MCP is an open standard for LLM tool integration.45## Prerequisites67- A remote MCP server endpoint (e.g., `https://api.githubcopilot.com/mcp`)8- For authenticated servers: a [project connection](../../../project/connections.md) storing credentials9- RBAC: **Contributor** or **Owner** role on the Foundry project1011## Authenticated Server Connections1213For authenticated MCP servers, create an `api_key` project connection to store credentials. Unauthenticated servers (public endpoints) don't need a connection — omit `project_connection_id`.1415See [Project Connections](../../../project/connections.md) for connection management via Foundry MCP tools.1617## MCPTool Parameters1819| Parameter | Required | Description |20|-----------|----------|-------------|21| `server_label` | Yes | Unique label for this MCP server within the agent |22| `server_url` | Yes | Remote MCP server endpoint URL |23| `require_approval` | No | `"always"` (default), `"never"`, or `{"never": ["tool1"]}` / `{"always": ["tool1"]}` |24| `allowed_tools` | No | List of specific tools to enable (default: all) |25| `project_connection_id` | No | Connection ID for authenticated servers |2627## Approval Workflow28291. Agent sends request → MCP server returns tool calls302. Response contains `mcp_approval_request` items313. Your code reviews tool name + arguments324. Submit `McpApprovalResponse` with `approve=True/False`335. Agent completes work using approved tool results3435> **Best practice:** Always use `require_approval="always"` unless you fully trust the MCP server. Use `allowed_tools` to restrict which tools the agent can access.3637## Hosting Local MCP Servers3839Agent Service only accepts **remote** MCP endpoints. To use a local server, deploy it to:4041| Platform | Transport | Notes |42|----------|-----------|-------|43| [Azure Container Apps](https://github.com/Azure-Samples/mcp-container-ts) | HTTP POST/GET | Any language, container rebuild needed |44| [Azure Functions](https://github.com/Azure-Samples/mcp-sdk-functions-hosting-python) | HTTP streamable | Python/Node/.NET/Java, key-based auth |4546## Known Limitations4748- **100-second timeout** for non-streaming MCP tool calls49- **Identity passthrough not supported in Teams** — agents published to Teams use project managed identity50- **Network-secured Foundry** can't use private MCP servers in same vNET — only public endpoints5152## Troubleshooting5354| Error | Cause | Fix |55|-------|-------|-----|56| `Invalid tool schema` | `anyOf`/`allOf` in MCP server definition | Update MCP server schema to use simple types |57| `Unauthorized` / `Forbidden` | Wrong credentials in connection | Verify connection credentials match server requirements |58| Model never calls MCP tool | Misconfigured server_label/url | Check `server_label`, `server_url`, `allowed_tools` values |59| Agent stalls after approval | Missing `previous_response_id` | Include `previous_response_id` in follow-up request |60| Timeout | Server takes >100s | Optimize server-side logic or break into smaller operations |6162## References6364- [MCP tool documentation](https://learn.microsoft.com/azure/ai-foundry/agents/how-to/tools/mcp?view=foundry)65- [Tool Catalog](https://learn.microsoft.com/azure/ai-foundry/agents/concepts/tool-catalog?view=foundry)66- [Project Connections](../../../project/connections.md)67