sharepoint-mcp-server

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.

Category
Visit Server

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

  1. Go to the Microsoft Entra Admin Center (https://entra.microsoft.com/).
  2. Navigate to Identity -> Applications -> App registrations -> New registration.
  3. Name your application (e.g., SharePoint-MCP-Server) and select Single Tenant.
  4. Note the Application (Client) ID and Directory (Tenant) ID.
  5. Under Certificates & secrets, generate a new Client Secret and copy its Value.
  6. Under API permissions, add the following Microsoft Graph Application Permissions:
  • Sites.Read.All
  • Files.Read.All
  1. 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

  1. Domain Onboarding: When prompted, enter your SharePoint tenant URL (e.g., https://yourtenant.sharepoint.com/).
  2. Site Selection: The console runner calls list_sites directly and displays an interactive menu of all accessible sites.
  3. 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 siteId context across multi-turn user queries.

  • Middleware Integration: Utilizes Microsoft.Extensions.AI with .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 JsonElement primitive wrappers.

  • Employs Regex lookahead sanitization to clean composite site IDs without corrupting server-relative URL paths.

  • Deterministic Tool Binding: Configured with Temperature = 0.0f and 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured