<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vinayak Kone</title>
    <description>The latest articles on DEV Community by Vinayak Kone (@vinayak_kone_78e4f472a489).</description>
    <link>https://dev.to/vinayak_kone_78e4f472a489</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4146267%2F1ac66798-b1cc-499a-a5df-1e9cfeade59c.jpg</url>
      <title>DEV Community: Vinayak Kone</title>
      <link>https://dev.to/vinayak_kone_78e4f472a489</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vinayak_kone_78e4f472a489"/>
    <language>en</language>
    <item>
      <title>Exposing API Endpoints as MCP Tools: Azure APIM Approach</title>
      <dc:creator>Vinayak Kone</dc:creator>
      <pubDate>Fri, 27 Nov 2026 05:43:12 +0000</pubDate>
      <link>https://dev.to/vinayak_kone_78e4f472a489/exposing-api-endpoints-as-mcp-tools-azure-apim-approach-3fi2</link>
      <guid>https://dev.to/vinayak_kone_78e4f472a489/exposing-api-endpoints-as-mcp-tools-azure-apim-approach-3fi2</guid>
      <description>&lt;p&gt;You already have REST APIs that do useful things. Now your AI agents need to call them as &lt;strong&gt;MCP (Model Context Protocol) tools&lt;/strong&gt;. You could write and host a new MCP server for each API, or you could let &lt;strong&gt;Azure API Management (APIM)&lt;/strong&gt; do it for you, with the security, throttling and observability you already get from a gateway.&lt;/p&gt;

&lt;p&gt;This post walks through the APIM approach end to end: exposing operations as MCP tools, locking the MCP endpoint down with &lt;strong&gt;Microsoft Entra ID&lt;/strong&gt;, and letting callers authenticate with either an &lt;strong&gt;agent-level identity&lt;/strong&gt; or the &lt;strong&gt;project-level identity&lt;/strong&gt; of your Microsoft Foundry project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why APIM for MCP?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No new server to build or host.&lt;/strong&gt; APIM turns operations of an existing API into MCP tools.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;One front door.&lt;/strong&gt; Auth, rate limits, logging and IP rules apply to MCP traffic the same way they do for every other API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Selective exposure.&lt;/strong&gt; You choose which operations become tools, so an agent never sees your whole API surface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Entra-native security.&lt;/strong&gt; Callers present an Entra token, and APIM validates it before anything reaches your backend.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Roles you need
&lt;/h2&gt;

&lt;p&gt;You do not need separate teams for this setup. You need the following roles, held by one person or several.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task&lt;/th&gt;
&lt;th&gt;Role required&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Create the app registration, app role and Application ID URI (Step 2)&lt;/td&gt;
&lt;td&gt;Entra role: &lt;strong&gt;Application Administrator&lt;/strong&gt;, &lt;strong&gt;Cloud Application Administrator&lt;/strong&gt;, or &lt;strong&gt;Application Developer&lt;/strong&gt; (the creator becomes the app owner)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Assign the app role to the agent or project identity (Step 5)&lt;/td&gt;
&lt;td&gt;Entra role: &lt;strong&gt;Application Administrator&lt;/strong&gt; or &lt;strong&gt;Cloud Application Administrator&lt;/strong&gt;. For automation, the Microsoft Graph permission &lt;code&gt;AppRoleAssignment.ReadWrite.All&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create the MCP server and add the policy in APIM (Steps 1 and 3)&lt;/td&gt;
&lt;td&gt;Azure RBAC: &lt;strong&gt;API Management Service Contributor&lt;/strong&gt; on the APIM instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Add the MCP tool and pick the identity in Foundry (Step 6)&lt;/td&gt;
&lt;td&gt;Azure RBAC: &lt;strong&gt;Contributor&lt;/strong&gt; (or the Foundry project management role your organization uses) on the Foundry project&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Role names change over time, so confirm them against the current documentation for your tenant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture at a glance
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent  --&amp;gt;  MCP Tools  --&amp;gt;  MCP Server  --&amp;gt;  APIM  --&amp;gt;  External API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The agent picks an MCP tool and calls it.&lt;/li&gt;
&lt;li&gt;The agent gets an Entra token for the APIM app (the audience), using its agent identity or the project identity.&lt;/li&gt;
&lt;li&gt;The call reaches the MCP server exposed by APIM, with the token as a Bearer header.&lt;/li&gt;
&lt;li&gt;APIM validates the token and the &lt;code&gt;MCP.Access&lt;/code&gt; role, then calls the external API.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr8net83nmm328ch6m2y5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr8net83nmm328ch6m2y5.png" alt="Request flow from an agent through MCP tools and an MCP server to Azure API Management, which calls the external API" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Expose your API operations as an MCP server
&lt;/h2&gt;

