kl-sharepoint-mcp

kl-sharepoint-mcp

Enables interaction with SharePoint Online and OneDrive content via Microsoft Graph, supporting device-code authentication for multi-account environments.

Category
Visit Server

README

Microsoft 365 (SharePoint & OneDrive) MCP Server

License: MIT

A modern Model Context Protocol (MCP) server that lets ChatGPT (and other MCP compatible clients) interact with SharePoint Online and OneDrive content using Microsoft Graph. The server is designed for environments where multiple Microsoft 365 accounts may exist on the same workstation: each session can authenticate with the signed-in Windows/Microsoft account that the user chooses at runtime.

Why this fork? The original SharePoint-only implementation relied on application credentials tied to a specific tenant. This version embraces user-centric authentication (device code flow + MSAL cache) so the connector works with whichever account is selected on the machineβ€”ideal for teams that share GPT licenses but want to access their own SharePoint/OneDrive resources.

Feature Highlights

  • πŸ” Device-code authentication – Pick the Microsoft account that is signed into the local machine instead of the ChatGPT account.
  • πŸ‘₯ Multi-account aware – List cached accounts, switch between them, and inspect the active context at any time.
  • πŸ—‚οΈ Drive discovery – Enumerate OneDrive personal drives and SharePoint document libraries.
  • πŸ“„ Full file lifecycle – Create folders, upload/update files (text or binary), download contents, and delete resources.
  • πŸ” Deep research – Perform scoped searches inside a drive or global Microsoft Graph Search across SharePoint + OneDrive.
  • πŸ“š Site exploration – Search for SharePoint sites and list their document libraries before activating one.

MCP Tools Overview

Tool Purpose
Start_Device_Login / Complete_Device_Login Initiate and complete the device-code flow for the desired Microsoft account.
List_Available_Accounts / Set_Active_Account Inspect cached accounts and pick which one is active.
Get_Auth_Context / Get_Graph_Context Debug helpers showing the current authentication + drive context.
List_My_Drives / List_Site_Drives / Search_SharePoint_Sites Discover drives and sites available to the active account.
Set_Active_Drive Choose the OneDrive or SharePoint library used for subsequent operations.
List_Drive_Items, Get_Drive_Item_Metadata, Get_Drive_Item_Content Explore the selected drive and read file contents.
Create_Drive_Folder, Upload_Drive_File, Update_Drive_File, Delete_Drive_Item Create, modify, and remove items.
Search_Drive_Items Search inside the currently-selected drive.
Deep_Search_Microsoft365 Perform a Microsoft Graph Search across SharePoint and OneDrive resources for deep research scenarios.

All tools automatically reuse the selected Microsoft account and drive context.

Prerequisites

  1. Azure AD App Registration – Register a public client application (no secret) in Azure AD / Entra ID.
    • Redirect URI can be https://login.microsoftonline.com/common/oauth2/nativeclient.
    • Required delegated permissions: Files.ReadWrite.All, Sites.ReadWrite.All, User.Read, and optionally others you need.
  2. Client ID – Note the Application (client) ID of the registration.
  3. Python 3.10+ – A recent Python interpreter for running the MCP server.

Configuration

The server is configured with environment variables (you can store them in a .env file during development):

Variable Description
MCP_GRAPH_CLIENT_ID Required. Client ID of the Azure AD public application (fallback: SHP_ID_APP).
MCP_GRAPH_TENANT_ID Optional. Tenant ID to restrict sign-ins. Defaults to common for multi-tenant.
MCP_GRAPH_SCOPES Optional comma-separated scopes. Defaults to Files.ReadWrite.All,Sites.ReadWrite.All,User.Read,offline_access.
MCP_GRAPH_CACHE_PATH Optional custom path for the MSAL token cache. Default: ~/.cache/mcp_sharepoint/token_cache.bin.
MCP_GRAPH_DEFAULT_DRIVE_ID Optional drive ID to auto-select on startup.
MCP_GRAPH_LOG_LEVEL / MCP_GRAPH_LOG_FILE Optional logging settings.

Quickstart

Installation

pip install -e .

Running the server

python -m mcp_sharepoint

Integrate the binary into your MCP-aware client (ChatGPT desktop, Claude Desktop, MCP Inspector, etc.) by referencing the script mcp-sharepoint (created via the console script entry point) or by executing python -m mcp_sharepoint directly.

First-time authentication workflow

  1. Call Start_Device_Login from your MCP client.
  2. Follow the verification_uri and user_code provided to authenticate with the Microsoft account currently logged into the workstation.
  3. Call Complete_Device_Login with the returned flow_id to finish the sign-in.
  4. (Optional) Use List_Available_Accounts and Set_Active_Account to switch between cached profiles.
  5. Discover drives with List_My_Drives or List_Site_Drives, then select one using Set_Active_Drive.
  6. You are ready to browse, search, and modify files using the rest of the tools.

Development

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e .

Use the MCP Inspector to debug traffic:

npx @modelcontextprotocol/inspector -- python -m mcp_sharepoint

License

This project is released under the MIT License.

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