使用说明
SharePoint MCP服务器
免责声明:此项目与微软公司无关、不受微软公司认可或与之无关。SharePoint和Microsoft Graph API是Microsoft Corporation的商标。这是一个独立的、由社区驱动的项目。
SharePoint模型上下文协议(MCP)服务器充当桥梁,使LLM应用程序(如Claude)能够访问SharePoint网站的内容。使用此项目,您可以使用自然语言查询SharePoint网站中的文档、列表和其他内容。
特性
- 浏览文档库:查看SharePoint文档库的内容
- 访问列表数据:检索和操作SharePoint列表数据
- 检索文档内容:访问特定文档中的内容
- SharePoint搜索:搜索整个网站
- 创建列表项:将新项目添加到SharePoint列表
先决条件
- Python 3.10或更高版本
- 访问SharePoint网站
- Microsoft Azure AD应用程序注册(用于身份验证)
快速入门
按照以下步骤快速启动并运行SharePoint MCP服务器:
-
先决条件
- 确保您已安装Python 3.10+
- 具有适当权限的Azure AD应用程序(请参阅docs/auth_guide.md)
-
安装
# Install from GitHub pip install git+https://github.com/DEmodoriGatsuO/sharepoint-mcp.git # Or install in development mode git clone https://github.com/DEmodoriGatsuO/sharepoint-mcp.git cd sharepoint-mcp pip install -e . -
配置
# Copy the example configuration cp .env.example .env # Edit the .env file with your details nano .env -
运行诊断工具
# Check your configuration python config_checker.py # Test authentication python auth-diagnostic.py -
启动服务器
python server.py
安装
- 克隆存储库:
git clone https://github.com/DEmodoriGatsuO/sharepoint-mcp.git
cd sharepoint-mcp
- 创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- 安装依赖项:
pip install -r requirements.txt
- 设置环境变量:
cp .env.example .env
# Edit the .env file with your authentication details
配置
- 在Azure AD中注册应用程序并授予必要的权限(请参阅docs/auth_guide.md)
- 在中配置您的身份验证信息和SharePoint网站URL
.env文件
用法
以开发模式运行
mcp dev server.py
在Claude桌面中安装
mcp install server.py --name "SharePoint Assistant"
直接运行
python server.py
高级用法
处理文件内容
# Example of retrieving document content
import requests
# Get document content
response = requests.get(
"http://localhost:8080/sharepoint-mcp/document/Shared%20Documents/report.docx",
headers={"X-MCP-Auth": "your_auth_token"}
)
# Process content
if response.status_code == 200:
document_content = response.json()
print(f"Document name: {document_content['name']}")
print(f"Size: {document_content['size']} bytes")
使用SharePoint列表
# Example of retrieving list data
import requests
import json
# Get list items
response = requests.get(
"http://localhost:8080/sharepoint-mcp/list/Tasks",
headers={"X-MCP-Auth": "your_auth_token"}
)
# Create a new list item
new_item = {
"Title": "Review quarterly report",
"Status": "Not Started",
"DueDate": "2025-05-01"
}
create_response = requests.post(
"http://localhost:8080/sharepoint-mcp/list/Tasks",
headers={
"X-MCP-Auth": "your_auth_token",
"Content-Type": "application/json"
},
data=json.dumps(new_item)
)
与克劳德融合
请参阅中的文档 docs/usage.md 了解如何将此服务器与Claude和其他LLM应用程序一起使用的详细示例。
监控和故障排除
日志
默认情况下,服务器会登录到stdout。集 DEBUG=True 在你的 .env 文件以启用详细日志记录。
常见问题
- 身份验证失败:运行
python auth-diagnostic.py诊断问题 - 权限错误:确保您的Azure AD应用程序具有所需的权限
- 令牌问题:使用
python token-decoder.py分析令牌的声明
许可证
该项目在MIT许可证下发布。有关详细信息,请参阅LICENSE文件。
贡献
欢迎捐款。在进行重大修改之前,请先打开一个问题,讨论您想更改什么。看 贡献.md 作为指导方针。
