<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yogi Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Yogi Srivastava on Medium]]></description>
        <link>https://medium.com/@kunkunbebo?source=rss-61892af75509------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YOD8I2LSIbFPGNe_</url>
            <title>Stories by Yogi Srivastava on Medium</title>
            <link>https://medium.com/@kunkunbebo?source=rss-61892af75509------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 08:56:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kunkunbebo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[First-Party vs. Third-Party AI Agents: Connecting Is Not Trusting]]></title>
            <link>https://medium.com/@kunkunbebo/first-party-vs-third-party-ai-agents-connecting-is-not-trusting-83f2daafea99?source=rss-61892af75509------2</link>
            <guid isPermaLink="false">https://medium.com/p/83f2daafea99</guid>
            <category><![CDATA[third-party-ai-agents]]></category>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[auth0-action]]></category>
            <category><![CDATA[azure-api-management]]></category>
            <category><![CDATA[custom-mcp-server]]></category>
            <dc:creator><![CDATA[Yogi Srivastava]]></dc:creator>
            <pubDate>Tue, 24 Nov 2026 10:58:31 GMT</pubDate>
            <atom:updated>2026-11-24T10:58:31.604Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What adding an enterprise MCP connector really establishes, and what it does not?</em></p><p>20 Nov 2026 · By <a href="https://medium.com/u/61892af75509">Yogi Srivastava</a> <a href="https://medium.com/u/295391949412">Rob Mawston</a> <a href="https://medium.com/u/d2f402593fbb">Jordan Knight</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1tcpAFzqj6vaEPvM-8VDEQ.png" /></figure><p>The platform says C<em>onnected</em>. A green tick, a list of tools and your enterprise MCP server is now one prompt away from a third-party AI agent.</p><p>That looks like one action. It is actually a chain of security decisions: discover the resource, identify its authorization server, establish the client’s identity, authenticate the user, authorize a grant, and validate the first authenticated MCP request. Any of them can fail before the backend sees an authenticated request. All of them can succeed without proving that the next business operation is authorized.</p><p>Here is what happens behind that tick when a user adds an enterprise connector in Claude.ai, Claude Cowork, or ChatGPT, and what “<em>Connected</em>” does and does not prove.</p><p>The user first signs in to the hosted platform with their own account, then adds the enterprise connector using details shared through the organization’s onboarding process. The organization permits this agentic channel for the intended use; it does not necessarily own or administer that account. The platform session does not authorize access to the enterprise MCP server. The connector starts a separate authorization flow with the enterprise identity provider, even when single sign-on means the user never sees a second credential prompt.</p><p>The examples below use Auth0 and Azure API Management (APIM) to explain a generalized HTTP-based, user-delegated Model Context Protocol (MCP) integration. Claude.ai and ChatGPT are examples of hosted platforms. Registration support, terminology, and availability depend on the platform and configuration.</p><h3>First-party and third-party describe ownership</h3><p>A first-party agent is an application and runtime the enterprise controls. A third-party agent runs on a provider operated platform outside that operational control. These architectural labels are separate from an identity provider’s application classification settings.</p><p>With a first-party agent, the enterprise controls deployment, patching, isolation, and identity provisioning. That brings responsibility for workload approval, API grants, and runtime security within that organizations governance boundary.</p><p>With a third-party platform, the provider controls the hosted runtime and integrated MCP client. The enterprise must govern provider integration, client admission, API eligibility, and user delegation. Client onboarding may use pre-registration, Dynamic Client Registration (DCR), or Client ID Metadata Documents (CIMD), where supported.</p><p>Registering a Claude.ai or ChatGPT client in the enterprise’s identity system does not make the provider’s runtime first-party. Equally, a first-party agent can still be compromised or overprivileged.</p><p>The OAuth client is the application implementing the MCP client integrated into a third-party agentic application. Its client ID does not necessarily identify a unique agent instance, model, conversation, or user.</p><h3>Before the connection: governed distribution and informed use</h3><p>In this enterprise scenario, users do not discover a connector URL in a public post or public marketplace. The organization shares approved connector details with eligible users through controlled mechanisms, such as an authenticated internal service catalog or access-controlled onboarding guidance. This is the intended distribution model, not a claim that every enterprise connector is private by default.</p><p>The onboarding information should identify the service owner, exact approved endpoint or connector entry, permitted agentic channels and account types, permitted use cases, expected permissions, and support and incident-reporting route. Users should not copy configuration from unsolicited messages, publish internal setup details, or paste tokens and secrets into chat. Distribution of setup instructions is separate from secure credential provisioning.</p><p>Users sign in to Claude.ai, Claude Cowork, or ChatGPT with their own accounts, then add the internally shared enterprise connector through the platform’s integrated MCP client. The organization permits this agentic channel for defined uses, evaluates its data handling, terms, and risks, and governs client admission and delegated access at its authorization server and protected services. Permission to use a platform is not permission for every OAuth client, scope, user, or action.</p><p><a href="https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp">Anthropic’s custom connector guidance</a> and <a href="https://help.openai.com/en/articles/11487775-connectors-in-chatgpt">OpenAI’s connected-app guidance</a> describe connection, permission review, and disconnection. Available integration features depend on the service, plan, and configuration.</p><h3>Education and an ethics agreement are part of onboarding</h3><p>Before enabling use, the enterprise should explain what information may leave its boundary and what actions the connector can perform. A practical responsible AI and acceptable use briefing covers:</p><ul><li>Use only organizationally permitted agentic channels, account types, connectors, and data classifications; understand applicable processing, retention, and sharing terms for the account actually used.</li><li>Recognize lookalike endpoints, unexpected consent requests, prompt injection, and changes in tool behavior; stop and report suspicious activity.</li><li>Review requested permissions and consequential actions instead of routinely accepting broad or persistent approvals.</li><li>Check outputs for accuracy, unfair treatment, and inappropriate disclosure; respect privacy, confidentiality, intellectual property, and required human oversight.</li><li>Know how to disconnect, request access removal, and report mistakes or unintended actions.</li></ul><p>Where enterprise policy requires it, users acknowledge a versioned responsible AI, ethics, or acceptable use agreement before access is enabled. Record the acknowledgement and training completion in an appropriate governance system and revisit them when the connector’s capabilities or data use materially change. If these are mandatory prerequisites, connect them to eligibility or an approval workflow rather than assuming that receipt of a setup link proves completion.</p><p>This approach aligns with the voluntary <a href="https://airc.nist.gov/airmf-resources/airmf/5-sec-core/">NIST AI RMF GOVERN</a> guidance: GOVERN 1.4 addresses transparent policies and controls, GOVERN 2.2 addresses training consistent with policies and agreements, and GOVERN 6 addresses third-party risks. NIST does not prescribe a universal connector specific ethics agreement; the acknowledgement process is an enterprise policy choice.</p><p>Organizational approval, an acceptable use acknowledgement, OAuth consent and approval of a particular business action are different decisions. An ethics agreement establishes responsibilities, it does not grant API scopes. OAuth consent delegates access under authorization server policy, it is not blanket ethical approval or a substitute for any legally required privacy basis.</p><h3>Not publicly advertised does not mean inaccessible</h3><p>Here, the public MCP endpoint means the externally reachable gateway endpoint used by the hosted client, not a publicly promoted connector listing or unrestricted service. The setup details are distributed internally, but the endpoint and necessary OAuth discovery metadata may still be reachable without an enterprise session. A URL may also leak or be inferred.</p><p>Controlled distribution reduces accidental exposure and misleading setup instructions. It must not be the authorization boundary, so knowing the URL must never be enough to read protected data or invoke protected tools. Client admission, user eligibility, token validation, and per-request authorization remain necessary even for someone who obtained the approved instructions.</p><h3>What happens when a user adds the connector?</h3><p>The onboarding flow crosses several boundaries. Here is the sequence without the deployment-specific detail:</p><ol><li><strong>The user signs in to Claude.ai, Claude Cowork, or ChatGPT.</strong> With internally supplied setup information and required education and policy acknowledgements completed, the user signs in using their account for that service on an organizationally permitted agentic channel before adding the connector. This platform session does not itself grant enterprise MCP access.</li><li><strong>The user adds the enterprise connector.</strong> The user enters the internally supplied MCP URL in the platform’s integrated MCP client. The client probes the endpoint exposed through APIM.</li><li><strong>APIM challenges an unauthenticated request.</strong> A 401 response includes a WWW-Authenticate challenge pointing to protected resource metadata through resource_metadata.</li><li><strong>The client discovers the authorization server.</strong> Resource metadata identifies the public resource and its authorization server. The client then discovers authorization endpoints and supported capabilities.</li><li><strong>The client establishes its identity.</strong> It reuses a pre-registered client, submits metadata through DCR, or presents a CIMD URL that the authorization server resolves or has already associated with approved metadata.</li><li><strong>The user completes enterprise authorization.</strong> Auth0 authenticates the user if needed and applies the relevant client grants and consent policy. An existing enterprise session may avoid another sign-in prompt. The user can approve or decline where consent is required.</li><li><strong>The client redeems the authorization code.</strong> The code exchange uses PKCE and requests a token for the intended MCP resource.</li><li><strong>The client returns to APIM with the token.</strong> APIM validates it and applies the relevant access policies before forwarding to the backend MCP server over the protected route.</li><li><strong>The MCP setup interaction completes.</strong> The backend response returns through APIM, and the platform reports that the connection is available.</li></ol><p>The registration choices are alternatives, not requirements that every client support every mechanism. Existing registrations and grants may be reused. CIMD metadata may already have been imported by an administrator or cached by the authorization server.</p><p>The gateway-to-backend authentication boundary must also remain protected. Its implementation is a separate architectural decision.</p><h3>Learning 1: APIM participates without becoming the authorization server</h3><p>In this pattern, APIM exposes the protected resource, returns an authorization challenge, and serves static discovery JSON through operation policies. A separate runtime policy validates incoming tokens and applies the configured access checks. These are distinct policy paths, not one universal response handler.</p><p>Auth0 admits or identifies the OAuth client, authenticates the user, evaluates grants and consent, and issues tokens.</p><p>Participating in discovery is not the same as processing registration.</p><p>If the client calls Auth0’s registration, authorization, or token endpoint directly, that traffic does not pass through APIM merely because APIM fronts the MCP server. Likewise, Auth0 normally fetches a hosted client’s CIMD from the provider, not the enterprise gateway.</p><p>In this pattern, the authorization server metadata served by APIM advertises Auth0’s authorization and token URLs directly, keeps Auth0 as the issuer, advertises CIMD support, and omits registration_endpoint. Those discovery operations return JSON without proxying authorization, registration, or token requests. Omitting the registration endpoint from this response does not itself disable DCR at Auth0. A static capability flag must also agree with the authorization server’s actual settings.</p><p>An APIM metadata response cannot enforce registration policy on Auth0’s separate endpoint. Intentional proxying of authorization-server endpoints requires its own routing and security design; it is not part of these discovery policies.</p><h3>What a working setup should show, and the gaps it can hide</h3><p>When discovery is wired correctly, a few checks confirm the bootstrap path:</p><ul><li>Protected resource metadata returns 200, names the public MCP resource and the authorization server, and its resource identifier matches the audience the gateway validates.</li><li>Authorization-server metadata returns 200, advertises only capabilities the server actually has, and keeps an issuer string that matches the JWT validator exactly, trailing slash included.</li><li>Unauthenticated HEAD, GET, and POST probes on the base path and the MCP path return 401 with a WWW-Authenticate discovery pointer, not an operation-not-found error.</li></ul><p>Those checks prove bootstrap behavior. They do not prove the protected branch enforces anything. These common gaps can sit behind a connector that works perfectly:</p><ul><li><strong>Logging instead of enforcing client pinning.</strong> A policy that logs a client-ID (azp) mismatch and lets the request continue is telemetry, not admission control.</li><li><strong>Substring scope checks.</strong> A check for mcp:write that uses substring matching also accepts a token carrying mcp:write-draft. Match exact scope values.</li><li><strong>Logging a missing scope instead of rejecting it.</strong> That is a diagnostic, not authorization.</li><li><strong>Test-time shortcuts left in place.</strong> An IP allowlist commented out during setup, or a broad discovery exemption, can quietly become the production configuration.</li><li><strong>Mistaking the backend token for user delegation.</strong> A managed-identity token from the gateway to the backend authenticates the gateway, not the user. It is not on-behalf-of (OBO) token exchange.</li><li><strong>Treating discovery tests as security acceptance.</strong> Successful discovery and challenge responses say nothing about invalid tokens, insufficient scope, unapproved clients, or the backend hop until those cases have recorded results.</li></ul><p>Before calling a connector secure, confirm that each control rejects rather than logs, and that each one has a recorded negative test.</p><h3>Gateway checks and hardening recommendations</h3><p>The checks below combine the routing and discovery lessons above with broader acceptance criteria. They describe what to verify, not controls proven in any single deployment. Discovery before enterprise authentication does not imply public distribution of the organization’s connector setup instructions.</p><ul><li><strong>Define operations for actual probe methods and paths.</strong> Clients may use HEAD, GET, or POST. An unmatched operation can look like an unreachable server rather than an OAuth failure.</li><li><strong>Handle API base-path probes where needed.</strong> A compatibility route must preserve the same challenge and access policy; it must not become an unauthenticated forwarding path.</li><li><strong>Return an actionable 401 challenge.</strong> Preserve the discovery pointer instead of replacing it with a generic success page or unusable error.</li><li><strong>Allow required metadata discovery before login.</strong> Exempt only the intended discovery operations, not the whole API.</li><li><strong>Keep issuer metadata consistent.</strong> An unexpected trailing slash can break issuer comparison. Do not invent a gateway issuer when Auth0 remains the issuer.</li><li><strong>Advertise real registration capabilities.</strong> Publishing CIMD support in gateway metadata does not enable it at the authorization server.</li><li><strong>Align the public resource identifier and token audience.</strong> Map resource and provider-specific audience behavior deliberately.</li><li><strong>Keep metadata minimal.</strong> Public clients need the supported public resource, not internal backend hostnames or diagnostic details.</li></ul><p>An operation-not-found response is a routing failure, not proof that OAuth rejected the client. Discovery success is not proof that a protected operation is reachable or authorized. Diagnose those stages separately.</p><h3>Learning 2: DCR and CIMD identify clients</h3><h3>Pre-registration</h3><p>An administrator establishes the client configuration before use. This supports explicit onboarding, but it does not authorize every user or business action.</p><h3>Dynamic Client Registration</h3><p>DCR is defined in <a href="https://www.rfc-editor.org/rfc/rfc7591">RFC 7591</a>. The authorization server accepts client metadata and returns a client identifier. Registration can be open or access-controlled according to server policy.</p><p>An unfamiliar client receiving a successful registration response demonstrates that registration was permitted. It does not by itself demonstrate user access, authorization code theft, or access to enterprise data.</p><p><a href="https://www.rfc-editor.org/rfc/rfc7592">RFC 7592</a>, an Experimental RFC, separately describes management of dynamically registered clients where supported.</p><h3>Client ID Metadata Documents</h3><p>With CIMD, an HTTPS client identifier refers to metadata that the authorization server resolves or pre-associates. It avoids requiring a DCR POST to obtain an authorization-server-generated identifier.</p><p>As checked on November 20, 2026, the <a href="https://datatracker.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/">CIMD specification remains an IETF Internet-Draft</a>, not a published RFC.</p><p>CIMD does not necessarily eliminate client records, grants, quotas, or lifecycle management. The provider publishes the hosted client’s metadata; an enterprise cannot change that client’s identity by publishing a different document of its own.</p><p>Application names and logos are not sufficient evidence of trust. A public client ID is not a secret or proof of possession by an uncompromised runtime.</p><h3>Where Auth0’s CIMD support fits</h3><p><a href="https://auth0.com/docs/get-started/auth0-overview/create-applications/cimd-overview">Auth0 documents both manual and dynamic CIMD registration</a>:</p><ul><li><strong>Manual import</strong> lets an administrator preview and register an externally hosted metadata URL before the client connects.</li><li><strong>Dynamic CIMD</strong> lets an eligible, enabled tenant discover and register a URL-based client during OAuth processing. Auth0 currently labels this feature Early Access; check entitlement and tenant settings.</li><li>Enabling CIMD capability discovery is separate from permitting new clients to register dynamically.</li><li>Auth0’s CIMD clients are third-party applications, with explicit API client grants and suitable authentication connections required.</li><li>Public CIMD clients use PKCE without a shared client secret. Auth0 also documents confidential CIMD clients using Private Key JWT, subject to product availability.</li></ul><p>The public document must never contain a shared secret or private key. Manual and dynamic metadata refresh have different operational implications; a document update does not necessarily change every tenant’s configuration immediately.</p><p>Auth0 recommends CIMD for production MCP onboarding. The <a href="https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration">MCP authorization specification</a> recommends CIMD support and retains DCR as a deprecated compatibility option. That guidance does not deprecate RFC 7591 across all OAuth deployments.</p><h3>Learning 3: Registration, authentication, and consent differ</h3><p>Three questions must not be collapsed into one:</p><ol><li>Is this client admitted and eligible to request access to the API?</li><li>Which user is authenticating through an allowed identity connection?</li><li>What access may this client receive on that user’s behalf?</li></ol><p>A registered client may fail because no appropriate authentication connection is enabled for it. An authenticated user may be denied because the client has no grant to the API. A user can also decline consent.</p><p>For Auth0 third-party applications, verify connection availability and API-access configuration. Promoting a connection to domain level changes its availability to third-party clients; it needs deliberate review and is not an API-authorization control by itself.</p><p>Consent should identify the requesting application and explain the resource and permissions clearly. A display name alone is not verified identity. Request only the scopes needed to establish the connection and supported initial access, rather than broad permissions intended to avoid future authorization work.</p><p>The authorization server enforces registered redirect URIs and applicable grant policy. The client binds the response to its initiating transaction and uses PKCE. APIM does not validate the PKCE verifier or observe a direct consent interaction at Auth0; those checks belong to the OAuth participants handling them.</p><p>An existing session or grant can reduce visible prompts. The absence of a fresh consent screen is not, on its own, evidence that authorization was bypassed. Verify the policy and grant that actually applied.</p><p>Consent creates or confirms a bounded access grant. It is not approval for every future tool call or business transaction.</p><h3>Learning 4: Gateway policies need acceptance criteria</h3><p>Making the connector work is an interoperability milestone. Hardening it requires positive and negative checks at each policy boundary.</p><ul><li><strong>Validate the JWT signature, allowed algorithms, issuer, intended audience, and lifetime before protected forwarding.</strong> Decoding claims is not validation.</li><li><strong>Enforce allowed client/API relationships using documented, validated identity semantics.</strong> A name, identifier prefix, or registration success is not approval.</li><li><strong>Match required scope values exactly and reject insufficient access.</strong> Logging a missing scope while allowing the request is diagnostic, not enforcement.</li><li><strong>Throttle discovery without breaking legitimate setup and retries.</strong> A per-IP discovery limit does not protect a separate registration endpoint.</li><li><strong>Use provider-supported egress restrictions only as an additional control where appropriate.</strong> Shared provider IP space does not identify a client or user.</li><li><strong>If caller-context headers are used, remove untrusted values and derive context from validated identity.</strong> A header’s name does not make it authentic.</li><li><strong>Authenticate the gateway-to-backend hop and constrain bypass paths.</strong> A valid ingress token does not establish a secure backend hop.</li><li><strong>Record failure stage and sanitized correlation data without leaking credentials.</strong> A generic connection error does not locate the failure.</li></ul><p>These are generalized controls and acceptance criteria, not a claim that every control was enabled and tested together in a particular deployment. Remove diagnostic exceptions before treating a successful connection as a security acceptance result.</p><p>Policy ordering matters. If an IP filter rejects a request before JWT validation, that response tests the IP filter, not token validation. Exercise token-negative tests from a path allowed to reach the validator.</p><p>Keep discovery useful, minimal, and cacheable where appropriate. Apply registration controls, quotas, and lifecycle monitoring at the authorization server itself. Removing inactive registrations requires checking active grants and usage, not deleting records based only on naming patterns.</p><h3>Learning 5: Third-party onboarding adds distinct threats</h3><p>First-party and third-party threats overlap, but external onboarding adds boundaries worth reviewing explicitly.</p><ul><li><strong>Unauthorized admission.</strong> Internally, the concern may be ungoverned identity provisioning. Externally, it may be open registration or unapproved metadata URLs. Both need admission and API-grant policy.</li><li><strong>Client impersonation.</strong> Names, logos, and lookalike domains can mislead users. Review provenance and validated redirect metadata rather than trusting presentation.</li><li><strong>Metadata compromise.</strong> Publishing pipelines, hosted documents, domains, and signing keys can change or be compromised. Sensitive changes need monitoring and review.</li><li><strong>Unsafe metadata retrieval.</strong> An authorization server fetching externally supplied URLs needs SSRF protections, destination checks, a redirect policy, bounded response size and time, and suitable caching.</li><li><strong>Code or token interception.</strong> Callback handling and hosted token storage become part of the trust boundary. Exact redirects, PKCE, TLS, and token protection remain essential.</li><li><strong>Excessive delegation and operational abuse.</strong> Broad grants, unclear consent, registration accumulation, and repeated discovery require least privilege, reviewable grants, separate quotas, and lifecycle controls.</li></ul><p>Enterprise ownership does not remove phishing, token theft, or configuration compromise. External ownership increases dependence on the provider’s controls and integration contract.</p><p>For CIMD, HTTPS and a valid document are necessary protocol inputs, not enterprise approval or runtime attestation. Validate the authorization server’s protections rather than adding an unrestricted URL-fetch proxy at the gateway.</p><h3>Define successful connector add before celebrating it</h3><p>First verify that eligible users receive setup details through approved internal channels, use an organizationally permitted agentic channel and account type, and complete any required education and policy acknowledgement. Enterprise ownership of the account used to sign in to Claude.ai, Claude Cowork, or ChatGPT is not a prerequisite. Then follow the client’s actual sequence:</p><ol><li>The public URL and supported probe methods reach the correct APIM operation.</li><li>An unauthenticated protected request receives the expected challenge, not protected data.</li><li>Resource and authorization-server metadata resolve consistently and advertise real capabilities.</li><li>The selected mechanism identifies an admitted client; registration alone cannot grant unapproved clients API access.</li><li>The user can authenticate through an intended connection and approve or decline access under the configured policy.</li><li>The code exchange succeeds only with the correct transaction and PKCE parameters, producing a token for the intended resource.</li><li>APIM accepts the authorized setup request and rejects invalid, expired, wrong-issuer, wrong-audience, and insufficient-scope requests at the intended layer.</li><li>The backend completes MCP setup over the protected route, and the platform reports the connection as available.</li></ol><p>Client transaction and token exchange checks require evidence from the client or authorization server; APIM traces alone cannot prove them. Metadata advertising a registration capability is not evidence that registration completed.</p><p>Use synthetic examples and summarized outcomes when sharing evidence. Raw captures can expose emails, tenant and application identifiers, sessions, request identifiers, tokens, authorization codes, callback query strings, and deployment hostnames. Removing direct identifiers alone may still leave a recognizable topology.</p><h3>What “Connected” means under zero trust</h3><p>A successful connector add establishes that a particular client configuration and user authorization could complete setup and use the granted access for the initial MCP interaction.</p><p>It does not establish that:</p><ul><li>The third-party runtime is now trusted as an internal workload.</li><li>Every user of the same platform has access.</li><li>Every tool or record is authorized by the initial grant.</li><li>A future request is valid because an earlier request succeeded.</li><li>A token remains usable after expiry or effective revocation.</li><li>The agent’s next proposed action reflects the user’s intent.</li></ul><p>Zero trust means making the decision explicit, limiting the grant, and assuming credentials or runtimes can be compromised. It does not mean prompting for consent on every request. It means continuing to validate credentials and enforce applicable authorization rather than inheriting trust from connector status.</p><p>After setup, the path remains hosted MCP client, APIM, backend MCP server. The permission decision still belongs to the protected system, not the platform’s “Connected” label.</p><p>Downstream OBO delegation and the enterprise user’s permission triad are the next boundary, beyond connector onboarding. Auth0 documents MCP-server OBO support, but that is a different operation from admitting a client through DCR or CIMD.</p><p>A successful connector add is a verified starting point for access, not a permanent grant of trust.</p><h3>Further reading</h3><ul><li>MCP authorization specification: <a href="https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration">client registration</a> and security best practices</li><li>DCR: <a href="https://www.rfc-editor.org/rfc/rfc7591">RFC 7591</a> and registration management: <a href="https://www.rfc-editor.org/rfc/rfc7592">RFC 7592</a></li><li>CIMD: <a href="https://datatracker.ietf.org/doc/draft-ietf-oauth-client-id-metadata-document/">IETF Internet-Draft</a></li><li>PKCE: <a href="https://www.rfc-editor.org/rfc/rfc7636">RFC 7636</a></li><li>Authorization server metadata: <a href="https://www.rfc-editor.org/rfc/rfc8414">RFC 8414</a> and protected resource metadata: <a href="https://www.rfc-editor.org/rfc/rfc9728">RFC 9728</a></li><li>Resource indicators: <a href="https://www.rfc-editor.org/rfc/rfc8707">RFC 8707</a></li><li>OAuth security best current practice: <a href="https://www.rfc-editor.org/rfc/rfc9700">RFC 9700</a></li><li>Auth0: DCR, <a href="https://auth0.com/docs/get-started/auth0-overview/create-applications/cimd-overview">CIMD registration</a>, and MCP client registration</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83f2daafea99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure Your MCP Server on Azure App Service with Microsoft Entra ID]]></title>
            <link>https://medium.com/@kunkunbebo/secure-your-mcp-server-on-azure-app-service-with-microsoft-entra-id-f1c1a2bf091a?source=rss-61892af75509------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1c1a2bf091a</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[azure-app-service]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[entra-id]]></category>
            <category><![CDATA[microsoft-entra-easyauth]]></category>
            <dc:creator><![CDATA[Yogi Srivastava]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 00:51:59 GMT</pubDate>
            <atom:updated>2026-11-21T00:56:01.498Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/u/61892af75509">Yogi Srivastava</a> <a href="https://medium.com/u/e274efb7b683">Aneep Agrawal</a> <a href="https://medium.com/u/2b5cea454596">Saima Khan</a></p><p>Connect Microsoft Foundry agents to FastMCP tools without leaving your API open to every caller.</p><p><em>Part 1 of 2. This part secures one hop: a Foundry agent calling an MCP server. </em><a href="https://medium.com/@kunkunbebo/traceable-autonomous-azure-devops-operations-with-foundry-agent-identity-and-app-service-managed-b0215ef46c69?sharedUserId=kunkunbebo"><em>Part 2</em></a><em> walks through the full end-to-end flow, from a signed-in engineer to Azure DevOps work items, pull requests and comments.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*724pf_DMsauD5ZYC1pfLOQ.png" /></figure><p>A working Model Context Protocol (MCP) endpoint is only the beginning. Before an AI agent can use it in a real environment, the server needs to establish who is calling and whether that caller is allowed to use its tools.</p><p>For a FastMCP server hosted on Azure App Service, Microsoft Entra ID and App Service Authentication, also called EasyAuth, provide the authentication boundary. App roles and an approved-client policy define which application identities can cross it.</p><p>The important distinction is this: <strong>accepting a valid token is not the same as authorizing an agent.</strong> The token must target your API, come from the expected tenant, and represent an approved caller. Your tools still need authorization for the actions and records they expose.</p><h3>Where this fits</h3><p>In a full agent solution, several identities hand off to each other: a user signs in to a frontend, a backend calls the Foundry Agent Service, the agent calls MCP tools, and the tools call downstream systems. This article focuses only on the hop in the middle, where the agent’s identity calls the MCP server. The agent calls the server as itself (app-only), not on behalf of the signed-in user. Part 2 covers the hops on either side and what the MCP server does next.</p><h3>The architecture</h3><pre>Foundry agent or project identity<br>    |<br>    | Entra access token for api://$APP_CLIENT_ID<br>    v<br>Azure App Service Authentication (EasyAuth)<br>    | Validate issuer, audience, and approved client<br>    v<br>FastAPI + FastMCP<br>    | Authorize tool and data access<br>    v<br>Application services and data</pre><p>There are two identity systems to keep straight: the app registration represents the protected API, while the agent or project identity represents the caller. Their identifiers are not interchangeable.</p><h3>Before you start</h3><ul><li>An Azure subscription and permission to configure App Service</li><li>Permission to create Entra app registrations and grant application permissions</li><li>A FastAPI application and an App Service deployment workflow</li><li>Python 3.11 or later and the mcp[cli] package</li><li>A Foundry agent or project with an identity enabled</li><li>Azure CLI, Bash, curl, jq, and uuidgen; Azure Developer CLI if using azd up</li></ul><p>The command examples use <strong>Bash syntax</strong>, suitable for a Bash session in Azure Cloud Shell or WSL. They are not PowerShell commands.</p><h3>Use your own environment values</h3><p>Set the following environment variables in your shell before running the examples. Every $VARIABLE_NAME refers to your own environment; no tenant, subscription, resource, or identity values are embedded here.</p><ul><li>$SUBSCRIPTION_ID: Azure subscription ID</li><li>$RESOURCE_GROUP: resource group containing the App Service</li><li>$APP_NAME: App Service name</li><li>$TENANT_ID: Entra tenant ID</li><li>$APP_REGISTRATION_NAME: display name for the protected API registration</li><li>$AGENT_PRINCIPAL_ID: object ID of the agent&#39;s service principal</li><li>$PROJECT_PRINCIPAL_ID: object ID of the project&#39;s service principal, only if it also needs access</li></ul><p>Later commands derive $APP_CLIENT_ID, $APP_OBJECT_ID, $API_SP_ID, $SCOPE_ID, $ROLE_ID, and the caller client IDs. Keep object IDs separate from client IDs.</p><pre>az account set --subscription &quot;$SUBSCRIPTION_ID&quot;</pre><pre>APP_HOSTNAME=$(az webapp show \<br>  --name &quot;$APP_NAME&quot; --resource-group &quot;$RESOURCE_GROUP&quot; \<br>  --query defaultHostName -o tsv)<br>APP_URL=&quot;https://$APP_HOSTNAME&quot;<br>MCP_URL=&quot;$APP_URL/mcp/mcp&quot;<br>PRM_URL=&quot;$APP_URL/.well-known/oauth-protected-resource&quot;</pre><p>Use the actual default hostname returned by Azure rather than constructing one from the resource name. If your application uses a custom domain, use its configured public URL instead.</p><h3>1. Mount FastMCP inside FastAPI</h3><p>FastMCP can expose tools over Streamable HTTP. For a minimal, stateless example, start its session manager as part of the FastAPI lifespan:</p><pre>from contextlib import asynccontextmanager</pre><pre>from fastapi import FastAPI<br>from mcp.server.fastmcp import FastMCP</pre><pre>mcp = FastMCP(&quot;ExampleToolsMCP&quot;, stateless_http=True)<br></pre><pre>@mcp.tool()<br>async def health_check() -&gt; dict[str, str]:<br>    &quot;&quot;&quot;Return a minimal tool response for connectivity testing.&quot;&quot;&quot;<br>    return {&quot;status&quot;: &quot;ok&quot;}<br></pre><pre>@asynccontextmanager<br>async def lifespan(app: FastAPI):<br>    async with mcp.session_manager.run():<br>        yield<br></pre><pre>app = FastAPI(lifespan=lifespan)<br>app.mount(&quot;/mcp&quot;, mcp.streamable_http_app())</pre><p>With the SDK’s default internal /mcp path and the mount above, the public endpoint is $APP_URL/mcp/mcp. If you change the internal path or mount, update $MCP_URL accordingly.</p><blockquote>The session manager must start in production, not only in local development. Ensure your ASGI server runs lifespan events. If the application already has a lifespan handler, combine the startup and shutdown logic rather than replacing it.</blockquote><p>For an existing custom Gunicorn/Uvicorn worker, retain its other settings and enable &quot;lifespan&quot;: &quot;on&quot;. A running web process does not prove that the MCP session manager initialized.</p><h3>2. Deploy the application</h3><p>If your project already includes Azure Developer CLI configuration, use its deployment workflow:</p><pre>azd auth login --use-device-code<br>azd up</pre><p>Otherwise, use your existing App Service deployment pipeline. Verify application startup in an isolated development environment. Do not expose production tools publicly to test connectivity.</p><h3>3. Register the protected API in Entra ID</h3><p>Create a single-tenant app registration and capture both identifiers returned by Microsoft Graph:</p><pre>APP_REGISTRATION=$(az ad app create \<br>  --display-name &quot;$APP_REGISTRATION_NAME&quot; \<br>  --sign-in-audience AzureADMyOrg -o json)</pre><pre>APP_CLIENT_ID=$(printf &#39;%s&#39; &quot;$APP_REGISTRATION&quot; | jq -r &#39;.appId&#39;)<br>APP_OBJECT_ID=$(printf &#39;%s&#39; &quot;$APP_REGISTRATION&quot; | jq -r &#39;.id&#39;)</pre><pre>az ad app update --id &quot;$APP_CLIENT_ID&quot; \<br>  --identifier-uris &quot;api://$APP_CLIENT_ID&quot;</pre><pre>SCOPE_ID=$(uuidgen)<br>ROLE_ID=$(uuidgen)</pre><p>A delegated scope represents access on behalf of a user. An application role represents app-only access. Define them separately, even if your current integration only uses application identities.</p><p>In this article the Foundry agent calls the server app-only, so the MCP.Access app role is what grants access. The user_impersonation scope is only needed if user-delegated MCP clients will also connect to the same API. If none will, you can leave it out and drop it from the discovery metadata in step 6.</p><pre>az rest --method PATCH \<br>  --uri &quot;https://graph.microsoft.com/v1.0/applications/$APP_OBJECT_ID&quot; \<br>  --headers &quot;Content-Type=application/json&quot; \<br>  --body &quot;$(cat &lt;&lt;JSON<br>{<br>  &quot;api&quot;: {<br>    &quot;requestedAccessTokenVersion&quot;: 2,<br>    &quot;oauth2PermissionScopes&quot;: [{<br>      &quot;id&quot;: &quot;$SCOPE_ID&quot;,<br>      &quot;value&quot;: &quot;user_impersonation&quot;,<br>      &quot;type&quot;: &quot;User&quot;,<br>      &quot;isEnabled&quot;: true,<br>      &quot;adminConsentDisplayName&quot;: &quot;Access MCP Server&quot;,<br>      &quot;adminConsentDescription&quot;: &quot;Access the MCP server on behalf of a user.&quot;,<br>      &quot;userConsentDisplayName&quot;: &quot;Access MCP Server&quot;,<br>      &quot;userConsentDescription&quot;: &quot;Access the MCP server on your behalf.&quot;<br>    }]<br>  },<br>  &quot;appRoles&quot;: [{<br>    &quot;id&quot;: &quot;$ROLE_ID&quot;,<br>    &quot;allowedMemberTypes&quot;: [&quot;Application&quot;],<br>    &quot;displayName&quot;: &quot;MCP.Access&quot;,<br>    &quot;description&quot;: &quot;Allow an application to access the MCP server.&quot;,<br>    &quot;isEnabled&quot;: true,<br>    &quot;value&quot;: &quot;MCP.Access&quot;<br>  }]<br>}<br>JSON<br>)&quot;</pre><p>This example targets a new registration. Updating an existing registration requires preserving its existing scopes and roles; replacing these arrays can remove other permissions.</p><h3>Create the API’s service principal</h3><p>The app registration defines the API. Its service principal is the tenant-local resource used in role assignments.</p><pre>API_SP_ID=$(az ad sp create --id &quot;$APP_CLIENT_ID&quot; --query id -o tsv)</pre><p>If the service principal already exists, retrieve its object ID with az ad sp show --id &quot;$APP_CLIENT_ID&quot; --query id -o tsv instead.</p><h3>4. Identify the callers and grant access</h3><p>Look up each caller’s service principal. Use its appId for the approved-client policy and its id for the role assignment. Do not assume those values are equal.</p><pre>AGENT_CLIENT_ID=$(az ad sp show \<br>  --id &quot;$AGENT_PRINCIPAL_ID&quot; --query appId -o tsv)</pre><pre>PROJECT_CLIENT_ID=$(az ad sp show \<br>  --id &quot;$PROJECT_PRINCIPAL_ID&quot; --query appId -o tsv)</pre><p>Grant the MCP.Access role to each identity that actually calls the server. If only the agent calls it, omit the project identity from the lookup, assignments, and allowlist.</p><pre>for PRINCIPAL_ID in &quot;$AGENT_PRINCIPAL_ID&quot; &quot;$PROJECT_PRINCIPAL_ID&quot;; do<br>  az rest --method POST \<br>    --uri &quot;https://graph.microsoft.com/v1.0/servicePrincipals/$PRINCIPAL_ID/appRoleAssignments&quot; \<br>    --headers &quot;Content-Type=application/json&quot; \<br>    --body &quot;$(cat &lt;&lt;JSON<br>{<br>  &quot;principalId&quot;: &quot;$PRINCIPAL_ID&quot;,<br>  &quot;resourceId&quot;: &quot;$API_SP_ID&quot;,<br>  &quot;appRoleId&quot;: &quot;$ROLE_ID&quot;<br>}<br>JSON<br>)&quot;<br>done</pre><p>These are create operations, not an idempotent provisioning script. On a rerun, inspect existing assignments before attempting to add them again.</p><p>For a dedicated app-only API, require assignments on the API’s service principal so unassigned applications cannot obtain app-only access through this resource:</p><pre>az rest --method PATCH \<br>  --uri &quot;https://graph.microsoft.com/v1.0/servicePrincipals/$API_SP_ID&quot; \<br>  --headers &quot;Content-Type=application/json&quot; \<br>  --body &#39;{&quot;appRoleAssignmentRequired&quot;:true}&#39;</pre><p>Review the impact before enabling assignment requirements on a shared API, especially one that also supports user sign-in.</p><blockquote>Delegated consent preauthorization and application role assignment solve different problems. An entry in api.preAuthorizedApplications is not a substitute for granting an application identity its app role.</blockquote><h3>5. Enable App Service Authentication</h3><p>Configure EasyAuth to require authentication, return HTTP 401 instead of an interactive redirect, validate the API audience, and admit only approved client applications.</p><p>The following configuration is for a bearer-token API. It does not configure interactive web sign-in or a client secret. If you also need a browser sign-in flow, configure its credentials and redirect settings separately and keep secrets out of published examples.</p><pre>AUTH_SETTINGS_URL=&quot;https://management.azure.com/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.Web/sites/$APP_NAME/config/authsettingsV2?api-version=2024-04-01&quot;</pre><pre>az rest --method PUT \<br>  --uri &quot;$AUTH_SETTINGS_URL&quot; \<br>  --headers &quot;Content-Type=application/json&quot; \<br>  --body &quot;$(cat &lt;&lt;JSON<br>{<br>  &quot;properties&quot;: {<br>    &quot;platform&quot;: {<br>      &quot;enabled&quot;: true,<br>      &quot;runtimeVersion&quot;: &quot;~2&quot;<br>    },<br>    &quot;httpSettings&quot;: {<br>      &quot;requireHttps&quot;: true<br>    },<br>    &quot;globalValidation&quot;: {<br>      &quot;requireAuthentication&quot;: true,<br>      &quot;unauthenticatedClientAction&quot;: &quot;Return401&quot;<br>    },<br>    &quot;identityProviders&quot;: {<br>      &quot;azureActiveDirectory&quot;: {<br>        &quot;enabled&quot;: true,<br>        &quot;registration&quot;: {<br>          &quot;openIdIssuer&quot;: &quot;https://login.microsoftonline.com/$TENANT_ID/v2.0&quot;,<br>          &quot;clientId&quot;: &quot;$APP_CLIENT_ID&quot;<br>        },<br>        &quot;validation&quot;: {<br>          &quot;allowedAudiences&quot;: [<br>            &quot;api://$APP_CLIENT_ID&quot;,<br>            &quot;$APP_CLIENT_ID&quot;<br>          ],<br>          &quot;defaultAuthorizationPolicy&quot;: {<br>            &quot;allowedApplications&quot;: [<br>              &quot;$AGENT_CLIENT_ID&quot;,<br>              &quot;$PROJECT_CLIENT_ID&quot;<br>            ]<br>          }<br>        }<br>      }<br>    }<br>  }<br>}<br>JSON<br>)&quot;</pre><pre>az webapp restart --name &quot;$APP_NAME&quot; --resource-group &quot;$RESOURCE_GROUP&quot;</pre><p>The issuer above matches the v2 access-token configuration set on the API registration. If you use an existing registration with a different token version, align the issuer with the tokens it issues.</p><p>A full PUT can replace existing authentication settings. Export and review your current configuration before applying this example to an existing application, and retain any providers or policies it still needs.</p><p>The client allowlist controls which applications may call the API. It does not replace application-level checks for the MCP.Access role, delegated scopes, tool permissions, or record ownership.</p><h3>6. Publish authentication discovery metadata</h3><p>Protected Resource Metadata (PRM) tells compatible MCP clients which authorization server and scopes are associated with the resource. On App Service configurations that support the EasyAuth PRM setting, configure it as follows:</p><pre>az webapp config appsettings set \<br>  --name &quot;$APP_NAME&quot; --resource-group &quot;$RESOURCE_GROUP&quot; \<br>  --settings WEBSITE_AUTH_PRM_DEFAULT_WITH_SCOPES=&quot;api://$APP_CLIENT_ID/user_impersonation&quot; \<br>  --output none</pre><pre>curl --silent --show-error &quot;$PRM_URL&quot;</pre><p>Check that discovery is accessible without a bearer token and that the returned metadata matches your public resource URL, tenant, and scope. Availability and response details depend on your App Service environment; verify the endpoint rather than assuming the setting alone enables discovery.</p><pre>{<br>  &quot;resource&quot;: &quot;$APP_URL&quot;,<br>  &quot;authorization_servers&quot;: [<br>    &quot;https://login.microsoftonline.com/$TENANT_ID/v2.0&quot;<br>  ],<br>  &quot;scopes_supported&quot;: [<br>    &quot;api://$APP_CLIENT_ID/user_impersonation&quot;<br>  ]<br>}</pre><p>The JSON above illustrates the shape of the response using placeholders. A live response contains resolved values. Publishing a delegated scope does not grant application permissions: an app-only caller still requests api://$APP_CLIENT_ID/.default and needs its app role assignment.</p><h3>7. Connect and test the Foundry identity</h3><p>Configure your Foundry MCP connection with $MCP_URL and the supported Entra identity authentication mode. Where the connection asks for an audience or resource, use api://$APP_CLIENT_ID; where it asks for an OAuth scope for app-only access, use api://$APP_CLIENT_ID/.default.</p><p>Confirm which identity the connection actually uses. Granting access to a project identity does not authorize an agent identity automatically, or vice versa.</p><h3>Check the negative paths first</h3><pre>MCP_INIT=&#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:1,&quot;method&quot;:&quot;initialize&quot;,&quot;params&quot;:{&quot;protocolVersion&quot;:&quot;2025-03-26&quot;,&quot;capabilities&quot;:{},&quot;clientInfo&quot;:{&quot;name&quot;:&quot;test-client&quot;,&quot;version&quot;:&quot;1.0&quot;}}}&#39;</pre><pre># No token: expect HTTP 401.<br>curl --silent --show-error -o /dev/null -w &#39;%{http_code}\n&#39; \<br>  -X POST &quot;$MCP_URL&quot; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;Accept: application/json, text/event-stream&#39; \<br>  -d &quot;$MCP_INIT&quot;</pre><pre># A token for Azure Resource Manager is not a token for this API.<br>WRONG_AUDIENCE_TOKEN=$(az account get-access-token \<br>  --resource <a href="https://management.azure.com/">https://management.azure.com/</a> \<br>  --query accessToken -o tsv)</pre><pre># Wrong audience: expect HTTP 401.<br>curl --silent --show-error -o /dev/null -w &#39;%{http_code}\n&#39; \<br>  -X POST &quot;$MCP_URL&quot; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;Accept: application/json, text/event-stream&#39; \<br>  -H &quot;Authorization: Bearer $WRONG_AUDIENCE_TOKEN&quot; \<br>  -d &quot;$MCP_INIT&quot;</pre><p>Also test an invalid or expired token, an unapproved client with the correct audience, and an identity without the required role. Authentication failures generally produce 401; authorization denials may produce 403 or fail earlier during token acquisition.</p><h3>Test with an approved caller</h3><p>Acquire $ACCESS_TOKEN through the approved identity&#39;s supported authentication flow. Do not publish, log, or paste its value into an article. A token obtained through an interactive Azure CLI login represents that CLI client and user, not automatically your approved agent.</p><pre>curl --silent --show-error -i -X POST &quot;$MCP_URL&quot; \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -H &#39;Accept: application/json, text/event-stream&#39; \<br>  -H &quot;Authorization: Bearer $ACCESS_TOKEN&quot; \<br>  -d &quot;$MCP_INIT&quot;</pre><p>A successful initialization returns an MCP response describing the negotiated protocol version, server, and capabilities. Use an MCP client for the full lifecycle, including the initialized notification and any negotiated session headers, before enumerating or calling tools.</p><p>Finally, run the Foundry agent and inspect its tool-enumeration trace. Successful initialization is useful evidence; a successful authorized tool call is the end-to-end check.</p><h3>When the connection times out</h3><p>An initialization timeout can hide a failure at several different layers. Check them in order:</p><ol><li>Confirm that the deployed MCP route matches $MCP_URL.</li><li>Check application startup and verify that the MCP session manager started.</li><li>Inspect the token’s issuer, audience, caller client ID, and roles without logging the token.</li><li>Confirm that the protected API has a service principal.</li><li>Check role assignments using principal object IDs and the API service principal object ID.</li><li>Compare the actual caller client ID with the EasyAuth approved-client policy.</li><li>Verify that discovery metadata is reachable if the client requires it.</li><li>Investigate cold starts, network restrictions, and App Service availability.</li></ol><pre># Inspect the current authentication settings.<br>az rest --method GET --uri &quot;$AUTH_SETTINGS_URL&quot;</pre><pre># Inspect assignments for the actual caller.<br>az rest --method GET \<br>  --uri &quot;https://graph.microsoft.com/v1.0/servicePrincipals/$AGENT_PRINCIPAL_ID/appRoleAssignments&quot;</pre><pre># Stream logs if application logging is enabled.<br>az webapp log tail --name &quot;$APP_NAME&quot; --resource-group &quot;$RESOURCE_GROUP&quot;</pre><p>Use Entra service principal or managed identity sign-in logs, as applicable, to confirm which identity requested a token and which resource it targeted. Application logs then show whether the authenticated request reached the MCP runtime.</p><blockquote>Do not disable authentication on a live server to diagnose an integration. Reproduce unauthenticated transport tests locally or in an isolated staging deployment with no sensitive tools or production data.</blockquote><h3>A production readiness checklist</h3><ul><li>Unauthenticated MCP requests are rejected.</li><li>Tokens with the wrong issuer or audience are rejected.</li><li>Correct-audience tokens from unapproved applications are denied.</li><li>The actual calling identity has the required application role.</li><li>The application enforces tool-level and data-level authorization.</li><li>MCP lifespan startup works in the deployed runtime.</li><li>Discovery metadata is reachable where required by the client.</li><li>Logs and traces exclude access tokens, secrets, and sensitive tool arguments.</li><li>A real Foundry run can initialize, enumerate tools, and complete an authorized call.</li></ul><h3>The takeaway</h3><p>Securing an MCP integration is a chain of decisions: identify the resource, validate the token, admit the caller, grant the application permission, and authorize the requested action.</p><p>EasyAuth handles an important part of that chain. Entra app roles and approved-client policies narrow access further. Your application remains responsible for what each tool is allowed to do.</p><p><strong>A reachable tool is a capability. A correctly authorized tool is a controlled capability.</strong></p><h3>Next in this series</h3><p><a href="https://medium.com/@kunkunbebo/traceable-autonomous-azure-devops-operations-with-foundry-agent-identity-and-app-service-managed-b0215ef46c69?sharedUserId=kunkunbebo">Part 2</a> follows the whole flow end to end and answers the question this hop raises: when an autonomous agent changes something in Azure DevOps, how do you trace that change back to the agent identity, the agent run and the person who started it?</p><p><em>The views and opinions expressed in this article are those of the authors and do not necessarily reflect the official policy or position of their employers or any other organization. This article is provided for informational purposes only and does not constitute official product guidance. Examples are illustrative; validate any configuration in your own environment before use.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1c1a2bf091a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Traceable Autonomous Azure DevOps Operations with Foundry Agent Identity and App Service Managed…]]></title>
            <link>https://medium.com/@kunkunbebo/traceable-autonomous-azure-devops-operations-with-foundry-agent-identity-and-app-service-managed-b0215ef46c69?source=rss-61892af75509------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0215ef46c69</guid>
            <category><![CDATA[entra-agent-id]]></category>
            <category><![CDATA[autonomous-agent]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Yogi Srivastava]]></dc:creator>
            <pubDate>Sat, 21 Nov 2026 00:48:49 GMT</pubDate>
            <atom:updated>2026-11-21T00:54:58.115Z</atom:updated>
            <content:encoded><![CDATA[<h3>Traceable Autonomous Azure DevOps Operations with Foundry Agent Identity and App Service Managed Identity</h3><p>By <a href="https://medium.com/u/e274efb7b683">Aneep Agrawal</a> <a href="https://medium.com/u/61892af75509">Yogi Srivastava</a></p><p>When an agent opens a pull request at 2 a.m., you should be able to say which agent did it, in which run, and who started it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L1dOyutPMRVwFqz5wjAQzA.png" /></figure><p><em>Part 2 of 2. </em><a href="https://medium.com/@kunkunbebo/secure-your-mcp-server-on-azure-app-service-with-microsoft-entra-id-f1c1a2bf091a"><em>Part 1</em></a><em> showed how to secure the hop where a Foundry agent calls an MCP server on Azure App Service with Microsoft Entra ID. This part follows the full flow end to end.</em></p><p>Autonomous agents are starting to do real engineering work: creating work items, opening pull requests, commenting on reviews and taking part in approvals. The hard question is not whether the agent can make the change. It is whether you can explain the change afterwards.</p><p>In Azure DevOps, every action is attributed to an identity. Ideally that identity would be the agent itself. Microsoft Foundry gives each agent its own Entra agent identity, but at the time we built this, we could not use that agent identity directly as an Azure DevOps user for these operations. If we simply gave a shared service account access to Azure DevOps, every change would look the same, and the trail back to the agent would be lost.</p><p>This article shows the pattern we used to keep that trail intact. <strong>The Foundry agent identity proves which agent is calling. An App Service managed identity performs the Azure DevOps operation. The MCP server in between binds the two together and records the link.</strong></p><h3>The end-to-end flow</h3><pre>DevOps engineer<br>   | (1) Sign in with MFA<br>   v<br>Frontend (App Service A)<br>   | (2) Call backend with the user&#39;s token (user token stops here)<br>   v<br>Backend (App Service B, managed identity)<br>   | (3) Start an agent run with its managed identity (Azure AI User)<br>   v<br>Foundry Agent Service<br>   | (4) Agent calls tools with its Entra agent identity<br>   v<br>MCP server (App Service C, EasyAuth + managed identity)<br>   | (5) Validate the agent, call Azure DevOps as the managed identity,<br>   |     and stamp the agent identity and correlation ID on the change<br>   v<br>Azure DevOps<br>     (6) Work items, PRs, comments, approvals</pre><p>Two setup steps come before any request:</p><ol><li><strong>Enable a system-assigned managed identity</strong> on the App Service that hosts the MCP server.</li><li><strong>Add that managed identity as a user</strong> in your Azure DevOps organization, and grant it permissions in the specific projects the agents need to work in.</li></ol><h3>Who is who? the identities in the chain</h3><p>Most traceability problems come from mixing up identities. Each hop has exactly one caller and one thing it proves:</p><p>HopCaller identityWhat it provesWhere it is recorded1. Sign inThe engineer (Entra user + MFA)A real, verified person started the workEntra sign-in logs, frontend logs2. Frontend → backendThe engineer’s token for the backend APIThe backend request came from that signed-in userBackend logs3. Backend → FoundryBackend managed identity (Azure AI User role)An approved backend started the agent runManaged identity sign-in logs, Foundry run history4. Agent → MCP serverFoundry agent identity (MCP.Access app role)Which agent is calling the toolAgent identity sign-in logs, MCP server logs5. MCP server → Azure DevOpsMCP server managed identityThe approved MCP server made the changeManaged identity sign-in logs, Azure DevOps history and audit log</p><p>Notice what does <em>not</em> happen: the engineer’s token is never forwarded past the backend, and the agent’s token is never forwarded to Azure DevOps. Each hop gets a token for its own audience. Traceability comes from linking the hops, not from passing one credential through all of them.</p><h3>Hop 1 and 2: the user starts the work</h3><p>The engineer signs in to the frontend through Entra ID, with MFA enforced by Conditional Access. The frontend calls the backend with a token issued for the backend’s API, and the backend validates it.</p><p>This is the last point where the user’s identity is cryptographically proven. So the backend does two things before going further:</p><ul><li>Creates a <strong>correlation ID</strong> for this unit of work.</li><li>Records the user’s object ID, the correlation ID and the requested task in its own log.</li></ul><pre>import uuid, logging</pre><pre>def start_task(user_claims: dict, task: str) -&gt; str:<br>    correlation_id = str(uuid.uuid4())<br>    logging.info(&quot;task.start&quot;, extra={<br>        &quot;correlation_id&quot;: correlation_id,<br>        &quot;user_oid&quot;: user_claims[&quot;oid&quot;],   # from the validated token<br>        &quot;task&quot;: task,<br>    })<br>    return correlation_id</pre><h3>Hop 3: the backend starts the agent run</h3><p>The backend calls the Foundry Agent Service with its own system-assigned managed identity, which holds the <strong>Azure AI User</strong> role on the Foundry project. No secrets or keys are stored in the backend.</p><p>When it starts the run, the backend passes the correlation ID into the run, for example in the run’s instructions or metadata, and logs the returned thread and run IDs alongside it. You now have: <em>user → correlation ID → agent run</em>.</p><pre>from azure.identity import ManagedIdentityCredential<br>from azure.ai.projects import AIProjectClient</pre><pre>credential = ManagedIdentityCredential()<br>project = AIProjectClient(endpoint=&quot;$FOUNDRY_PROJECT_ENDPOINT&quot;, credential=credential)</pre><pre># Start the run with your SDK&#39;s run API, include the correlation ID in the<br># instructions or metadata, then log thread_id and run_id with correlation_id.</pre><p>The exact run API depends on your Foundry SDK version. What matters is that the run ID and correlation ID land in the same log record.</p><h3>Hop 4: the agent calls the MCP server as itself</h3><p>This is the hop Part 1 covers in detail. In short:</p><ul><li>The MCP server’s API is registered in Entra ID with an app role, MCP.Access, allowed for applications only.</li><li>The Foundry agent identity is assigned that role.</li><li>App Service Authentication (EasyAuth) validates the issuer and audience, and only admits approved client applications.</li></ul><p>For traceability, the key point is that once EasyAuth has validated the token, the MCP server <strong>knows exactly which agent identity is calling</strong>. EasyAuth passes the validated claims to your code in the X-MS-CLIENT-PRINCIPAL header, a base64-encoded JSON document. Only trust this header when EasyAuth is enabled in front of the app and the app cannot be reached any other way.</p><pre>import base64, json</pre><pre>def caller_from_easyauth(headers) -&gt; dict:<br>    raw = headers.get(&quot;x-ms-client-principal&quot;)<br>    if not raw:<br>        raise PermissionError(&quot;No authenticated caller&quot;)<br>    principal = json.loads(base64.b64decode(raw))<br>    claims = {c[&quot;typ&quot;]: c[&quot;val&quot;] for c in principal.get(&quot;claims&quot;, [])}<br>    return {<br>        # v2 tokens carry azp; v1 tokens carry appid<br>        &quot;agent_client_id&quot;: claims.get(&quot;azp&quot;) or claims.get(&quot;appid&quot;),<br>        &quot;agent_object_id&quot;: claims.get(&quot;http://schemas.microsoft.com/identity/claims/objectidentifier&quot;)<br>                           or claims.get(&quot;oid&quot;),<br>        &quot;roles&quot;: [c[&quot;val&quot;] for c in principal.get(&quot;claims&quot;, []) if c[&quot;typ&quot;] == &quot;roles&quot;],<br>    }</pre><p>Claim type names in this header can vary by token version. Log the claim types once in a test environment and adjust the lookups to match.</p><h3>Hop 5: the MCP server acts in Azure DevOps and binds the trail</h3><p>The MCP server calls Azure DevOps with <strong>its own managed identity</strong>, not the agent’s token. Azure DevOps sees the managed identity as the actor. That is why the MCP server must do the binding: it is the only component that knows both the verified agent identity and the Azure DevOps change it is about to make.</p><h3>Get an Azure DevOps token with the managed identity</h3><pre>from azure.identity import ManagedIdentityCredential</pre><pre>AZDO_SCOPE = &quot;499b84ac-1321-427f-aa17-267ca6975798/.default&quot;  # Azure DevOps resource<br>credential = ManagedIdentityCredential()</pre><pre>def azdo_headers() -&gt; dict:<br>    token = credential.get_token(AZDO_SCOPE).token<br>    return {&quot;Authorization&quot;: f&quot;Bearer {token}&quot;, &quot;Content-Type&quot;: &quot;application/json&quot;}</pre><h3>Stamp the agent identity on every change</h3><p>Each tool writes three things: the Azure DevOps change itself, a visible attribution on that change, and a structured log record that links everything.</p><pre>import logging, requests<br>from mcp.server.fastmcp import Context</pre><pre>ORG, PROJECT, REPO = &quot;$AZDO_ORG&quot;, &quot;$AZDO_PROJECT&quot;, &quot;$AZDO_REPO&quot;<br>ALLOWED_AGENTS = {&quot;$AGENT_CLIENT_ID&quot;}  # deny by default</pre><pre>@mcp.tool()<br>async def comment_on_pull_request(pr_id: int, text: str,<br>                                  correlation_id: str, ctx: Context) -&gt; dict:<br>    caller = caller_from_easyauth(ctx.request_context.request.headers)<br>    if caller[&quot;agent_client_id&quot;] not in ALLOWED_AGENTS:<br>        raise PermissionError(&quot;Agent not approved for this tool&quot;)</pre><pre>    footer = (f&quot;\n\n---\nPosted by agent {caller[&#39;agent_client_id&#39;]} &quot;<br>              f&quot;via MCP server. Correlation ID: {correlation_id}&quot;)<br>    url = (f&quot;https://dev.azure.com/{ORG}/{PROJECT}/_apis/git/repositories/&quot;<br>           f&quot;{REPO}/pullRequests/{pr_id}/threads?api-version=7.1&quot;)<br>    body = {&quot;comments&quot;: [{&quot;parentCommentId&quot;: 0, &quot;content&quot;: text + footer,<br>                          &quot;commentType&quot;: 1}], &quot;status&quot;: 1}<br>    resp = requests.post(url, headers=azdo_headers(), json=body, timeout=30)<br>    resp.raise_for_status()</pre><pre>    logging.info(&quot;azdo.write&quot;, extra={<br>        &quot;correlation_id&quot;: correlation_id,<br>        &quot;agent_client_id&quot;: caller[&quot;agent_client_id&quot;],<br>        &quot;agent_object_id&quot;: caller[&quot;agent_object_id&quot;],<br>        &quot;operation&quot;: &quot;pr.comment&quot;,<br>        &quot;azdo_pr_id&quot;: pr_id,<br>        &quot;azdo_thread_id&quot;: resp.json().get(&quot;id&quot;),<br>    })<br>    return {&quot;thread_id&quot;: resp.json().get(&quot;id&quot;)}</pre><p>Use the same pattern for every write tool: the work item’s history or a tag, the pull request description, and the comment footer all carry the agent identity and correlation ID. How you read the HTTP request inside a tool depends on your MCP SDK version; recent versions of the Python SDK expose it through the request context.</p><blockquote><strong>Trust levels differ.</strong> The agent identity comes from a validated token, so it is authoritative. The correlation ID arrives as a tool argument chosen by the model, so treat it as a hint for linking records, never as proof. Confirm it against the run in your backend and Foundry logs.</blockquote><h3>Hop 6: reading the trail back</h3><p>With every hop logging the same correlation ID, any Azure DevOps change can be traced back in a few steps:</p><ol><li><strong>Start from Azure DevOps.</strong> The change’s history shows the MCP server’s managed identity as the actor. The comment, description or work item history shows the agent identity and the correlation ID.</li><li><strong>Go to the MCP server log.</strong> Find the azdo.write record by Azure DevOps object ID or correlation ID. It gives the validated agent client ID and object ID.</li><li><strong>Go to the backend log.</strong> The correlation ID gives you the Foundry run ID and the user who started the task.</li><li><strong>Confirm with Entra sign-in logs.</strong> The agent identity’s token request for the MCP API and the managed identity’s token request for Azure DevOps should both appear at the matching time.</li></ol><p>If all your App Services send logs to the same Log Analytics workspace, one query that joins on correlation_id reconstructs the whole chain: <em>engineer → agent run → agent identity → MCP tool → Azure DevOps change</em>.</p><h3>Controls this pattern needs</h3><p>Because one managed identity performs Azure DevOps changes for every approved agent, its permissions are shared. Treat it like a privileged account.</p><ul><li><strong>Least privilege in Azure DevOps.</strong> Grant the managed identity access only in the projects the agents need, at project level, not through organization-wide or collection-wide groups. Give it an access level that covers the features it uses, and nothing more.</li><li><strong>A per-agent allowlist in the MCP server.</strong> Map each agent client ID to the tools and projects it may use, and deny anything not listed. EasyAuth decides which agents can reach the server; the allowlist decides what each one can do.</li><li><strong>Separation of duties for approvals.</strong> If the same managed identity can open a pull request and vote on it, an agent could effectively approve its own change. Use branch policies that require a minimum number of human reviewers, turn off “Allow requestors to approve their own changes”, and consider not exposing an approve tool at all until you have a clear policy for it.</li><li><strong>Split identities by risk.</strong> A read-only MCP server and a write-capable MCP server can run as separate App Services with separate managed identities, so a problem with one agent does not inherit every permission.</li><li><strong>No secrets in the chain.</strong> Managed identities and agent identities remove the need for personal access tokens or stored client secrets. Do not reintroduce them for convenience.</li><li><strong>Protect the logs.</strong> Log identities, IDs and operations, never access tokens or sensitive tool arguments. Restrict who can read and change the logs that make up your audit trail.</li></ul><h3>A traceability checklist</h3><ul><li>The user’s identity is verified with MFA and recorded with a correlation ID at the backend.</li><li>The backend logs the Foundry run ID against the same correlation ID.</li><li>The MCP server rejects any caller that is not an approved agent identity with the MCP.Access role.</li><li>Every write tool records the validated agent identity, correlation ID, operation and Azure DevOps object ID.</li><li>Every Azure DevOps change visibly names the agent identity and correlation ID.</li><li>The managed identity’s Azure DevOps permissions are limited to the projects and actions the agents need.</li><li>Branch policies prevent an agent from being the only approver of its own change.</li><li>One query can reconstruct the chain from an Azure DevOps change back to the person who started it.</li></ul><h3>The takeaway</h3><p>Autonomy without traceability is a support ticket waiting to happen. This pattern does not pretend the managed identity is the agent. It keeps each identity doing the one job it can prove: the user proves who started the work, the agent identity proves which agent asked, and the managed identity proves which approved service made the change.</p><p><strong>The MCP server is where those proofs meet. Make it record the link every time, and every autonomous change in Azure DevOps has a name, a run and a person behind it.</strong></p><p><em>The views and opinions expressed in this article are those of the authors and do not necessarily reflect the official policy or position of their employers or any other organization. This article is provided for informational purposes only and does not constitute official product guidance. Examples are illustrative; validate any configuration in your own environment before use.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0215ef46c69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Context Space — A Modern Framework for Shifting Security Left]]></title>
            <link>https://medium.com/@kunkunbebo/security-context-space-a-modern-framework-for-shifting-security-left-bf257ed3ff21?source=rss-61892af75509------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf257ed3ff21</guid>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[ai-assisted-code-scans]]></category>
            <category><![CDATA[developer-security]]></category>
            <category><![CDATA[generative-ai-security]]></category>
            <category><![CDATA[ai-security]]></category>
            <dc:creator><![CDATA[Yogi Srivastava]]></dc:creator>
            <pubDate>Mon, 04 May 2026 13:40:11 GMT</pubDate>
            <atom:updated>2026-05-04T13:40:11.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*quRm5nadPXRrxyUPaUHV8Q.png" /><figcaption>DevSecOps with Security Context Space</figcaption></figure><p>The <strong>Security Context Space</strong> is a structured, AI‑assisted environment that embeds security deeply and continuously into the developer workflow. Instead of treating security as a late‑stage checkpoint, the <em>security</em> <em>context space</em> creates a <em>persistent, evolving context</em> — a combination of prompts, chat modes, instructions, and organisation‑specific artifacts — that ensures every interaction with GitHub Copilot happens within a secure, well‑informed boundary.</p><p>At its core, the <em>Security Context Space </em>orchestrates industry‑standard security tools (such as pip‑audit, Bandit, Semgrep, and OWASP Dependency‑Check) directly inside the developer’s IDE, using GitHub Copilot’s prompts to guide analysis and remediation. This approach allows developers to surface vulnerabilities during implementation even <em>before</em> code reaches PR review, hence enabling earlier detection, faster remediation, and cheaper mitigation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQ3lA37S-kQ7ZllRblPJGw.png" /><figcaption>Innovation with Security as first-class citizen</figcaption></figure><p>The framework builds a “living” security context tailored to both the <strong>customer’s environment</strong> and <strong>security baselines</strong>, incorporating known security events and incidents, audit items, compliance requirements, threat models, and best practices. This ensures that every recommendation Copilot makes is grounded in the real-world constraints and risks of the organisation. This context integration provides traceable, repeatable outcomes.</p><p>For engineering leaders, the <em>Security Context Space</em> acts as a <strong>security flywheel by </strong>continuously reducing vulnerabilities, improving code quality, strengthening compliance, and accelerating onboarding. It transforms Copilot from a generic coding assistant into a <strong>strategic security enabler</strong>, generating measurable improvements in review cycles, vulnerability reduction, and development velocity.</p><p>Security Context Layering Strategy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4rrTX763qL0fdNljJrtiw.png" /></figure><p>Ultimately, the Security Context Space operationalises “shift‑left security” at scale by turning secure coding into a natural, guided, and AI‑augmented part of everyday development by empowering every developer to become a security champion while giving enterprises the confidence to innovate safely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf257ed3ff21" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>