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
访问服务器

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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选