&lt;p&gt;In the Azure portal, open your APIM instance and go to &lt;strong&gt;APIs &amp;gt; MCP Servers&lt;/strong&gt; (the exact blade name may shift while the feature evolves). Create an MCP server from an existing API, then pick only the operations you want as tools. Each selected operation becomes one tool, with its name, description and parameters derived from your OpenAPI definition.&lt;/p&gt;

&lt;p&gt;Tip: good tool descriptions matter more than you think. The model chooses tools based on them, so tidy up operation summaries and parameter descriptions in your OpenAPI spec before you expose them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create the Entra app registration (the resource app)
&lt;/h2&gt;

&lt;p&gt;This app registration represents the &lt;strong&gt;APIM MCP server as a protected resource&lt;/strong&gt;. Callers request tokens &lt;em&gt;for&lt;/em&gt; this app. The roles you need for each step are listed in "Roles you need" above.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 Register the app
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Microsoft Entra ID &amp;gt; App registrations &amp;gt; + New registration&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Name: &lt;code&gt;apim-mcp-server&lt;/code&gt; (or your preferred name). Supported account types: &lt;strong&gt;Single tenant&lt;/strong&gt;. Leave Redirect URI blank. Click &lt;strong&gt;Register&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2.2 Set the token version to v2
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the app &amp;gt; &lt;strong&gt;Manifest&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Set &lt;code&gt;requestedAccessTokenVersion&lt;/code&gt; to &lt;code&gt;2&lt;/code&gt; (under &lt;code&gt;api&lt;/code&gt;). In the older manifest format the property is &lt;code&gt;accessTokenAcceptedVersion&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2.3 Set the Application ID URI
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;strong&gt;Expose an API &amp;gt; Add&lt;/strong&gt; next to Application ID URI.&lt;/li&gt;
&lt;li&gt;Accept the default &lt;code&gt;api://&amp;lt;client-id&amp;gt;&lt;/code&gt; and &lt;strong&gt;Save&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  2.4 Create the app role
&lt;/h3&gt;

&lt;p&gt;Go to &lt;strong&gt;App roles &amp;gt; Create app role&lt;/strong&gt; and fill in:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Field&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Display name&lt;/td&gt;
&lt;td&gt;&lt;code&gt;MCP.Access&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Allowed member types&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Applications&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Value&lt;/td&gt;
&lt;td&gt;&lt;code&gt;MCP.Access&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Description&lt;/td&gt;
&lt;td&gt;Allows authorized Microsoft Foundry identities to invoke MCP server endpoints in APIM.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enable this app role&lt;/td&gt;
&lt;td&gt;Checked&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Choosing &lt;strong&gt;Applications&lt;/strong&gt; as the member type matters. It makes this an &lt;em&gt;application permission&lt;/em&gt;, meaning only non-human identities (agents, managed identities) can be granted it. No user can sign in and get it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.5 Collect four values for the APIM configuration
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Where to find it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tenant ID&lt;/td&gt;
&lt;td&gt;App &lt;strong&gt;Overview&lt;/strong&gt; page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Client ID&lt;/td&gt;
&lt;td&gt;App &lt;strong&gt;Overview&lt;/strong&gt; page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Application ID URI&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Expose an API&lt;/strong&gt; page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;App Role ID&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Manifest &amp;gt; appRoles &amp;gt;&lt;/strong&gt; the &lt;code&gt;id&lt;/code&gt; of &lt;code&gt;MCP.Access&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 3: Validate the token in APIM
&lt;/h2&gt;

