How to Configure a SharePoint App Registration for an MCP Server
A SharePoint App Registration for an MCP server is a Microsoft Entra ID identity that authorizes a Model Context Protocol server to read and index SharePoint document libraries using application credentials. Setting up this connection requires configuring tenant IDs, client secrets, and Microsoft Graph permissions. While broad scopes create tenant-wide risk, scoping with Sites.Selected or routing through an indexed workspace enables secure document access for autonomous AI agents.
Why Autonomous AI Agents Require Dedicated SharePoint App Registrations
Connecting an autonomous AI agent directly to enterprise SharePoint document libraries breaks immediately when the connection depends on an interactive human user login. Model Context Protocol (MCP) servers executing inside background daemon processes, continuous integration runners, or developer terminal sessions cannot respond to interactive browser authentication prompts, conditional access device checks, or rotating session cookies. The moment an interactive session expires, tool execution halts, leaving agent tasks unfinished.
A SharePoint App Registration for an MCP server is a Microsoft Entra ID identity that authorizes a Model Context Protocol server to read and index SharePoint document libraries using application credentials.
Understanding this architecture requires examining how the Model Context Protocol interacts with Microsoft Entra ID (formerly Azure Active Directory) and the Microsoft Graph API. The Model Context Protocol provides an open standard that allows large language models to interact with external tools, file repositories, and databases through structured JSON-RPC messages. Rather than embedding custom REST clients or bespoke SharePoint SDK code inside an agent runtime, the client connects to an MCP server that advertises capabilities such as reading drive items, searching site collections, and listing folder contents.
The Identity and Authorization Chain
Four distinct architectural components participate in this authentication boundary:
- The MCP Client: The environment running the AI assistant, such as Claude Desktop, Cursor, Claude Code, VS Code, or an autonomous backend framework.
- The MCP Server: A local or hosted runtime that exposes tools to the client, parses incoming JSON-RPC tool calls, and translates them into REST requests against Microsoft Graph.
- Microsoft Entra ID: The identity provider and OAuth 2.0 authorization server that authenticates client identities, evaluates directory policies, and issues cryptographically signed JSON Web Tokens (JWTs).
- Microsoft Graph API: The REST gateway (
https://graph.microsoft.com/v1.0/) that governs access to SharePoint Online sites, document libraries, lists, and drive items.
When an AI agent invokes an action like sharepoint_read_document, the MCP server does not prompt the user for a password. Instead, it contacts the Microsoft identity platform token endpoint (https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token) and requests an access token using OAuth 2.0 credentials. Once acquired, the MCP server passes that token as an Authorization: Bearer <token> header on every request to Microsoft Graph.
Delegated Permissions versus Application Permissions
Selecting the OAuth grant type determines how the MCP server interacts with corporate security controls:
- Delegated Permissions (Interactive User Context): The MCP server operates on behalf of a signed-in person. Token acquisition relies on the OAuth 2.0 Authorization Code flow with PKCE or Device Code flow. The issued token includes both an identity claim (
upnoroid) and a scope claim (scp). The agent can only read files that the signed-in human is allowed to view. This model works for desktop assistants where an engineer is present to complete a browser login prompt, but it fails for unattended automations. - Application Permissions (Service Principal): The MCP server operates as an autonomous background service without an interactive user session. Token acquisition uses the OAuth 2.0 Client Credentials Grant (
grant_type=client_credentials). The token contains a roles claim (roles) identifying the application identity rather than an individual employee. The server authenticates using an Application (client) ID and a client secret or certificate.
Application permissions eliminate interactive login prompts for autonomous AI agents connecting to SharePoint. However, configuring this machine-to-machine identity requires configuring tenant ID, client ID, client secret, and Graph API permission scopes with precision to avoid exposing the entire tenant.
Core Credentials Required for MCP Server Configuration
To establish an unattended connection between an MCP server and SharePoint Online, administrators must configure four essential values:
- Directory (Tenant) ID: A GUID identifying your Microsoft 365 tenant instance. The MCP server uses this identifier to construct the correct OAuth 2.0 token authority URL.
- Application (Client) ID: A unique GUID assigned to the registered application object within Microsoft Entra ID. This value acts as the public username for the service principal.
- Client Secret: A cryptographic string generated within the registration that acts as the service principal password. In high-assurance environments, teams can replace client secrets with X.509 certificates.
- Microsoft Graph Permission Scopes: Pre-configured application roles, such as
Sites.SelectedorSites.Read.All, that define what document resources the service principal can access after token acquisition.
Related guides
- SharePoint MCP Server GitHub Repos vs. Managed Remote WorkspacesA SharePoint MCP server GitHub repository provides open-source reference implementations that expose Microsoft Graph...
- How to Connect Cloudflare R2 to AI Agents via MCP ServerA Cloudflare R2 MCP server connects AI agents directly to Cloudflare S3-compatible R2 object storage for reading,...
- How to Connect MCP Agents to a SharePoint Document LibraryA SharePoint Document Library MCP connection allows AI assistants to interact directly with a scoped repository of...
- How to Connect ChatGPT to OneDrive Using MCPConnecting OpenAI models to enterprise document stores requires moving beyond brittle local folder scripts. A ChatGPT...
- Microsoft 365 MCP Server: Connecting Agents to OneDrive and SharePointA Microsoft 365 MCP server connects AI coding assistants to OneDrive and SharePoint repositories via the Model Context...
- How to Deploy MCP Server on RenderLearn how to deploy MCP servers on Render with git-based updates and zero downtime. This guide covers Docker setup,...
More on this subject: MCP and Model Context Protocol (274 guides)
How to Configure a SharePoint App Registration for an MCP Server
Setting up an Entra ID app registration for an MCP server requires an administrative identity with permission to create applications and grant directory-level consent. In most corporate tenants, creating the application requires the Application Administrator or Cloud Application Administrator role, while approving permissions requires Global Administrator or Privileged Role Administrator approval.
Follow this 5-step numbered configuration checklist for setting up the Entra ID App Registration:
- Register the application in Microsoft Entra admin center: Navigate to the Microsoft Entra admin center (
entra.microsoft.com), open Identity > Applications > App registrations, and select New registration. - Record the Directory (tenant) ID and Application (client) ID: Open the application Overview page and copy both GUID values to your secure deployment store.
- Generate a client secret under Certificates & secrets: Navigate to Certificates & secrets, select New client secret, define a description and expiration window, and copy the secret Value immediately.
- Configure Microsoft Graph API permissions: Navigate to API permissions, select Add a permission > Microsoft Graph > Application permissions, and select your required scopes (such as
Sites.SelectedorSites.Read.All). - Grant tenant administrator consent: Select Grant admin consent for {Tenant Name} at the top of the API permissions pane to activate the selected scopes.
Each step in this checklist establishes a component of the trust chain between your agent runtime and Microsoft Graph.
Setting Identity Parameters and Account Types
When creating the registration in step 1, provide a recognizable name that reflects the service function, such as SharePoint-MCP-Connector. Under Supported account types, choose Accounts in this organizational directory only (Single tenant). Selecting a single-tenant configuration restricts the application identity to your company directory, preventing external Microsoft 365 tenants from authenticating against the registration.
Leave the Redirect URI setting blank. Because autonomous MCP servers run as background daemons using the OAuth 2.0 client credentials grant, token requests occur via back-channel HTTP POST calls directly to the token endpoint. A redirect URI is only required when configuring interactive delegated flows that return authorization codes through a browser redirect.
Generating and Managing Client Secrets
In step 3, creating a client secret provides the credential the MCP server sends to prove its identity. Microsoft Entra ID allows secret lifetimes of up to 24 months. For production agent deployments, selecting an expiration of 180 or 365 days balances operational continuity with credential hygiene.
Enter a descriptive label indicating the host environment, such as mcp-prod-service-2026. Once you click Add, Entra ID generates two values: a Secret ID and a Secret Value. Copy the Value string immediately. Entra ID permanently masks this string once you refresh or leave the view. If you lose the value, you must generate a new secret and update all connected MCP server instances.
Configuring the MCP Server Environment Variables
After recording your credentials, populate the environment block of your MCP server configuration. In standard client configuration files, such as .cursor/mcp.json or claude_desktop_config.json, the registration details are passed as environment variables to the server process:
{
"mcpServers": {
"sharepoint": {
"command": "node",
"args": ["/path/to/sharepoint-mcp/build/index.js"],
"env": {
"TENANT_ID": "<tenant-id>",
"CLIENT_ID": "<client-id>",
"CLIENT_SECRET": "<client-secret>",
"SHAREPOINT_SITE_URL": "https://example.sharepoint.com/sites/engineering"
}
}
}
}
When the MCP server starts, it reads these variables, initiates an OAuth 2.0 token exchange with Microsoft Entra ID, and prepares its file discovery tools.
Microsoft Graph Permissions: Sites.Selected versus Sites.Read.All
Most online tutorials give broad tenant-wide permissions (Sites.Read.All) without explaining least-privilege Sites.Selected scoping or the maintenance burden compared to managed sync. This pattern represents a critical security gap in AI agent integration.
When you configure Microsoft Graph permissions for an application registration, the scopes you select dictate the access boundary of every AI agent connected to that MCP server. Granting excessive scopes exposes company data to model hallucination, unintended retrieval, or prompt injection exploits. Selecting the correct permission model requires understanding how Microsoft Graph evaluates application tokens against SharePoint document hierarchies. Microsoft Entra ID separates scopes into interactive delegated contexts and autonomous application contexts, each carrying distinct administrative consent requirements and tenant risk profiles.
The Danger of Tenant-Wide Scopes
When an administrator grants Sites.Read.All or Files.Read.All with application permissions, the MCP server receives read access to every single SharePoint site collection and OneDrive account across the entire Microsoft 365 tenant. This includes executive leadership portals, confidential human resources archives, legal dispute files, payroll documentation, and internal audit notes.
Large language models connected to MCP servers with Sites.Read.All can retrieve documents from any library if a user prompt triggers a broad search query. If an agent processes an adversarial prompt or misinterprets an instruction, it can surface confidential corporate records that the person prompting the model has no authorization to inspect in their daily role.
Enforcing Least Privilege with Sites.Selected
The Sites.Selected scope provides an enterprise-grade mechanism to enforce least privilege. When granted in the Entra ID admin center, Sites.Selected gives the application registration access to zero SharePoint sites by default. Even after a Global Administrator grants admin consent, any Graph API call attempting to read files returns an HTTP 403 Forbidden error until an administrator explicitly binds the application to an approved site collection.
Microsoft Graph provides selected scopes to restrict application access to designated SharePoint site collections rather than the entire tenant. This architecture confines the MCP server to specific project libraries, protecting sensitive corporate sites from unintended inspection.
Granting Site-Level Permissions via Microsoft Graph API and PowerShell
To grant an application access to a specific site collection under Sites.Selected, an administrator must make a direct REST call to Microsoft Graph or run a PowerShell script.
To use the Microsoft Graph API, send an HTTP POST request to the site permissions endpoint:
POST https://graph.microsoft.com/v1.0/sites/{site-id}/permissions
Content-Type: application/json
Authorization: Bearer <admin-access-token>
{
"roles": ["read"],
"grantedToIdentities": [
{
"application": {
"id": "<client-id>",
"displayName": "SharePoint-MCP-Server"
}
}
]
}
The {site-id} value is retrieved by querying GET https://graph.microsoft.com/v1.0/sites/{tenant-domain}.sharepoint.com:/sites/{site-name}.
Administrators managing access via PnP PowerShell can execute the assignment in a single command:
Connect-PnPOnline -Url "https://example.sharepoint.com/sites/engineering" -Interactive
Grant-PnPAzureADAppSitePermission -AppId "<client-id>" -DisplayName "SharePoint-MCP-Server" -Permissions Read
This command binds the service principal to the engineering site collection with read-only rights. The MCP server can inspect files in that library while remaining blocked from the rest of the SharePoint tenant.
Permission Scopes and Access Radius Comparison
The following table compares the Microsoft Graph permission scopes evaluated for SharePoint MCP servers:
The Operational Toll of Running Direct SharePoint MCP Connectors
While setting up an Entra ID app registration connects an MCP server to SharePoint, operating direct Graph API connectors in production introduces significant performance, cost, and maintenance burdens. Engineering teams frequently discover that direct API connections struggle under autonomous agent workloads.
Graph API Throttling and Concurrency Limits
Microsoft Graph enforces strict rate limits to protect SharePoint Online infrastructure. Graph monitors request volume across tenants and application IDs. When an autonomous AI agent indexes large document libraries, crawls subfolders, or runs concurrent multi-agent tool loops, Graph issues HTTP 429 (Too Many Requests) responses accompanied by Retry-After headers.
Standard MCP servers often handle rate limits poorly. If an agent hits a 429 response while traversing directory trees, the tool call fails or times out. In multi-agent environments where several developers run local MCP instances using the same client ID, collective request volume quickly exhausts tenant API quotas, causing agent workflows to stall across the entire team.
Payload Bloat and Context Window Saturation
SharePoint document libraries contain complex enterprise files, including formatted Word documents, dense PDF reports, Excel workbooks, and PowerPoint decks. When an MCP server reads these files directly through the Graph API, it pulls raw binary payloads over HTTP and extracts text locally.
Passing full document contents directly into large language model context windows consumes tens of thousands of tokens per query. Most agent tasks only require specific passages, such as a paragraph from a project specification or a table from an operational guideline. Direct SharePoint MCP servers lack native vector search or chunked semantic retrieval, forcing the model to process massive text dumps. This increases prompt token costs, inflates execution latency, and causes models to lose track of key instructions inside bloated contexts.
Credential Rotation and Local Configuration Debt
Managing client secrets across a distributed engineering team creates configuration sprawl. When dozens of developers store tenant credentials in local .env files or desktop client configurations, security oversight deteriorates.
Client secrets expire on set schedules. When an enterprise secret expires, every developer's local MCP server fails simultaneously, disrupting ongoing engineering workflows. Rotating credentials requires distributing new secrets to every team member, creating operational friction and increasing the probability that secrets are accidentally committed to version control repositories.
Search Inefficiencies in Native SharePoint APIs
Querying document libraries through native Microsoft Graph search endpoints (/v1.0/search/query) presents significant latency challenges for interactive agents. Graph search relies on SharePoint search schemas and crawl cadences. When newly uploaded files arrive in SharePoint, they can take minutes or hours to appear in Graph search results.
Graph search queries return broad metadata objects that require subsequent API calls to retrieve file content. For an AI agent executing multi-turn reasoning loops, waiting hundreds of milliseconds for each Graph query compounds response times, turning simple research queries into multi-minute operations.
Connect AI Agents to Enterprise Storage Without Token Limits
Keep your files in SharePoint, sync document libraries to an intelligent Fast.io workspace, and let agents query indexed context through remote MCP. Monthly plans include a 14-day free trial.
Architectural Alternative: Offloading SharePoint Sync to Fast.io Workspaces
To eliminate the maintenance burden of client secrets, Graph API rate limits, and context window saturation, teams can adopt an architectural pattern that separates storage from agent retrieval. The team keeps their existing storage in SharePoint, while an intelligent workspace layer handles indexing and agent access.
In this architecture, enterprise files remain in their authoritative SharePoint document libraries. Rather than pointing local MCP servers directly at Microsoft Graph with sensitive tenant credentials, document libraries sync into a Fast.io workspace.
Fast.io Cloud Sync connects Google Drive, Dropbox, Box and OneDrive folders to a workspace, one-way or two-way, on a schedule or on demand. SharePoint document libraries connect through the OneDrive connector, syncing designated corporate folders into the workspace without real-time overhead.
+--------------------------+ Cloud Sync (Scheduled) +-----------------------+
| SharePoint Online Libs | =================================> | Fast.io Workspace |
| (Existing Enterprise) | | (Intelligence Mode) |
+--------------------------+ +-----------------------+
|
| Streamable HTTP
v
+-----------------------+
| Remote MCP Server |
| (Remote MCP Tools) |
+-----------------------+
|
| Semantic Context
v
+-----------------------+
| AI Coding Agents |
| (Cursor, Claude, etc) |
+-----------------------+
Remote MCP Access Over Streamable HTTP
Instead of running local MCP server daemons that require local client secrets, AI agents connect directly to Fast.io's remote MCP server over Streamable HTTP:
- Claude Applications and General Clients: Connect at
https://mcp.fast.io/mcp/tools. - Coding Agents (Cursor, Claude Code, Cline, Devin): Connect at
https://mcp.fast.io/mcp/code. - ChatGPT and Codex Custom Servers: Connect at
https://mcp.fast.io/mcp/operations(or install the Fastio plugin directly).
Setup steps and tooling specifications are documented at Fast.io MCP documentation. In published connector benchmarks, Fastio was measured the fastest and the lowest cost of the providers tested.
Built-in Intelligence Mode and Structured Extraction
When files arrive in a Fast.io workspace, Intelligence Mode auto-indexes content for hybrid search (combining full-text, semantic meaning, and metadata values). When an AI agent needs information from a corporate document, it queries the workspace through MCP and receives precise, citation-backed text passages rather than full binary files. This eliminates token bloat and reduces context saturation.
For structured documents such as vendor agreements, invoices, or project specs, Metadata Views extract natural-language fields into structured schemas (Text, Integer, Decimal, Boolean, URL, JSON, Date & Time) without OCR templates. Agents can inspect structured metadata across hundreds of files with a single tool call.
Enterprise Governance Without Tenant Credential Sprawl
Consolidating agent file access inside an intelligent workspace strengthens security governance:
- Role-Based Access Control: Permissions are set per organization, workspace, and share through member roles, preventing unintended file exposure.
- Detailed Activity Log: A detailed activity log records storage modifications (uploads, edits, moves, deletions) and permission changes across humans and agents.
- Per-File Version History: Every document keeps a full version history, allowing teams to review concurrent modifications and restore earlier states.
Monthly plans start with a 14-day free trial that requires a credit card:
Storage and seats come with the plan, while credits meter AI operations.
Best Practices for Securing MCP Credentials and Monitoring Access
When engineering teams choose to maintain direct SharePoint app registrations, implementing strict credential management and telemetry monitoring prevents accidental exposure and policy violations.
Isolating Credentials in Dedicated Environment Stores
Never store client secrets in plain text inside local project directories, shell histories, or shared configuration repositories. When deploying MCP servers on developer machines, load credentials from secure credential stores or system keychains:
- Use environment variable files (
.env) excluded from version control via.gitignore. - Enforce file system permissions that restrict read access to the local user account (
chmod 600 .env). - Where supported by deployment infrastructure, replace client secrets with X.509 certificates or Azure Managed Identities. Certificates eliminate shared secret strings and simplify automated rotation.
Monitoring Microsoft Entra Sign-In Telemetry
Administrators must actively monitor authentication events for the MCP application registration within the Microsoft Entra admin center:
- Open Identity > Monitoring & health > Sign-in logs.
- Select the Service principal sign-ins tab.
- Filter by your application name or Client ID.
- Review the IP addresses, timestamps, and conditional access status of token requests.
Anomalous spikes in token issuance or token requests originating from unexpected geographic locations or untrusted IP ranges indicate credential leakage, requiring immediate secret revocation.
Auditing Microsoft Graph Resource Access
To track what documents AI agents inspect, configure diagnostic logging in Microsoft Entra and SharePoint:
- Enable Microsoft 365 Unified Audit Logging to record file access, download, and modification events across SharePoint Online.
- Route Microsoft Graph activity logs into Azure Log Analytics or your security information and event management (SIEM) platform.
- Set alert thresholds for bulk download events. If an MCP server attempts to read hundreds of files outside typical working hours, automated security rules can suspend the service principal.
Regularly review assigned permission scopes and remove inactive client secrets to maintain an auditable, least-privilege identity perimeter.
Sources
References used to verify factual claims in this guide.
-
Microsoft Graph provides selected scopes to restrict application access to designated SharePoint site collections rather than the entire tenant.
Frequently Asked Questions
How do I register an app in Azure AD for SharePoint MCP?
To register an app in Azure AD (Microsoft Entra ID) for a SharePoint MCP server, sign in to the Microsoft Entra admin center, navigate to Applications > App registrations, and select New registration. Choose a single-tenant account type, leave the redirect URI blank, and create the registration. Next, generate a client secret under Certificates & secrets, add Microsoft Graph application permissions (such as Sites.Selected or Sites.Read.All) under API permissions, and have a Global Administrator grant tenant admin consent.
What permissions does an MCP server need for SharePoint?
For autonomous, unattended AI agents, an MCP server requires Microsoft Graph application permissions. The recommended least-privilege scope is Sites.Selected, which grants zero access until an administrator binds the app to specific site collections. For broader, unconstrained access across all corporate sites, tutorials often use Sites.Read.All and Files.Read.All, though this exposes the entire tenant to the agent.
What is the difference between Sites.Selected and Sites.Read.All for MCP?
Sites.Read.All is a tenant-wide application permission that gives the MCP server read access to every SharePoint site collection, document library, and executive portal in the organization. In contrast, Sites.Selected grants zero access across the tenant until an administrator explicitly assigns read or write roles to designated site collections using Microsoft Graph permissions endpoints or PowerShell.
How do I grant an MCP server access to a specific SharePoint site using Sites.Selected?
After granting admin consent for Sites.Selected in Microsoft Entra ID, an administrator must call the Microsoft Graph API endpoint POST /sites/{site-id}/permissions with the application Client ID and the desired role (such as read). Alternatively, administrators can run the PnP PowerShell command Grant-PnPAzureADAppSitePermission -AppId <client-id> -DisplayName <app-name> -Permissions Read targeting the specific SharePoint site URL.
Why does my SharePoint MCP server fail with HTTP 429 Too Many Requests?
Microsoft Graph enforces concurrency and rate limits per tenant and application. When an autonomous AI agent traverses document hierarchies, crawls large libraries, or runs parallel tool calls across multiple developer sessions, it exhausts Graph API request quotas. Microsoft Graph responds with HTTP 429 Too Many Requests and a Retry-After header, requiring callers to back off.
Can I connect an MCP server to SharePoint without storing client secrets locally?
Yes. Instead of running a local MCP server that requires storing tenant client secrets on developer workstations, teams can sync SharePoint document libraries into a Fast.io workspace using Cloud Sync. AI agents then connect to Fast.io's remote MCP server over Streamable HTTP, querying indexed document context securely without local tenant credentials.
Related Resources
Connect AI Agents to Enterprise Storage Without Token Limits
Keep your files in SharePoint, sync document libraries to an intelligent Fast.io workspace, and let agents query indexed context through remote MCP. Monthly plans include a 14-day free trial.