SharePoint MCP Server

SharePoint MCP Server

Enables browsing and interacting with Microsoft SharePoint sites and documents through Microsoft Graph API, supporting file search, site listing, document library browsing, and file content retrieval with OAuth2 authentication.

Category
访问服务器

README

SharePoint MCP Server

A Model Context Protocol server for browsing and interacting with Microsoft SharePoint sites and documents.

This TypeScript-based MCP server provides comprehensive SharePoint integration through Microsoft Graph API, enabling:

  • Resources: Access SharePoint sites as MCP resources with structured metadata
  • Tools: Search files, list sites, browse document libraries, and retrieve file content
  • Authentication: Secure OAuth2 client credentials flow with automatic token management

Features

Resources

  • List SharePoint sites accessible to the application
  • Access individual site information via sharepoint://site/{siteId} URIs
  • JSON-formatted site metadata with display names and web URLs

Tools

search_files

Search for files and documents across SharePoint using Microsoft Graph Search API

  • Parameters:
    • query (required): Search query string
    • limit (optional): Maximum results to return (default: 10)

list_sites

List SharePoint sites accessible to the application

  • Parameters:
    • search (optional): Filter sites by display name

get_site_info

Get detailed information about a specific SharePoint site

  • Parameters:
    • siteUrl (required): SharePoint site URL (e.g., https://tenant.sharepoint.com/sites/sitename)

list_site_drives

List document libraries (drives) in a SharePoint site

  • Parameters:
    • siteUrl (required): SharePoint site URL

list_drive_items

List files and folders in a SharePoint document library

  • Parameters:
    • siteUrl (required): SharePoint site URL
    • driveId (optional): Specific drive ID (uses default drive if not specified)
    • folderPath (optional): Folder path to list items from (default: root)

get_file_content

Get the content of a specific file from SharePoint (text files only)

  • Parameters:
    • siteUrl (required): SharePoint site URL
    • filePath (required): Path to the file
    • driveId (optional): Specific drive ID (uses default drive if not specified)

Prerequisites

Azure App Registration

  1. Register an application in Azure Active Directory
  2. Configure API permissions:
    • Microsoft Graph: Sites.Read.All (Application permission)
    • Microsoft Graph: Files.Read.All (Application permission)
  3. Grant admin consent for the permissions
  4. Create a client secret

Environment Variables

Set the following environment variables:

SHAREPOINT_URL=https://yourtenant.sharepoint.com
TENANT_ID=your-azure-tenant-id
CLIENT_ID=your-azure-app-client-id
CLIENT_SECRET=your-azure-app-client-secret

Development

Install dependencies:

npm install

Build the server:

npm run build

For development with auto-rebuild:

npm run watch

Testing

Test the server using the MCP Inspector:

npm run inspector

The Inspector provides a web interface to test all available tools and resources.

Installation

Claude Desktop Configuration

Add the server to your Claude Desktop configuration:

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

{
  "mcpServers": {
    "sharepoint-mcp-server": {
      "command": "node",
      "args": ["/path/to/sharepoint-mcp-server/build/index.js"],
      "env": {
        "SHAREPOINT_URL": "https://yourtenant.sharepoint.com",
        "TENANT_ID": "your-azure-tenant-id",
        "CLIENT_ID": "your-azure-app-client-id",
        "CLIENT_SECRET": "your-azure-app-client-secret"
      }
    }
  }
}

Global Installation

You can also install the server globally:

npm install -g .

Then use it directly:

sharepoint-mcp-server

Architecture

The server implements a service-oriented architecture with clear separation of concerns:

  • Authentication Layer: Handles OAuth2 token acquisition and refresh
  • Graph API Client: Manages HTTP requests to Microsoft Graph API
  • Tool Handlers: Process MCP tool requests and format responses
  • Resource Handlers: Manage SharePoint site resources and metadata
  • Error Handling: Comprehensive error management with proper MCP error codes

Security Considerations

  • Uses OAuth2 client credentials flow for secure authentication
  • Tokens are automatically refreshed before expiration
  • All API requests use HTTPS
  • Client secrets should be stored securely and never committed to version control
  • Application permissions require admin consent in Azure AD

Troubleshooting

Common Issues

  1. Authentication Errors: Verify Azure app registration and permissions
  2. Site Access: Ensure the app has appropriate SharePoint permissions
  3. Network Issues: Check firewall settings for Microsoft Graph API access

Debug Mode

Set environment variable for detailed logging:

DEBUG=sharepoint-mcp-server

Contributing

  1. Follow TypeScript best practices
  2. Maintain comprehensive error handling
  3. Add tests for new functionality
  4. Update documentation for API changes

License

This project is licensed under the Mozilla Public License 2.0. See the LICENSE file for details.

Contributing

We welcome contributions! Please follow these guidelines:

Getting Started

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass (npm test)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices and maintain type safety
  • Implement comprehensive error handling with proper MCP error codes
  • Add JSDoc comments for all public methods and classes
  • Maintain the service-oriented architecture with clear separation of concerns
  • Follow SOLID principles and keep functions focused and testable
  • Update documentation for any API changes

Code Style

  • Use TypeScript strict mode
  • Follow the existing code formatting and naming conventions
  • Remove unused imports and variables
  • Use descriptive variable and function names
  • Prefer composition over inheritance

Testing

  • Add unit tests for new functionality
  • Test error conditions and edge cases
  • Ensure the basic test suite passes
  • Test with real SharePoint environments when possible

Documentation

  • Update README.md for new features or configuration changes
  • Add JSDoc comments for new public APIs
  • Include examples for complex functionality
  • Update the changelog for significant changes

Changelog

[0.1.0] - Initial Release

  • Basic SharePoint integration via Microsoft Graph API
  • Support for searching files across SharePoint
  • Site listing and browsing capabilities
  • Document library access and file content retrieval
  • OAuth2 client credentials authentication
  • MCP resource support for SharePoint sites
  • Comprehensive error handling and logging

Support

If you encounter issues or have questions:

  1. Check the troubleshooting section in this README
  2. Search existing GitHub issues
  3. Create a new issue with detailed information about your problem
  4. Include relevant logs and configuration (without sensitive information)

Acknowledgments

  • Built with the Model Context Protocol SDK
  • Uses Microsoft Graph API for SharePoint integration
  • Inspired by the MCP community and ecosystem

推荐服务器

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

官方
精选