&lt;p&gt;Add a &lt;code&gt;validate-jwt&lt;/code&gt; policy on the MCP server so that only tokens carrying the &lt;code&gt;MCP.Access&lt;/code&gt; role get through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;inbound&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;base&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;validate-jwt&lt;/span&gt; &lt;span class="na"&gt;header-name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Authorization"&lt;/span&gt;
                  &lt;span class="na"&gt;failed-validation-httpcode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"401"&lt;/span&gt;
                  &lt;span class="na"&gt;failed-validation-error-message&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Unauthorized"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;openid-config&lt;/span&gt; &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://login.microsoftonline.com/{tenant-id}/v2.0/.well-known/openid-configuration"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;audiences&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;audience&amp;gt;&lt;/span&gt;{client-id}&lt;span class="nt"&gt;&amp;lt;/audience&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/audiences&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;issuers&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;issuer&amp;gt;&lt;/span&gt;https://login.microsoftonline.com/{tenant-id}/v2.0&lt;span class="nt"&gt;&amp;lt;/issuer&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/issuers&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;required-claims&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;claim&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"roles"&lt;/span&gt; &lt;span class="na"&gt;match&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"any"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;MCP.Access&lt;span class="nt"&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/claim&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/required-claims&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/validate-jwt&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/inbound&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details that trip people up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Audience.&lt;/strong&gt; Because we set the token version to 2, the &lt;code&gt;aud&lt;/code&gt; claim in the token is the app's &lt;strong&gt;client ID&lt;/strong&gt;, not the &lt;code&gt;api://...&lt;/code&gt; URI. The caller &lt;em&gt;requests&lt;/em&gt; the token using the Application ID URI as the scope or resource, but APIM &lt;em&gt;validates&lt;/em&gt; against the client ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Issuer.&lt;/strong&gt; v2 tokens use the &lt;code&gt;.../{tenant-id}/v2.0&lt;/code&gt; issuer. If you left the token version at 1, the issuer and audience would not match this policy, which is why Step 2.2 is not optional.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 4: Decide which identity calls the MCP server
&lt;/h2&gt;

&lt;p&gt;This is where the design choice sits. A Foundry agent can authenticate to your APIM MCP endpoint using Entra in two ways, and your app role works with both.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Agent identity&lt;/th&gt;
&lt;th&gt;Project-level identity&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;What it is&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A dedicated Entra identity for an individual agent&lt;/td&gt;
&lt;td&gt;The managed identity of the Foundry project, shared by everything in that project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Granularity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Per agent&lt;/td&gt;
&lt;td&gt;Per project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Role assignment&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;One assignment per agent&lt;/td&gt;
&lt;td&gt;One assignment covers every agent in the project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Audit trail&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Token shows which agent called&lt;/td&gt;
&lt;td&gt;Token shows the project, not the individual agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Least privilege&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Strongest. Each agent only gets the tools you grant it&lt;/td&gt;
&lt;td&gt;Coarser. Every agent in the project inherits access&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Good fit&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Production agents with different access needs&lt;/td&gt;
&lt;td&gt;Dev/test projects, or projects where all agents legitimately need the same tools&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A practical rule of thumb:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with the &lt;strong&gt;project-level identity&lt;/strong&gt; when you are prototyping, or when a project is dedicated to a single use case. It is one role assignment and you are done.&lt;/li&gt;
&lt;li&gt;Move to &lt;strong&gt;agent identity&lt;/strong&gt; when agents in the same project should &lt;em&gt;not&lt;/em&gt; all have the same reach, or when you need per-agent attribution in your logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that Foundry's identity model has been evolving, including when an agent gets its own distinct identity versus using the project's. Check the current Foundry documentation for how your agents are being identified before you decide.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhob1hhbxcgxq6760lxbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhob1hhbxcgxq6760lxbg.png" alt="Two side-by-side diagrams comparing one shared project identity with a separate identity for each agent" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Assign the app role to the identity
&lt;/h2&gt;

&lt;p&gt;Once the agent or project exists in Foundry, grab the &lt;strong&gt;Object ID&lt;/strong&gt; of the identity (the agent identity's service principal, or the project's managed identity) and assign the &lt;code&gt;MCP.Access&lt;/code&gt; role to it.&lt;/p&gt;

&lt;p&gt;This is an &lt;strong&gt;app role assignment on the resource's enterprise application (service principal)&lt;/strong&gt;, not a setting in the app registration blade. The Entra portal does not offer it for agent identities, and may not for the project identity either, so use Microsoft Graph through Graph Explorer, PowerShell or the Azure CLI. All three call the same API.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sign in to the right tenant first
&lt;/h3&gt;

