SharePoint MCP Server

SharePoint MCP Server

A Model Context Protocol server for SharePoint file and folder management using Microsoft Graph API. Enables listing, uploading, downloading, and converting documents with markdown-to-DOCX support.

Category
访问服务器

README

SharePoint MCP Server

A TypeScript MCP (Model Context Protocol) server for SharePoint file and folder management via Microsoft Graph API.

Features

  • 11 MCP tools for complete SharePoint file/folder management
  • Two auth flows: Client Credentials (app-level) and On-Behalf-Of (user-level)
  • Two transports: stdio (for Claude Desktop/CLI) and Streamable HTTP
  • Resumable uploads for large files (>4MB)
  • Content extraction from PDF, Word (.docx), Excel (.xlsx), and text files
  • Markdown-to-DOCX conversion via Pandoc with optional style templates from SharePoint

Quick Start

1. Install dependencies

npm install
npm run build

2. Configure environment

cp .env.example .env
# Edit .env with your Azure AD and SharePoint details

Required environment variables:

  • AZURE_TENANT_ID - Azure AD tenant ID
  • AZURE_CLIENT_ID - App registration client ID
  • AZURE_CLIENT_SECRET - App registration client secret
  • SHAREPOINT_HOSTNAME - e.g. yourcompany.sharepoint.com
  • SHAREPOINT_SITE_NAME - e.g. YourSiteName
  • AUTH_FLOW - client_credentials (default) or on_behalf_of

3. Run

stdio transport (for Claude Desktop):

npm start

HTTP transport:

npm run start:http
# Server starts on http://localhost:3000/mcp

Claude Desktop Configuration

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "sharepoint": {
      "command": "node",
      "args": ["/path/to/sharepoint-mcp-nodejs/dist/index.js"],
      "env": {
        "AZURE_TENANT_ID": "your-tenant-id",
        "AZURE_CLIENT_ID": "your-client-id",
        "AZURE_CLIENT_SECRET": "your-client-secret",
        "SHAREPOINT_HOSTNAME": "yourcompany.sharepoint.com",
        "SHAREPOINT_SITE_NAME": "YourSiteName"
      }
    }
  }
}

Available Tools

Tool Description
List_SharePoint_Folders List folders in a directory
Create_Folder Create a new folder
Delete_Folder Delete a folder
Get_SharePoint_Tree Recursive tree view (configurable depth)
List_SharePoint_Documents List documents with metadata
Get_Document_Content Download + extract text (PDF/Word/Excel/text)
Create_Document_From_Markdown Convert markdown/text to .docx with optional style template
Upload_Document Upload from base64 or text content
Upload_Document_From_Path Upload a local file (resumable for >4MB)
Update_Document Update existing document content
Delete_Document Delete a document

Markdown to DOCX Conversion

The Create_Document_From_Markdown tool converts markdown or plain text to a .docx file using Pandoc and uploads it to SharePoint.

Parameters:

  • content (required) — Markdown or plain text to convert
  • folder_path (required) — Destination folder in SharePoint
  • file_name (required) — Output filename (e.g. report.docx)
  • template_path (optional) — Path to a .docx template on SharePoint for styling

Style templates: Create a .docx file in Word with your desired styles (fonts, headings, margins, colors), upload it to SharePoint, then reference it as template_path. Pandoc applies styles from the template to the generated document via --reference-doc.

Testing the Markdown-to-DOCX Tool

Prerequisites: Pandoc must be installed. In Docker this is handled automatically. For local development:

# macOS
brew install pandoc

# Ubuntu/Debian
sudo apt-get install pandoc

# Verify
pandoc --version

Test 1 — Basic conversion (no template):

Using MCP Inspector:

npx @modelcontextprotocol/inspector node dist/index.js

Call Create_Document_From_Markdown with:

{
  "content": "# My Report\n\n## Introduction\n\nThis is a **test** document with:\n\n- Bullet point 1\n- Bullet point 2\n\n## Data\n\n| Name | Value |\n|------|-------|\n| A    | 100   |\n| B    | 200   |",
  "folder_path": "Shared Documents",
  "file_name": "test-report.docx"
}

Then verify with Get_Document_Content:

{
  "file_path": "Shared Documents/test-report.docx"
}

Test 2 — With style template:

  1. Create a styled .docx template in Word (set fonts, heading styles, margins, colors)
  2. Upload it to SharePoint (e.g. via Upload_Document_From_Path or manually)
  3. Call Create_Document_From_Markdown with the template:
{
  "content": "# Styled Report\n\nThis document uses corporate styling.",
  "folder_path": "Shared Documents",
  "file_name": "styled-report.docx",
  "template_path": "Templates/corporate-style.docx"
}

Test 3 — Via curl (HTTP transport):

# Initialize session
curl -s -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"0.1.0"}}}'

# Call the tool (use the mcp-session-id from the response headers above)
curl -s -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "mcp-session-id: <SESSION_ID>" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"Create_Document_From_Markdown","arguments":{"content":"# Hello World\n\nTest document.","folder_path":"Shared Documents","file_name":"curl-test.docx"}}}'

Upload Strategy

  • Files <= 4MB: Simple PUT to /content endpoint
  • Files > 4MB: Resumable upload session with 3.2MB chunks

Auth Flows

Client Credentials (default)

App-level access using client ID + secret. Best for server-to-server scenarios.

On-Behalf-Of (OBO)

User-level access by exchanging a user token. Use with HTTP transport where the client sends a Authorization: Bearer <token> header.

See docs/azure-setup.md for detailed Azure Portal setup instructions.

Docker

After editing .env with your credentials, build and run with:

docker compose up --build -d

The server will be available at http://localhost:3000/mcp.

After making changes to the source, rebuild and restart (the Docker build compiles TypeScript internally):

docker compose up --build -d

To view logs:

docker compose logs -f

Development

npm run dev    # Watch mode for TypeScript compilation

Testing with MCP Inspector

npx @modelcontextprotocol/inspector node dist/index.js

推荐服务器

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 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
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 模型以安全和受控的方式获取实时的网络信息。

官方
精选