# Building MCP servers with Entra ID and pre-authorized clients

DevFeed: [Building MCP servers with Entra ID and pre-authorized clients](<https://devfeed.tech/articles/building-mcp-servers-with-entra-id-and-pre-authorized-clients-21749.md>)

Original publisher: [Read original article](<http://blog.pamelafox.org/2026/04/building-mcp-servers-with-entra-id-and.html>)

Author: Pamela Fox (noreply@blogger.com)

Published: 2026-04-02T23:44:00Z

Content type: tutorial

Language: en

Sources: [Pamela Fox](<https://devfeed.tech/sources/pamela-fox.md>)

Topics: [Model Context Protocol](<https://devfeed.tech/topics/model-context-protocol.md>), [Entra ID](<https://devfeed.tech/topics/entra-id.md>), [OAuth](<https://devfeed.tech/topics/oauth.md>), [Python](<https://devfeed.tech/topics/python.md>), [vs-code](<https://devfeed.tech/topics/vs-code.md>), [Security](<https://devfeed.tech/topics/security.md>)

Tags: [entra-id](<https://devfeed.tech/tags/entra-id.md>), [mcp](<https://devfeed.tech/tags/mcp.md>), [model-context-protocol](<https://devfeed.tech/tags/model-context-protocol.md>), [oauth](<https://devfeed.tech/tags/oauth.md>), [python](<https://devfeed.tech/tags/python.md>), [security](<https://devfeed.tech/tags/security.md>), [vs-code](<https://devfeed.tech/tags/vs-code.md>)

## AI overview

This tutorial explains how to build a Python MCP server with FastMCP that authenticates users with Microsoft Entra ID when they connect through a pre-authorized client such as VS Code. It outlines the MCP authorization flow, OAuth 2.1 roles, and why arbitrary-client support may require an OAuth proxy.

## Source excerpt

The Model Context Protocol (MCP) gives AI agents a standard way to call external tools, but things get more complicated when those tools need to know who the user is. In this post, I'll show how to build an MCP server with the Python FastMCP package that authenticates users with Microsoft Entra ID when they connect from a pre-authorized client such as VS Code. If you need to build a server that works with any MCP clients, read my previous blog post. With Microsoft Entra as the authorization server, supporting arbitrary clients currently requires adding an OAuth proxy in front, which increases security risk. This post focuses on the simpler pre-authorized-client path instead. MCP auth Let's start by digging into the MCP auth spec, since that explains both the shape of the flow and the constraints we run into with Entra. The MCP specification includes an authorization protocol based on OAuth 2.1, so an MCP client can send a request that includes a Bearer token from an authorization server, and the MCP server can validate that token. In OAuth 2.1 terms, the MCP client is acting as the OAuth client, the MCP server is the resource server, the signed-in user is the resource owner, and the authorization server issues an access token. In this case, Entra will be our authorization server. We can't necessarily use any OAuth-compatible authorization servers, as MCP auth requires more than just the core OAuth 2.1 functionality. In OAuth, the authorization server needs a relationship with the client. MCP auth describes three options: Pre-registration: the auth server has a pre-existing relationship and has the client ID in its database already CIMD (Client Identity Metadata Document): the MCP client sends the URL of its CIMD, a JSON document that describes its attributes, and the auth server bases its interactions on that information. DCR (Dynamic Client Registration): when the auth server sees a new client, it explicitly registers it and stores the client information in its own