Skip to main content

MCP Server to integrate with SharePoint

Project description

SharePoint MCP Server

License: MIT PyPI version

A comprehensive MCP Server for seamless integration with Microsoft SharePoint, enabling MCP clients to interact with documents, folders and other SharePoint resources. Built with efficiency and ease of use in mind, supporting both text and binary file operations. Developed by sofias tech.

SharePoint Server MCP server

✨ Key Features

This server provides a clean, efficient interface to SharePoint resources through the Model Context Protocol (MCP), with optimized operations for document management and content processing.

🛠️ Available Tools

The server implements 10 comprehensive tools for complete SharePoint management:

📁 Folder Management

  • List_SharePoint_Folders: Lists all folders in a specified directory or root
  • Create_Folder: Creates new folders in specified directories
  • Delete_Folder: Safely deletes empty folders from SharePoint
  • Get_SharePoint_Tree: Gets a recursive tree view of SharePoint folder structure

📄 Document Management

  • List_SharePoint_Documents: Fetches all documents within a specified folder with metadata
  • Get_Document_Content: Retrieves and processes document content (supports text extraction from PDF, Word, Excel)
  • Upload_Document: Uploads new documents to specified folders (supports both text and binary content)
  • Upload_Document_From_Path: Direct file upload from local filesystem for large files
  • Update_Document: Updates content of existing documents
  • Delete_Document: Removes documents from specified folders

🎯 Advanced Content Processing

The server includes intelligent content extraction capabilities:

  • 📊 Excel Files: Extracts data from all sheets, converts to readable text format (first 50 rows per sheet)
  • 📝 Word Documents: Processes paragraphs and tables, maintaining structure
  • 📄 PDF Files: Full text extraction using PyMuPDF for accurate content parsing
  • 📃 Text Files: Direct processing of various text formats (JSON, XML, HTML, MD, code files)
  • 🔧 Binary Support: Base64 encoding/decoding for seamless binary file handling

🏗️ Architecture

The server is built with resource efficiency and maintainability in mind:

  • Efficient SharePoint API usage with selective property loading to minimize bandwidth
  • Smart error handling through decorators for cleaner, more reliable code
  • Clear separation of concerns between resource management and tool implementation
  • Optimized content handling for both text and binary files with automatic type detection
  • Configurable tree operations with depth limits and batch processing for large directories
  • Async/await support throughout for non-blocking operations

Setup

  1. Register an app in Azure AD with appropriate SharePoint permissions
  2. Obtain the client ID and client secret for the registered app
  3. Identify your SharePoint site URL and the document library path you want to work with

Environment Variables

The server requires these environment variables:

Required Variables

  • SHP_ID_APP: Your Azure AD application client ID
  • SHP_ID_APP_SECRET: Your Azure AD application client secret
  • SHP_SITE_URL: The URL of your SharePoint site
  • SHP_DOC_LIBRARY: Path to the document library (default: "Shared Documents/mcp_server")
  • SHP_TENANT_ID: Your Microsoft tenant ID

Optional Configuration Variables

  • SHP_MAX_DEPTH: Maximum folder depth for tree operations (default: 15)
  • SHP_MAX_FOLDERS_PER_LEVEL: Maximum folders to process per level (default: 100)
  • SHP_LEVEL_DELAY: Delay in seconds between processing levels (default: 0.5)

Quickstart

Installation

pip install -e .

Or install from PyPI once published:

pip install mcp-sharepoint-server

Using uv:

uv pip install mcp-sharepoint-server

Claude Desktop Integration

To integrate with Claude Desktop, update the configuration file:

On Windows: %APPDATA%/Claude/claude_desktop_config.json On macOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json

Standard Integration

"mcpServers": {
  "sharepoint": {
    "command": "mcp-sharepoint",
    "env": {
      "SHP_ID_APP": "your-app-id",
      "SHP_ID_APP_SECRET": "your-app-secret",
      "SHP_SITE_URL": "https://your-tenant.sharepoint.com/sites/your-site",
      "SHP_DOC_LIBRARY": "Shared Documents/your-folder",
      "SHP_TENANT_ID": "your-tenant-id",
      "SHP_MAX_DEPTH": "15",
      "SHP_MAX_FOLDERS_PER_LEVEL": "100",
      "SHP_LEVEL_DELAY": "0.5"
    }
  }
}

Using uvx

"mcpServers": {
  "sharepoint": {
    "command": "uvx",
    "args": [
      "mcp-sharepoint"
    ],
    "env": {
      "SHP_ID_APP": "your-app-id",
      "SHP_ID_APP_SECRET": "your-app-secret",
      "SHP_SITE_URL": "https://your-tenant.sharepoint.com/sites/your-site",
      "SHP_DOC_LIBRARY": "Shared Documents/your-folder",
      "SHP_TENANT_ID": "your-tenant-id",
      "SHP_MAX_DEPTH": "15",
      "SHP_MAX_FOLDERS_PER_LEVEL": "100",
      "SHP_LEVEL_DELAY": "0.5"
    }
  }
}

Development

Requirements

  • Python 3.10+
  • Dependencies listed in requirements.txt and pyproject.toml

Local Development

  1. Clone the repository
  2. Create a virtual environment:
    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install development dependencies:
    pip install -e .
    
  4. Create a .env file with your SharePoint credentials:
    SHP_ID_APP=your-app-id
    SHP_ID_APP_SECRET=your-app-secret
    SHP_SITE_URL=https://your-tenant.sharepoint.com/sites/your-site
    SHP_DOC_LIBRARY=Shared Documents/your-folder
    SHP_TENANT_ID=your-tenant-id
    
  5. Run the server:
    python -m mcp_sharepoint
    

Debugging

For debugging the MCP server, you can use the MCP Inspector:

npx @modelcontextprotocol/inspector -- python -m mcp_sharepoint

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2025 sofias tech

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_sharepoint-0.1.7.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_sharepoint-0.1.7-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_sharepoint-0.1.7.tar.gz.

File metadata

  • Download URL: mcp_sharepoint-0.1.7.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for mcp_sharepoint-0.1.7.tar.gz
Algorithm Hash digest
SHA256 8fa67628d8ea83d19e653324c4384549d5f62c86ffacd2bd97f162f0b00c23db
MD5 e7ff900d3560af40d42a1f358fa4a41b
BLAKE2b-256 085e12b420c7289d7814fd1b9a5b63ed87ed4900a6b36f902633ef4cfb3c2869

See more details on using hashes here.

File details

Details for the file mcp_sharepoint-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: mcp_sharepoint-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for mcp_sharepoint-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cfd0847e9d16d6536f6ea5a2679ae18919cd1ece50f569ab9461ccebf9b6b6be
MD5 d65deeeb3b6ffb013ecf836300212bc0
BLAKE2b-256 282f77b36572b7cf6cb2091891e6eb7289662f99722aba675b7acf72d6469938

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page