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"
}
}
}
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。