sharepoint-mcp-server
Here is the complete text formatted inside a single code block. You can click the "Copy" button at the top-right corner of the block to copy everything in one click:
# SharePoint MCP Server & AI Orchestrator (.NET 9)
An end-to-end local AI-driven SharePoint orchestrator that connects a local LLM (**Ollama**) to Microsoft SharePoint via the **Model Context Protocol (MCP)** and **Microsoft Graph API**.
---
## ๐๏ธ Architecture Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 1. Natural Language Prompt โโโโโโโโโโโโโโโโโโโโโโโโโ
โ Console AI Orchestrator โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ>โ Ollama (qwen2.5:1.5b) โ
โ (SharePointMcpClient) โ <โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ (Local GPU Inference) โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโ 2. Tool Call Request (JSON) โโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โ 3. Execute Tool via MCP (CallToolAsync)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ C# SharePoint MCP Server โ โโโ> Microsoft Graph API โโโ> SharePoint Online
โ (SharePointMcpServer Web API)โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
---
## ๐ Repository Structure
```text
.
โโโ SharePointMcpServer/ # ASP.NET Core Web API implementing MCP Server tools
โ โโโ Controllers/ # MCP endpoints (/mcp)
โ โโโ Services/ # SharePoint Graph API service methods
โ โโโ appsettings.json # Azure Entra ID configuration
โ
โโโ SharePointMcpClient/ # .NET 9 Console App (AI Orchestrator)
โโโ Program.cs # Interactive CLI with automatic tool invocation
๐ Prerequisites
Ollama installed locally
Microsoft Entra ID (Azure AD) Tenant with Application Permissions to SharePoint/Graph API
Related MCP server: m365-mcp-server
โ๏ธ Setup & Configuration
1. Microsoft Entra ID (Azure AD) Setup
Go to the Microsoft Entra Admin Center (
https://entra.microsoft.com/).Navigate to Identity -> Applications -> App registrations -> New registration.
Name your application (e.g.,
SharePoint-MCP-Server) and select Single Tenant.Note the Application (Client) ID and Directory (Tenant) ID.
Under Certificates & secrets, generate a new Client Secret and copy its Value.
Under API permissions, add the following Microsoft Graph Application Permissions:
Sites.Read.AllFiles.Read.All
Click Grant admin consent for [Your Organization].
2. Configure Server (SharePointMcpServer)
Open SharePointMcpServer/appsettings.json and enter your Azure AD credentials:
"AzureEntra": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "",
"ClientId": "",
"ClientSecret": "",
"Scopes": [ "https://graph.microsoft.com/.default" ]
},
3. Setup Ollama Model
Pull the recommended lightweight model for fast local tool execution (~1.2 GB VRAM footprint):
ollama pull qwen2.5:1.5b
Tip (Disk Space Optimization): To store Ollama models on a secondary drive (e.g.,
D:\OllamaModels), set the environment variable:setx OLLAMA_MODELS "D:\OllamaModels"
๐ Running the Solution
Step 1: Start the MCP Server
Navigate to the server directory and run:
cd SharePointMcpServer
dotnet run
The server will start listening at https://localhost:7149 (or your configured port).
Step 2: Start the AI Orchestrator Console App
In a separate terminal, navigate to the client directory and run:
cd SharePointMcpClient
dotnet run
๐ฌ Usage Flow
Domain Onboarding: When prompted, enter your SharePoint tenant URL (e.g.,
https://yourtenant.sharepoint.com/).Site Selection: The console runner calls
list_sitesdirectly and displays an interactive menu of all accessible sites.Natural Language Querying: Select a site index (e.g.,
1), then ask questions naturally without manually supplying site IDs:
[Main Site] User > list libraries
[Main Site] User > show recent documents
[Main Site] User > search documents for 'invoice'
๐ ๏ธ Key Technical Features
Interactive Site Context Management: Automatically discovers tenant sites and retains active
siteIdcontext across multi-turn user queries.Middleware Integration: Utilizes
Microsoft.Extensions.AIwith.UseFunctionInvocation()middleware for automatic two-way execution between Ollama and MCP tools.Defensive Parameter Normalization:
Handles key casing remappings (e.g.,
site_id->siteId).Unwraps
JsonElementprimitive wrappers.Employs Regex lookahead sanitization to clean composite site IDs without corrupting server-relative URL paths.
Deterministic Tool Binding: Configured with
Temperature = 0.0fand strict context limits for accurate schema mapping.
๐งช Testing Endpoints Directly via Postman
You can test MCP endpoints directly via HTTP POST to https://localhost:7149/mcp:
Payload Example (list_libraries):
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "list_libraries",
"arguments": {
"siteId": "yourtenant.sharepoint.com,guid-1,guid-2"
}
}
}
This server cannot be installed
Maintenance
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ashishsurve353/SharePointMcpClient'
If you have feedback or need assistance with the MCP directory API, please join our Discord server