OneNote MCP服务器
模型上下文协议(MCP)服务器实现,使Claude和其他LLM等AI语言模型能够与Microsoft OneNote交互。
该项目基于 azure onenote mcp服务器 由Zubeid Hendricks设计,经过修改以简化身份验证并提高可用性。
这有什么作用?
该服务器允许AI助手:
- 访问您的OneNote笔记本、分区和页面
- 在笔记本中创建新页面
- 搜索您的笔记
- 阅读完整的笔记内容,包括HTML格式和文本
- 直接分析和总结您的笔记
所有这些都直接通过AI界面进行,而无需切换上下文。
使用AI助手
光标设置
- 克隆此存储库并按照以下安装步骤进行操作
- 启动MCP服务器:
npm start
- 在Cursor中注册服务器:
- 打开光标首选项(Mac上的Cmd+或Windows上的Ctrl+) - 转到“MCP”选项卡 - 使用以下设置添加新的MCP服务器: - 姓名: onenote - 命令: node - Args: ["/path/to/your/onenote-mcp.mjs"] (使用绝对路径)
以下是完整的JSON配置示例:
{
"mcpServers": {
"onenote": {
"command": "node",
"args": ["/absolute/path/to/your/onenote-mcp.mjs"],
"env": {}
}
}
}- 重新启动游标
- 在Cursor中,您现在可以使用自然语言与OneNote数据交互:
Can you show me my OneNote notebooks?
Create a new page in my first notebook with a summary of this conversation
Find notes related to "project planning" in my OneNote当您第一次询问OneNote时,AI将引导您完成身份验证过程。
Claude Desktop(或其他MCP兼容助手)的设置
- 克隆此存储库并按照以下安装步骤进行操作
- 启动MCP服务器:
npm start
- 在Claude Desktop设置中,添加OneNote MCP服务器:
- 姓名: onenote - 命令: node - Args: ["/path/to/your/onenote-mcp.mjs"] (使用绝对路径)
JSON配置示例:
{
"mcpServers": {
"onenote": {
"command": "node",
"args": ["/absolute/path/to/your/onenote-mcp.mjs"],
"env": {}
}
}
}- 现在,您可以让Claude与您的OneNote数据进行交互
特性
- 使用设备代码流通过Microsoft OneNote进行身份验证(无需Azure设置)
- 列出所有笔记本、分区和页面
- 使用HTML内容创建新页面
- 阅读完整的页面内容,包括HTML格式
- 提取文本内容以进行AI分析和总结
- 在一次操作中汇总所有页面的内容
- 以可读格式阅读所有页面的全部内容
- 在笔记中搜索
安装
先决条件
- Node.js 16或更高版本(从安装 )
- 具有OneNote访问权限的活动Microsoft帐户
- Git(从安装 git-scm.com)
步骤1:克隆存储库
git clone https://github.com/yourusername/onenote-mcp.git
cd onenote-mcp第二步:下载TypeScript SDK
此项目需要MCP TypeScript SDK,需要单独下载:
git clone https://github.com/modelcontextprotocol/typescript-sdk.git
cd typescript-sdk
npm install
npm run build
cd ..步骤3:安装项目依赖项
npm install步骤4:启动MCP服务器
npm start这将启动MCP服务器,您将看到一条消息:
Server started successfully.
Use the "authenticate" tool to start the authentication flow,
or use "saveAccessToken" if you already have a token.步骤5:通过您的AI助手进行身份验证
服务器运行后,您可以直接通过AI助手进行身份验证:
- 在Cursor、Anthropic的Claude Desktop或任何兼容MCP的助手中,要求使用OneNote进行身份验证:
Can you authenticate with my OneNote account?- AI将触发身份验证流程,并为您提供:
- URL(通常为microsoft.com/devicelogin) - 输入代码
- 转到URL,输入代码,然后使用您的Microsoft帐户登录
- 成功身份验证后,您可以开始使用OneNote和您的AI助手
可用的MCP工具
一旦通过身份验证,以下工具可供AI助手使用:
| 工具名称 | 描述 |
|---|---|
authenticate | 启动Microsoft身份验证流程 |
listNotebooks | 获取所有OneNote笔记本的列表 |
getNotebook | 获取特定笔记本的详细信息 |
listSections | 列出笔记本中的所有部分 |
listPages | 列出一个部分中的所有页面 |
getPage | 获取特定页面的完整内容,包括HTML格式 |
createPage | 使用HTML内容创建新页面 |
searchPages | 在笔记本中搜索页面 |
交互示例
以下是您如何通过AI助手与OneNote MCP交互的一些示例:
User: Can you show me my OneNote notebooks?
AI: (uses listNotebooks) I found 3 notebooks: "Work", "Personal", and "Projects"
User: What sections are in my Projects notebook?
AI: (uses listSections) Your Projects notebook has the following sections: "Active Projects", "Ideas", and "Completed"
User: Create a new page in Projects with today's date as the title
AI: (uses createPage) I've created a new page titled "2025-04-12" in your Projects notebook
User: Find all my notes about machine learning
AI: (uses searchPages) I found 5 pages with content related to machine learning...
User: Can you read and summarize my notes on the "Project Requirements" page?
AI: (uses getPage) Based on your "Project Requirements" page, here's a summary: The project requires Python 3.8+, integration with AWS services, and completion by Q3. Key deliverables include a web dashboard, API, and documentation...
User: Extract all the action items from my "Team Meeting" notes
AI: (uses getPage) Here are all the action items from your "Team Meeting" notes:
1. John to complete API documentation by Friday
2. Sarah to schedule design review meeting
3. Team to finalize Q3 roadmap by end of month
User: Summarize content of all my OneNote pages
AI: (runs get-all-page-contents.js) Here's a summary of all your pages:
- Questions: Contains strategic business questions about competitor analysis
- 2025-04-12: Discussion about monetization strategy for bank transfers
- Role Specification: Details about the Chief Payments Officer position
...
User: I want to read through all my OneNote pages so I can ask questions about them
AI: (runs read-all-pages.js) I've retrieved the full content of all your pages in a readable format. Now you can ask me specific questions about any of the content.高级:直接脚本使用
出于测试或开发目的,您还可以直接使用提供的脚本:
# Authenticate with Microsoft
npm run auth
# List your notebooks
npm run list-notebooks
# List sections in your first notebook
npm run list-sections
# List pages in the first section
npm run list-pages
# Create a new page
npm run create-page
# Summarize content of all pages
node get-all-page-contents.js
# Read full content of all pages
node read-all-pages.js故障排除
身份验证问题
- 如果身份验证失败,请确保您使用的是没有跟踪保护的现代浏览器
- 尝试清除浏览器Cookie和缓存
- 如果收到“expired_token”错误,请重新启动身份验证过程
服务器无法启动
- 验证是否安装了Node.js(16+版本):
node --version - 确保安装了所有依赖项:
npm install - 检查TypeScript SDK是否正确构建
AI无法连接到服务器
- 确保MCP服务器正在运行(
npm start) - 检查AI助手的设置,确保其配置为使用MCP
- 对于Cursor,确保它是支持MCP的最新版本
安全说明
- 身份验证令牌存储在本地
.access-token.txt - 令牌授予对OneNote数据的访问权限,因此请确保其安全
- 令牌在一段时间后过期,需要重新验证
- 不需要Azure设置或API密钥
鸣谢
该项目建立在 azure onenote mcp服务器 Zubeid Hendricks,专注于简化身份验证过程,改善人工智能助手的用户体验。
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件

