Blog Post

Azure Integration Services Blog
6 MIN READ

Run MCP tools as the signed-in user: on-behalf-of authentication in Connector Namespace

WSilveira's avatar
WSilveira
Icon for Microsoft rankMicrosoft
Nov 17, 2026

You built an agent that answers employee questions from SharePoint. It works. Then someone asks the obvious question: whose access is the agent using? If the answer is "one shared connection with access to everything", that agent isn't going to production. On-behalf-of (OBO) authentication for MCP connectors fixes that.

What is on-behalf-of authentication

OBO is a standard Microsoft Entra ID OAuth 2.0 flow. A service receives a user's token, exchanges it for a new token for a downstream API, and that new token still represents the same user.

In Connector Namespace, you turn it on per MCP connector (a set of connector operations exposed as Model Context Protocol tools) by setting its authentication mode to OnBehalfOfUser. In the portal, this option is called Per-user authentication. From then on:

  • There's no shared connection. The first time a user calls a tool, the namespace creates a connection for that user and that MCP connector.
  • The user signs in to the connector once. Later calls reuse their connection.
  • Connector credentials stay in the namespace. Your app never sees them.
 Developer connection (default)On-behalf-of user
Runs asThe connection ownerThe user calling the tool
ConnectionsOne, shared by every callerOne per user, created on first use
What the agent can reachEverything the owner can reachOnly what that user can reach

Why it matters

An agent that reads files or tickets for an employee should see only what that employee can see. With OBO, it does, because every call runs with the user's own permissions in the downstream system. OBO uses delegated permissions, so it never gives a user access they don't already have.

That changes three things for you:

  • No shared service account. Nothing in your namespace holds broad access on behalf of everyone.
  • Actions belong to real people. The downstream system sees the user, not a service account, so its audit trail stays meaningful.
  • Access is yours to pull. Remove an app or user from the MCP connector's access policies and their calls stop.

Targets: where OBO applies

OBO targets connector-backed MCP connectors that use Per-user authentication (OnBehalfOfUser in the API and CLI). It works with any managed connector that supports OAuth sign-in, such as SharePoint Online and Office 365 Outlook. Connectors that don't support OAuth can't use this mode.

Two details shape your design:

  • Each OBO MCP connector wraps exactly one connector. Need SharePoint and Outlook? Create two MCP connectors.
  • Every call needs two matches: an Application access policy for the calling app, and a User or Group policy for the signed-in user. Permissions on a connection don't count toward this check.

Hosted MCP servers have their own OBO mode with an admin app registration. That's a separate post.

Prerequisites

You need four things before the walkthrough. The first two are one-time tenant setup, usually done by an Entra admin.

  1. A connector namespace. Plus Owner or Contributor on it. See Create a connector namespace.

  2. The Azure API Connections enterprise application in your tenant. This is a Microsoft first-party app, not an Azure resource you deploy. It represents the namespace runtime in Entra ID (application ID fe053c5f-3692-4f14-aef2-ee34fc081cae, audience https://apihub.azure.com). Check whether your tenant already has it:

    az login --tenant "<tenant-id>"
    az ad sp show --id fe053c5f-3692-4f14-aef2-ee34fc081cae

    If it's missing, an Entra Application Administrator or Cloud Application Administrator creates it:

    az ad sp create --id fe053c5f-3692-4f14-aef2-ee34fc081cae

    These identifiers are for Azure public cloud. Verify the app ID and audience before you use another cloud.

    Azure API Connections First Party application enabled in Microsoft Entra

     

  3. An app registration for your agent or app. This is the caller. It must be a confidential client (secret, certificate, or federated credential) in the same tenant as your users. Public clients and app-only tokens don't qualify. In its API permissions:

    1. Select Add a permission, then APIs my organization uses, and search for Azure API Connections (or the application ID above).
    2. Select Delegated permissions, then Runtime.All (scope ID 6c3012bf-22c1-4bb5-959b-dff738314144).
    3. Select Grant admin consent for your tenant.
Enterprise Application Registration that will be used to configure the MCP server using per-user authentication.

You will also need The users or groups who'll use the agent. You need their object IDs from the Microsoft Entra admin center.

Walkthrough: an agent that only sees your files

The scenario: an HR policy agent that searches SharePoint document libraries. Two employees ask the same question. Each gets answers only from files they can open.

Step 1: Create the MCP connector

  1. Open your namespace in the portal at connectors.azure.com and select MCP Connectors.
  2. Create a new MCP connector, pick the SharePoint Online connector and select an existing connector or create a new one
  3. Under authentication, select Per-user authentication.
  4. Under tools select the tools you want to expose.
    1. Get file content
    2. Get file metadata
    3. Get file properties
    4. List folder
    5. List root folder

The portal uses your own sign-in to read the connector's operations while it builds the tools. At runtime, each user gets their own connection.

Per-user authentication mode selected, with the calling application and allowed users.

Pick the mode carefully. It's fixed once set. To switch modes, you recreate the MCP connector.

Resulting MCP showing selected tools

Step 2: Add access policies

In the MCP connector, select Access Policies, then + Add Access Policy, and add two policies:

  • Application, with your app registration's client ID and tenant ID.
  • User or Group, with the object ID and tenant ID.

Watch the IDs. Applications use the client (application) ID, users and groups use the object ID, and swapping them gets the policy rejected.

Connector MCP

Step 3: Get a delegated token in your app

Your agent backend already receives a user token for its own API. Exchange it with MSAL's on-behalf-of flow for the Runtime.All scope:

 
var app = ConfidentialClientApplicationBuilder
    .Create(clientId)
    .WithClientSecret(clientSecret) // or a certificate or federated credential
    .WithAuthority($"https://login.microsoftonline.com/{tenantId}")
    .Build();

var result = await app
    .AcquireTokenOnBehalfOf(
        new[] { "https://apihub.azure.com/Runtime.All" },
        new UserAssertion(incomingUserToken))
    .ExecuteAsync();

If your app signs the user in directly, request the same scope during sign-in instead. Either way, the token should have audience https://apihub.azure.com and scope Runtime.All.

Step 4: Call the MCP endpoint

Copy the MCP endpoint URL from the MCP connector's overview. Don't build it from the resource name. Send the token as a bearer token:

POST <mcp-endpoint-url>
Authorization: Bearer <delegated-token>
Content-Type: application/json

{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}

Step 5: Handle first-time consent

The first time a user calls a tool, they haven't connected to SharePoint yet. The response is HTTP 200 with a JSON-RPC error:

{"jsonrpc":"2.0","id":"<request-id>","error":{"code":-32001,"message":"<consent-required-message>","data":{"url":"<consent-url>","connectorName":"sharepointonline","connectionId":"<connection-id>"}}}

Show the user a sign-in action that opens error.data.url, then retry the call. Don't treat HTTP 200 as success on its own. If your MCP client supports URL elicitation, turn on consent elicitation in the MCP connector settings and you'll get an elicitation/create request instead.

Before you build: what to know

  • One connector per MCP connector. Group tools by connector.
  • Same-tenant users only. Guest and cross-tenant users aren't supported yet.
  • Consent is per user, per connector. Design your client for the consent response from day one.

Feedback

I want to know where this breaks for you. Point it at the connector your agent depends on most, run it as two different users, and tell me what you see. File issues and requests at GitHub Issues. That list decides what we build next.

Updated Nov 14, 2026
Version 1.0
No CommentsBe the first to comment