{"id":1032,"date":"2025-06-27T15:30:03","date_gmt":"2025-06-27T22:30:03","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/foundry\/?p=1032"},"modified":"2025-07-21T20:01:11","modified_gmt":"2025-07-22T03:01:11","slug":"announcing-model-context-protocol-support-preview-in-azure-ai-foundry-agent-service","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/foundry\/announcing-model-context-protocol-support-preview-in-azure-ai-foundry-agent-service\/","title":{"rendered":"Announcing Model Context Protocol Support (preview) in Azure AI Foundry Agent Service"},"content":{"rendered":"<p><span data-contrast=\"auto\">Generative-AI agents only become useful when they can\u00a0<\/span><i><span data-contrast=\"auto\">do<\/span><\/i><span data-contrast=\"auto\">\u00a0things\u2014query systems of record, trigger workflows, or look up\u00a0specialized\u00a0knowledge. Until now that meant hand-rolling Azure Functions, managing OpenAPI specs, or writing custom plug-ins for every backend you\u00a0own.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><b><span data-contrast=\"auto\">MCP changes the economics<\/span><\/b><span data-contrast=\"auto\">: it is an open, JSON-RPC\u2013based protocol\u2014originally proposed by Anthropic\u2014that lets a \u201cserver\u201d publish\u00a0<\/span><i><span data-contrast=\"auto\">tools<\/span><\/i><span data-contrast=\"auto\">\u00a0(functions) and\u00a0<\/span><i><span data-contrast=\"auto\">resources<\/span><\/i><span data-contrast=\"auto\">\u00a0(context)\u00a0once and\u00a0have any compliant \u201cclient\u201d (your agent runtime) discover and call them automatically. Think \u201cUSB-C for AI integrations.\u201d<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">With today\u2019s preview, Foundry Agent Service become first-class MCP clients. Bring any remote MCP server\u2014self-hosted or SaaS\u2014and Azure AI Foundry will import its capabilities in seconds, keep them updated, and route calls through the service\u2019s enterprise envelope.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><a href=\"https:\/\/modelcontextprotocol.io\/introduction\"><span data-contrast=\"none\">Model Context Protocol (MCP)<\/span><\/a><span data-contrast=\"auto\">\u202fallows developers, organizations, and service providers to host services and APIs on MCP servers and easily expose and connect tools to MCP-compatible clients, such as the Foundry Agent\u00a0Service. MCP is an open standard that defines how services provide various functions and context to AI models and agents. With Foundry Agent\u00a0Service&#8217;s support\u00a0of\u00a0MCP, users can bring an existing MCP server endpoint and add it as a tool to Foundry\u00a0agents. When connecting to an MCP server, actions and knowledge are automatically added to the agent and updated as functionality evolves. This streamlines the process of building agents and reduces the time\u00a0required\u00a0for\u00a0maintaining\u00a0them.<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<p><span data-contrast=\"auto\">With MCP support in Foundry Agent\u00a0Service,\u00a0it empowers you to:<\/span><span data-ccp-props=\"{}\">\u00a0<\/span><\/p>\n<ul>\n<li data-leveltext=\"-\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335551671&quot;:0,&quot;335552541&quot;:1,&quot;335559682&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Aptos&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;-&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><b><span data-contrast=\"auto\">Easily integrate with services and APIs.<\/span><\/b><span data-contrast=\"auto\"> Whether you want to connect with your internal services or APIs from external providers, MCP\u00a0provides\u00a0an\u00a0easy\u00a0way\u00a0to integrate with Foundry Agent\u00a0Service without writing and managing custom functions.<\/span><\/li>\n<li data-leveltext=\"-\" data-font=\"Aptos\" data-listid=\"1\" data-list-defn-props=\"{&quot;335551671&quot;:0,&quot;335552541&quot;:1,&quot;335559682&quot;:1,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Aptos&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;-&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" aria-setsize=\"-1\" data-aria-posinset=\"0\" data-aria-level=\"1\"><b><span data-contrast=\"auto\">Enhance your AI agent with enterprise features in Foundry Agent Service.<\/span><\/b><span data-contrast=\"auto\"> With Foundry Agent Service, you can enable enterprise-ready features such as Bring Your Own thread storage.<\/span><\/li>\n<\/ul>\n<div style=\"display: flex; justify-content: center; margin: 2rem 0; width: 100%;\"><video style=\"width: 100%; max-width: 720px; height: auto; border-radius: 8px; display: block;\" autoplay=\"autoplay\" loop=\"loop\" muted=\"\" width=\"300\" height=\"150\" aria-label=\"Demonstration of Model Context Protocol support in Azure AI Foundry Agent Service, highlighting user interface workflows.\"><source src=\"https:\/\/devblogs.microsoft.com\/foundry\/wp-content\/uploads\/sites\/89\/2025\/06\/ezgif-3d1524784ef3d5.mp4\" type=\"video\/mp4\" \/>Your browser does not support the video tag.<\/video><\/div>\n<h3>Code Samples<\/h3>\n<p><strong>Step 1: <\/strong>Import the needed packages.\nPlease make sure you use the latest packages for\n<a href=\"https:\/\/pypi.org\/project\/azure-ai-projects\/1.0.0b12\/\" target=\"_blank\" rel=\"noopener\">azure-ai-projects<\/a> and\n<a href=\"https:\/\/pypi.org\/project\/azure-ai-agents\/1.1.0b2\/\" target=\"_blank\" rel=\"noopener\">azure-ai-agents<\/a> and the supported region.<\/p>\n<pre><code>import time\r\nimport json\r\n\r\nfrom azure.ai.agents.models import MessageTextContent, ListSortOrder, McpTool\r\nfrom azure.ai.projects import AIProjectClient\r\nfrom azure.identity import DefaultAzureCredential\r\n<\/code><\/pre>\n<p><strong>Step 2: Create AI Project Client and an Azure AI Foundry Agent<\/strong>\nUse <code>server_label<\/code> to provide a unique name for the MCP server within the same Foundry Agent.\n<code>server_url<\/code> is the URL of the MCP server.\n<code>allowed_tools<\/code> is optional to specify which tools are enabled for the agent.<\/p>\n<pre><code class=\"language-python\">mcp_tool = McpTool(\r\n    server_label=mcp_server_label,\r\n    server_url=mcp_server_url,\r\n    allowed_tools=[],  # Optional\r\n)\r\n\r\nproject_client = AIProjectClient(\r\n    endpoint=PROJECT_ENDPOINT,\r\n    credential=DefaultAzureCredential()\r\n)\r\n\r\nwith project_client:\r\n    agent = project_client.agents.create_agent(\r\n        model=MODEL_DEPLOYMENT_NAME,\r\n        name=\"my-mcp-agent\",\r\n        instructions=(\r\n            \"You are a helpful assistant. Use the tools provided to answer the user's \"\r\n            \"questions. Be sure to cite your sources.\"\r\n        ),\r\n        tools=mcp_tool.definitions\r\n    )\r\n    print(f\"Created agent, agent ID: {agent.id}\")\r\n<\/code><\/pre>\n<p><strong>Step 3: Create a Thread, Message and Run<\/strong>\nWithin the Run, you can pass custom headers and use the <code>server_label<\/code> you provided to map to the specific MCP server.<\/p>\n<pre><code class=\"language-python\">thread = project_client.agents.threads.create()\r\nprint(f\"Created thread, thread ID: {thread.id}\")\r\n\r\nmessage = project_client.agents.messages.create(\r\n    thread_id=thread.id,\r\n    role=\"user\",\r\n    content=\"&lt;a question for your MCP server&gt;\"\r\n)\r\nprint(f\"Created message, message ID: {message.id}\")\r\n<\/code><\/pre>\n<p>Please note headers are only valid for the run. You can provide headers in this way:<\/p>\n<pre><code class=\"language-python\">mcp_tool.update_headers(\"SuperSecret\", \"123456\")<\/code><\/pre>\n<pre><code class=\"language-python\">run = project_client.agents.runs.create(\r\n    thread_id=thread.id,\r\n    agent_id=agent.id\r\n)\r\n<\/code><\/pre>\n<p><strong>Step 4: Execute the Run and retrieve Message<\/strong>\nYou can use <code>run_step<\/code> to get more details on tool inputs and outputs. By default, every tool calling to a MCP server needs approval.<\/p>\n<pre><code class=\"language-python\">while run.status in [\"queued\", \"in_progress\", \"requires_action\"]:\r\n    time.sleep(1)\r\n    run = agents_client.runs.get(thread_id=thread.id, run_id=run.id)\r\n\r\n    if run.status == \"requires_action\" and isinstance(run.required_action, SubmitToolApprovalAction):\r\n        tool_calls = run.required_action.submit_tool_approval.tool_calls\r\n        if not tool_calls:\r\n            print(\"No tool calls provided - cancelling run\")\r\n            agents_client.runs.cancel(thread_id=thread.id, run_id=run.id)\r\n            break\r\n\r\n        tool_approvals = []\r\n        for tool_call in tool_calls:\r\n            if isinstance(tool_call, RequiredMcpToolCall):\r\n                try:\r\n                    print(f\"Approving tool call: {tool_call}\")\r\n                    tool_approvals.append(\r\n                        ToolApproval(\r\n                            tool_call_id=tool_call.id,\r\n                            approve=True,\r\n                            headers=mcp_tool.headers,\r\n                        )\r\n                    )\r\n                except Exception as e:\r\n                    print(f\"Error approving tool_call {tool_call.id}: {e}\")\r\n\r\n        print(f\"tool_approvals: {tool_approvals}\")\r\n        if tool_approvals:\r\n            agents_client.runs.submit_tool_outputs(\r\n                thread_id=thread.id,\r\n                run_id=run.id,\r\n                tool_approvals=tool_approvals\r\n            )\r\n\r\n    print(f\"Current run status: {run.status}\")\r\n\r\n# Retrieve the generated response:\r\nmessages = agents_client.messages.list(thread_id=thread.id)\r\nprint(\"\\nConversation:\")\r\nprint(\"-\" * 50)\r\n\r\nfor msg in messages:\r\n    if msg.text_messages:\r\n        last_text = msg.text_messages[-1]\r\n        print(f\"{msg.role.upper()}: {last_text.text.value}\")\r\n        print(\"-\" * 50)\r\n<\/code><\/pre>\n<p><strong>Step 5: Clean up<\/strong><\/p>\n<pre><code class=\"language-python\">project_client.agents.delete_agent(agent.id)\r\nprint(f\"Deleted agent, agent ID: {agent.id}\")\r\n<\/code><\/pre>\n<p>At <strong>Microsoft Build 2025<\/strong>, Satya Nadella shared our vision for an\n<em>open-by-design<\/em> AI ecosystem and announced a partnership with\n<strong>Anthropic<\/strong> to make the <strong>Model Context Protocol (MCP)<\/strong>\na first-class standard across Windows 11, GitHub, Copilot Studio, and\n<strong>Azure AI Foundry<\/strong>.<\/p>\n<p>Today\u2019s <strong>preview support for MCP in Azure AI Foundry Agent Service<\/strong>\nis the next step in that journey. It brings the same\n<em>\u201cconnect once, integrate anywhere\u201d<\/em> promise to cloud-hosted agents\u2014letting you\nplug any MCP server directly into Foundry with <strong>zero custom code<\/strong>.<\/p>\n<h3>Create with Azure AI Foundry<\/h3>\n<ul>\n<li>Get started with\n<a href=\"https:\/\/ai.azure.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">\nAzure AI Foundry\n<\/a> and jump directly into\n<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TeamsDevApp.vscode-ai-foundry\" target=\"_blank\" rel=\"noopener noreferrer\">\nVisual Studio Code\n<\/a>.<\/li>\n<li>Download the\n<a href=\"https:\/\/aka.ms\/aifoundrysdk\" target=\"_blank\" rel=\"noopener noreferrer\">\nAzure AI Foundry SDK\n<\/a>.<\/li>\n<li>Read the\n<a href=\"https:\/\/aka.ms\/FoundryAgentMCPDoc\" target=\"_blank\" rel=\"noopener noreferrer\">\ndocumentation\n<\/a> to learn more about the feature.<\/li>\n<li>Take the\n<a href=\"https:\/\/aka.ms\/CreateAgenticAISolutions\" target=\"_blank\" rel=\"noopener noreferrer\">\nAzure AI Foundry Learn courses\n<\/a>.<\/li>\n<li>Keep the conversation going in\n<a href=\"https:\/\/aka.ms\/azureaifoundry\/forum\" target=\"_blank\" rel=\"noopener noreferrer\">\nGitHub\n<\/a> and\n<a href=\"https:\/\/aka.ms\/azureaifoundry\/discord\" target=\"_blank\" rel=\"noopener noreferrer\">\nDiscord\n<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Generative-AI agents only become useful when they can\u00a0do\u00a0things\u2014query systems of record, trigger workflows, or look up\u00a0specialized\u00a0knowledge. Until now that meant hand-rolling Azure Functions, managing OpenAPI specs, or writing custom plug-ins for every backend you\u00a0own.\u00a0 MCP changes the economics: it is an open, JSON-RPC\u2013based protocol\u2014originally proposed by Anthropic\u2014that lets a \u201cserver\u201d publish\u00a0tools\u00a0(functions) and\u00a0resources\u00a0(context)\u00a0once and\u00a0have any compliant [&hellip;]<\/p>\n","protected":false},"author":166509,"featured_media":1044,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[49,51,1],"tags":[],"class_list":["post-1032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aiagent","category-mcp","category-microsoft-foundry"],"acf":[],"blog_post_summary":"<p>Generative-AI agents only become useful when they can\u00a0do\u00a0things\u2014query systems of record, trigger workflows, or look up\u00a0specialized\u00a0knowledge. Until now that meant hand-rolling Azure Functions, managing OpenAPI specs, or writing custom plug-ins for every backend you\u00a0own.\u00a0 MCP changes the economics: it is an open, JSON-RPC\u2013based protocol\u2014originally proposed by Anthropic\u2014that lets a \u201cserver\u201d publish\u00a0tools\u00a0(functions) and\u00a0resources\u00a0(context)\u00a0once and\u00a0have any compliant [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts\/1032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/users\/166509"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/comments?post=1032"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/posts\/1032\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/media\/1044"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/media?parent=1032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/categories?post=1032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/foundry\/wp-json\/wp\/v2\/tags?post=1032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}