SharePoint MCP: The .NET MCP Server with Graph API & Semantic Kernel
Create MCP server for accessing SharePoint Online
mhmd2015
README
SharePoint MCP: The .NET MCP Server with Graph API & Semantic Kernel
In the modern enterprise, accessing specific data securely and efficiently is crucial, especially when integrating with AI capabilities. Imagine a chatbot that can not only converse intelligently but also fetch relevant documents or information directly from your organization's SharePoint sites. This post outlines a modular architecture using .NET, Microsoft Graph API, Semantic Kernel, and Gemini AI to achieve just that.
This project composed of three distinct modules:
- The MCP Server (Semantic Kernel): The brain of our SharePoint interaction.
- The SharePoint Connector Library: The hands reaching into SharePoint Online.
- The MCP Client (Gemini AI): The user-facing chat interface.
Let's break down each module:
Module 1: The .NET MCP Server (Leveraging Semantic Kernel)
This core component acts as the central hub and API endpoint. Built using .NET, we're incorporating Semantic Kernel here. While it could be a standard ASP.NET Core Web API, using Semantic Kernel allows us to potentially define the SharePoint interaction as a native "skill" or "plugin".
Expose functionality (like SharePoint search) via an API endpoint that the client can call. Orchestrate calls to the Connector Library, using .NET (e.g., ASP.NET Core Web API), Semantic Kernel SDK. Key Function: Define an API route (e.g., /api/sharepoint/search) that accepts search queries. This route will invoke the function within our Connector Library. Using Semantic Kernel allows this function to be easily integrated into more complex AI reasoning flows if needed later.
Module 2: SharePoint Connector Library (Graph API)
This .NET library is solely responsible for the nitty-gritty details of communicating with SharePoint Online.
Purpose: Authenticate with Microsoft Graph and execute specific SharePoint actions, starting with search. Technology: .NET Standard or .NET Core Library, Microsoft.Graph SDK. Authentication: Uses Client ID and Client Secret (App-Only Authentication). Setup: Requires registering an application in Azure Active Directory (Azure AD), granting it the necessary Graph API permissions (e.g., Sites.Read.All or more granular permissions depending on your needs), and obtaining admin consent. Crucially, store your Client Secret securely (e.g., Azure Key Vault, .NET User Secrets) – never hardcode it! Key Function: An asynchronous function (e.g., SearchSharePointAsync(string query)) that: Uses the Client ID and Secret to obtain an access token for Microsoft Graph. Constructs a Graph API request to the SharePoint search endpoint (/search/query). Sends the request using the Microsoft.Graph SDK. Parses the response and returns the relevant search results (e.g., document names, links, snippets).
Module 3: The MCP Client (Gemini AI)
This is the application your users interact with. It features a chat interface powered by Gemini AI.
Purpose: Provide an AI-driven conversational experience. Detect user intent related to SharePoint and delegate those tasks to the MCP Server. Technology: Any client platform (.NET MAUI, Blazor, Console App, etc.), Google AI Gemini SDK. Functionality: User chats with the Gemini-powered interface. The client application (or potentially Gemini itself, depending on implementation) analyzes the conversation. When keywords or intent related to "SharePoint" (or specific document types, sites, etc.) are detected, the client makes an HTTP request to the MCP Server's API endpoint (e.g., /api/sharepoint/search) with the relevant query. It receives the search results from the server and presents them back to the user within the chat context. Workflow Example:
User: "Hey Gemini, can you find the Q1 marketing report on SharePoint?" MCP Client: Detects "SharePoint" and "Q1 marketing report". MCP Client: Sends POST /api/sharepoint/search with query "Q1 marketing report" to the MCP Server. MCP Server: Receives request, calls SearchSharePointAsync("Q1 marketing report") in the Connector Library. Connector Library: Authenticates with Graph API using Client ID/Secret, performs the search /search/query. SharePoint Online: Returns search results. Connector Library: Returns formatted results to the MCP Server. MCP Server: Returns results in the API response to the MCP Client. MCP Client: Displays the results (e.g., "I found these documents: [Link 1], [Link 2]") within the Gemini chat interface. Benefits:
Modular Design: Clear separation of concerns makes development and maintenance easier. Secure Access: App-only authentication ensures controlled access to SharePoint data without user impersonation in the backend. AI Integration: Seamlessly blends conversational AI with enterprise data retrieval. Extensible: Easily add more SharePoint functions (uploading, listing files, etc.) to the Connector Library and expose them via the MCP Server.
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.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.
Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.