Share via

Trouble connecting Foundry agent to MCP server behind APIM

Elise Mjoen 0 Reputation points
2026-03-18T09:43:34.9533333+00:00

I'm having consistent problems connecting my Microsoft Foundry agent to an MCP server that was created from API Management (APIM) by exposing another REST-API in APIM in Azure. Every time the agent tries to fetch data from the MCP server, the request fails with the following error message:

“The server had an error processing your request. Sorry about that! You can retry your request, or contact us through an Azure support request at: https://go.microsoft.com/fwlink/?linkid=2213926 if you keep seeing this error. (Please include the request ID f9774a65-a4a6-4d7a-9039-246ac920abe2.)”

I do not have an Azure Support plan, so I’m unable to open a support ticket, but I hope someone here can help me. What could be possible causes to my problem? How can I solve it?

Setup details: The REST-API was exposed as a MCP server by clicking that button in the Azure portal. I have not added any policies to the MCP Server, but I have checked the subscription required-box. I added the MCP Server in Foundry by clicking Tools -> Connect a tool -> Custom -> Model Context Protocol (MCP). There, I pasted the server url, chose key-based authentication and provided the Ocp-Apim-Subscription-Key and the x-api-key for the original REST-API (unsure if this key is necessary or not).

Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

{count} votes

1 answer

Sort by: Most helpful
  1. Jorre De Backer 0 Reputation points
    2026-03-18T15:44:35.0566667+00:00

    A couple of things I would check first:

    • Remove the x-api-key, having both that and Ocp-Apim-Subscription-Key can cause issues since APIM only needs the subscription key.
    • Also, add a CORS policy to your APIM MCP server without it Foundry's requests can get blocked silently because they're coming from a different domain.
      • APIM → APIs → your MCP server → Policies and add a basic inbound CORS policy allowing all origins. You can tighten it down to specific origins once it's working.
      https://learn.microsoft.com/en-us/azure/api-management/cors-policy
      The block below can be added to alow Foundry's specific domain
      User's image

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.