&lt;p&gt;Yes, sign in to the tenant even though the identities you are assigning are applications. The assignment is a write to your directory, so it must be made by a signed-in principal (you, or a pipeline identity) in the same tenant as the &lt;code&gt;apim-mcp-server&lt;/code&gt; app. The app registration is single tenant, so a session in another tenant cannot see it. Each option below shows its own sign-in step.&lt;/p&gt;

&lt;h3&gt;
  
  
  The most common mistake
&lt;/h3&gt;

&lt;p&gt;Using the &lt;strong&gt;app registration's&lt;/strong&gt; object ID as &lt;code&gt;resourceId&lt;/code&gt;. It must be the object ID of the &lt;strong&gt;enterprise application&lt;/strong&gt; with the same name. You need three values for every option:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;resourceId&lt;/code&gt;: object ID of the &lt;code&gt;apim-mcp-server&lt;/code&gt; enterprise application&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;principalId&lt;/code&gt;: object ID of the agent identity or the Foundry project's managed identity&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;appRoleId&lt;/code&gt;: the App Role ID collected in Step 2.5&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the assignment once for the project identity, once per agent identity, or both.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option A: Graph Explorer
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;a href="https://developer.microsoft.com/graph/graph-explorer" rel="noopener noreferrer"&gt;Graph Explorer&lt;/a&gt; and sign in with an account in the tenant from Step 2.5 (use the tenant switcher if you belong to several).&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;Modify permissions&lt;/strong&gt;, consent to &lt;code&gt;AppRoleAssignment.ReadWrite.All&lt;/code&gt; and &lt;code&gt;Application.Read.All&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Set the method to &lt;code&gt;POST&lt;/code&gt; and the URL to &lt;code&gt;https://graph.microsoft.com/v1.0/servicePrincipals/{resource-sp-object-id}/appRoleAssignedTo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Paste this request body and run it:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"principalId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;agent-or-project-identity-object-id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"resourceId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;resource-sp-object-id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"appRoleId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;mcp-access-role-id&amp;gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A &lt;code&gt;201 Created&lt;/code&gt; response means the role is assigned. If the v1.0 endpoint does not resolve an agent identity as &lt;code&gt;principalId&lt;/code&gt;, try the same call on the &lt;code&gt;beta&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option B: PowerShell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Connect&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;MgGraph&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;TenantId&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;tenant-id&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Scopes&lt;/span&gt; &lt;span class="s2"&gt;"AppRoleAssignment.ReadWrite.All"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"Application.Read.All"&lt;/span&gt;

&lt;span class="nv"&gt;$resourceSpId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;resource-sp-object-id&amp;gt;"&lt;/span&gt;   &lt;span class="c1"&gt;# enterprise app of apim-mcp-server&lt;/span&gt;
&lt;span class="nv"&gt;$principalId&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;agent-or-project-identity-object-id&amp;gt;"&lt;/span&gt;
&lt;span class="nv"&gt;$appRoleId&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;mcp-access-role-id&amp;gt;"&lt;/span&gt;

&lt;span class="nc"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;MgServicePrincipalAppRoleAssignedTo&lt;/span&gt; &lt;span class="sb"&gt;`
  -ServicePrincipalId $resourceSpId `&lt;/span&gt;
  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;PrincipalId&lt;/span&gt; &lt;span class="nv"&gt;$principalId&lt;/span&gt; &lt;span class="sb"&gt;`
  -ResourceId $resourceSpId `&lt;/span&gt;
  &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;AppRoleId&lt;/span&gt; &lt;span class="nv"&gt;$appRoleId&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This needs the Microsoft Graph PowerShell module (&lt;code&gt;Install-Module Microsoft.Graph&lt;/code&gt;). &lt;code&gt;Connect-MgGraph -TenantId&lt;/code&gt; is the sign-in-to-the-right-tenant step for this option.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option C: Azure CLI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;az login --tenant &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;tenant-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; --allow-no-subscriptions

&lt;span class="nv"&gt;RESOURCE_SP_ID&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;apim-mcp-server-enterprise-app-object-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;PRINCIPAL_ID&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;agent-or-project-identity-object-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nv"&gt;APP_ROLE_ID&lt;/span&gt;&lt;span class="o"&gt;=&amp;lt;&lt;/span&gt;mcp-access-role-id&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

