sharepoint-mcp-server
SharePoint MCP Server is an enterprise-ready Model Context Protocol (MCP) server built with C# .NET 9. It enables local AI models (such as Ollama, Qwen, and Llama) to securely connect to Microsoft SharePoint and query document libraries, site metadata, and files via the Microsoft Graph API without exposing enterprise data to public clouds.
README
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
- .NET 9 SDK
- Ollama installed locally
- Microsoft Entra ID (Azure AD) Tenant with Application Permissions to SharePoint/Graph API
โ๏ธ 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"
}
}
}
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.