az rest --method POST \
  --uri &lt;span class="s2"&gt;"https://graph.microsoft.com/v1.0/servicePrincipals/$RESOURCE_SP_ID/appRoleAssignedTo"&lt;/span&gt; \
  --body &lt;span class="s2"&gt;"{\"principalId\":\"$PRINCIPAL_ID\",\"resourceId\":\"$RESOURCE_SP_ID\",\"appRoleId\":\"$APP_ROLE_ID\"}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;--allow-no-subscriptions&lt;/code&gt; if your account has directory access but no Azure subscription.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Connect the agent to the MCP server
&lt;/h2&gt;

&lt;p&gt;In Foundry, add the APIM MCP endpoint as a tool for your agent (via a project connection to the MCP server) and choose &lt;strong&gt;Microsoft Entra&lt;/strong&gt; as the authentication type. You then pick whether the token comes from the &lt;strong&gt;agent identity&lt;/strong&gt; or the &lt;strong&gt;project managed identity&lt;/strong&gt;, and supply the &lt;strong&gt;Application ID URI&lt;/strong&gt; as the audience.&lt;/p&gt;

&lt;p&gt;The flow at runtime:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent decides to call a tool.&lt;/li&gt;
&lt;li&gt;Foundry gets an Entra token for &lt;code&gt;api://&amp;lt;client-id&amp;gt;&lt;/code&gt; using the chosen identity.&lt;/li&gt;
&lt;li&gt;The token carries &lt;code&gt;roles: ["MCP.Access"]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;APIM validates it and forwards the call to your backend API.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Floemtfzb5gs7dc2c6uif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Floemtfzb5gs7dc2c6uif.png" alt="Sequence of an agent getting an Entra token, calling the APIM MCP server, and APIM validating the token before calling the backend" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;Likely cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;401&lt;/code&gt; from APIM&lt;/td&gt;
&lt;td&gt;Wrong audience (use client ID for v2 tokens), wrong issuer, or token version left at 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;401&lt;/code&gt; and the token has no &lt;code&gt;roles&lt;/code&gt; claim&lt;/td&gt;
&lt;td&gt;The role was never assigned to that identity, or it was assigned to the app registration object ID instead of the enterprise app&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Works for one agent but not another&lt;/td&gt;
&lt;td&gt;You assigned the role to an agent identity, not the project identity (or vice versa)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Role assignment fails&lt;/td&gt;
&lt;td&gt;The app role's allowed member type is not &lt;strong&gt;Applications&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The APIM approach gives you MCP tools without building MCP servers, and Entra gives you a clean authorization story: one resource app, one &lt;code&gt;MCP.Access&lt;/code&gt; role, and a choice between &lt;strong&gt;project-level&lt;/strong&gt; simplicity and &lt;strong&gt;agent-level&lt;/strong&gt; precision for who gets to hold it.&lt;/p&gt;

&lt;p&gt;The whole setup comes down to the roles in the table above. Whoever holds them can run every step, and the four values in Step 2.5 are all you need to carry between steps.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Have you exposed APIs as MCP tools through APIM? I would love to hear which identity model you picked and why.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/api-management/export-rest-mcp-server" rel="noopener noreferrer"&gt;Expose a REST API in API Management as an MCP server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/api-management/mcp-server-overview" rel="noopener noreferrer"&gt;MCP server overview in API Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/api-management/secure-mcp-servers" rel="noopener noreferrer"&gt;Secure access to MCP servers in API Management&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/api-management/validate-jwt-policy" rel="noopener noreferrer"&gt;validate-jwt policy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/foundry/agents/how-to/mcp-authentication" rel="noopener noreferrer"&gt;MCP authentication in Microsoft Foundry agents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/azure/foundry/agents/concepts/agent-identity" rel="noopener noreferrer"&gt;Agent identity in Microsoft Foundry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/entra/identity-platform/howto-add-app-roles-in-apps" rel="noopener noreferrer"&gt;Add app roles to an application&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/graph/api/serviceprincipal-post-approleassignedto" rel="noopener noreferrer"&gt;Grant an appRoleAssignment to a service principal (Microsoft Graph)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://modelcontextprotocol.io" rel="noopener noreferrer"&gt;Model Context Protocol&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>microsoftgraph</category>
      <category>mcp</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
