
Mowen Notes
STDIOMCP server for creating and managing Mowen notes with rich text functionality
MCP server for creating and managing Mowen notes with rich text functionality
这是一个基于**模型上下文协议(MCP)**的服务器,用于与墨问笔记软件进行交互。通过此服务器,你可以在支持MCP的应用(如Cursor、Claude Desktop等)中直接创建、编辑和管理墨问笔记。
本项目由一支烟花社区和墨问合作共创。
{ "mcpServers": { "mowen-mcp-server": { "command": "D:\\mowen\\mowen-mcp-server.exe", "args": [], "env": { "MOWEN_API_KEY": "xxxxxxxxxxxxxxx" } } } }
✨ 最新版本特性:支持文件上传功能!现在可以在笔记中插入图片、音频和PDF文件,支持本地文件和远程URL两种上传方式。
⚠️ 重要:文件路径必须使用绝对路径,因为MCP Server和Client运行在不同的工作目录中。
# 本地图片文件 { "type": "file", "file_type": "image", "source_type": "local", "source_path": "C:\\Users\\用户名\\Documents\\image.jpg", # Windows绝对路径 "metadata": { "alt": "图片描述", "align": "center" } } # 远程音频文件(URL不受路径限制) { "type": "file", "file_type": "audio", "source_type": "url", "source_path": "https://example.com/audio.mp3", "metadata": { "show_note": "00:00 开始\n01:30 主要内容" } }
{ "type": "quote", "texts": [ {"text": "重要提醒:", "bold": true}, {"text": "支持富文本格式的引用段落"} ] }
{ "type": "note", "note_id": "VPrWsE_-P0qwrFUOygGs8" }
git clone https://github.com/z4656207/mowen-mcp-server.git cd mowen-mcp-server
pip install -e .
pip install mcp httpx pydantic
$env:MOWEN_API_KEY="你的墨问API密钥"
export MOWEN_API_KEY="你的墨问API密钥"
创建 .env
文件:
MOWEN_API_KEY=你的墨问API密钥
如果你使用了 pip install -e .
安装,在 Cursor 设置中添加:
{ "mcpServers": { "mowen-mcp-server": { "command": "python", "args": ["-m", "mowen_mcp_server.server"], "env": { "MOWEN_API_KEY": "${env:MOWEN_API_KEY}" } } } }
如果你没有安装包,可以直接指定文件路径:
{ "mcpServers": { "mowen-mcp-server": { "command": "python", "args": ["绝对路径/mowen-mcp-server/src/mowen_mcp_server/server.py"], "env": { "MOWEN_API_KEY": "${env:MOWEN_API_KEY}" } } } }
注意: 请将 绝对路径
替换为你的实际项目路径,例如:
"D:/CODE/mowen-mcp-server/src/mowen_mcp_server/server.py"
"/home/user/mowen-mcp-server/src/mowen_mcp_server/server.py"
创建一篇新的墨问笔记,使用统一的富文本格式
参数:
paragraphs
(数组,必需):富文本段落列表,每个段落包含文本节点auto_publish
(布尔值,可选):是否自动发布,默认为falsetags
(字符串数组,可选):笔记标签列表支持的段落类型:
{"texts": [...]}
{"type": "quote", "texts": [...]}
{"type": "note", "note_id": "笔记ID"}
{"type": "file", "file_type": "image|audio|pdf", "source_type": "local|url", "source_path": "绝对路径", "metadata": {...}}
段落格式示例:
[ { "texts": [ {"text": "普通文本"}, {"text": "加粗文本", "bold": true}, {"text": "高亮文本", "highlight": true}, {"text": "链接文本", "link": "https://example.com"} ] }, { "type": "quote", "texts": [ {"text": "这是引用段落"}, {"text": "支持富文本", "bold": true} ] }, { "type": "note", "note_id": "VPrWsE_-P0qwrFUOygxxx" }, { "type": "file", "file_type": "image", "source_type": "local", "source_path": "C:\\Users\\用户名\\Documents\\image.jpg", "metadata": { "alt": "图片描述", "align": "center" } } ]
简单文本示例:
[ { "texts": [ {"text": "这是一段简单的文本内容"} ] } ]
编辑已存在的笔记内容,使用统一的富文本格式
参数:
note_id
(字符串,必需):要编辑的笔记IDparagraphs
(数组,必需):富文本段落列表,将完全替换原有内容注意: 此操作会完全替换笔记的原有内容,而不是追加内容。支持所有段落类型(普通段落、引用段落、内链笔记、文件段落)。
设置笔记的隐私权限
参数:
note_id
(字符串):笔记IDprivacy_type
(字符串):隐私类型(public/private/rule)no_share
(布尔值,可选):是否禁止分享(仅rule类型有效)expire_at
(整数,可选):过期时间戳(仅rule类型有效,0表示永不过期)重置墨问API密钥
注意: 此操作会使当前密钥立即失效
# 通过MCP工具调用 create_note( paragraphs=[ { "texts": [ {"text": "今天学习了Python编程,重点是异步编程概念"} ] } ], auto_publish=True, tags=["学习", "Python", "编程"] )
# 通过MCP工具调用 create_note( paragraphs=[ { "texts": [ {"text": "重要提醒:", "bold": true}, {"text": "明天的会议已改期"} ] }, { "texts": [ {"text": "详情请查看:", "highlight": true}, {"text": "会议通知", "link": "https://example.com/meeting"} ] } ], auto_publish=True, tags=["会议", "通知"] )
# 通过MCP工具调用 create_note( paragraphs=[ { "texts": [ {"text": "项目进展报告", "bold": true} ] }, { "type": "quote", "texts": [ {"text": "本周完成了主要功能开发,", "highlight": true}, {"text": "详见技术文档", "link": "https://docs.example.com"} ] }, { "type": "note", "note_id": "VPrWsE_-P0qwrFUOygGs8" }, { "texts": [ {"text": "下周计划:开始测试阶段"} ] } ], auto_publish=True, tags=["项目", "进展", "报告"] )
# 通过MCP工具调用 create_note( paragraphs=[ { "texts": [ {"text": "项目截图和演示", "bold": true} ] }, { "type": "file", "file_type": "image", "source_type": "local", "source_path": "C:\\Users\\user\\Desktop\\screenshot.png", "metadata": { "alt": "项目主界面截图", "align": "center" } }, { "texts": [ {"text": "演示视频(音频):"} ] }, { "type": "file", "file_type": "audio", "source_type": "url", "source_path": "https://example.com/demo.mp3", "metadata": { "show_note": "00:00 项目介绍\n01:30 功能演示\n03:00 总结" } }, { "texts": [ {"text": "详细文档见附件:"} ] }, { "type": "file", "file_type": "pdf", "source_type": "local", "source_path": "C:\\Users\\user\\Documents\\project_doc.pdf" } ], auto_publish=True, tags=["项目", "文档", "演示"] )
# 通过MCP工具调用 edit_note( note_id="note_123456", paragraphs=[ { "texts": [ {"text": "更新:", "bold": true}, {"text": "项目进度已完成80%"} ] }, { "type": "quote", "texts": [ {"text": "详细报告请查看:", "highlight": true}, {"text": "项目文档", "link": "https://example.com/report"} ] }, { "type": "note", "note_id": "related_note_id" } ] )
根据墨问API文档,各接口有以下限制:
API | 配额 | 频率限制 | 说明 |
---|---|---|---|
笔记创建 | 100 次/天 | 1次/秒 | 调用成功才计为 1 次,即:每天可以基于 API 创建 100 篇笔记 |
笔记编辑 | 1000 次/天 | 1次/秒 | 调用成功才计为 1 次,即:每天可以基于 API 编辑 1000 次 |
笔记设置 | 100 次/天 | 1次/秒 | 调用成功才计为 1 次 |
mowen-mcp-server/
├── src/
│ └── mowen_mcp_server/
│ ├── __init__.py # 包初始化
│ ├── server.py # MCP服务器主程序
│ └── config.py # 配置管理
├── examples/
│ └── create_note/ # 创建笔记案例
├── pyproject.toml # 项目配置
├── README.md # 项目文档
├── CHANGELOG.md # 更新日志
└── 墨问API.md # 墨问API详细文档
墨问API.md
文件A: 请确保使用 pip install -e .
安装了包,或者使用直接文件路径的配置方式。
A: 登录墨问小程序,在个人主页的开发者模块中找到API密钥,需要Pro会员权限。
A: 目前不支持,只能编辑通过API创建的笔记。
A: 引用段落使用 {"type": "quote", "texts": [...]}
格式,内链笔记使用 {"type": "note", "note_id": "笔记ID"}
格式。引用段落支持所有富文本格式(加粗、高亮、链接)。
A: note_id是创建笔记时返回的笔记ID,或者是墨问中已存在笔记的ID。注意只能引用通过API创建的笔记。
A: 我们统一了接口设计,使用富文本格式可以支持更丰富的内容。即使是简单文本,也可以很容易地使用paragraphs格式:[{"texts": [{"text": "你的文本"}]}]
A: 如果之前使用 create_note(content="文本")
,现在需要改为 create_note(paragraphs=[{"texts": [{"text": "文本"}]}])
。富文本功能保持不变。
A: 必须使用绝对路径。MCP Server和Client运行在不同的工作目录中,相对路径会解析失败。
"C:\\Users\\用户名\\Documents\\image.jpg"
(Windows)"/Users/用户名/Documents/image.jpg"
(macOS/Linux)"./image.jpg"
或 "image.jpg"
(相对路径)A: 支持三种文件类型:
A: 远程URL不受路径格式限制,但文件必须公开可访问,且符合文件类型和大小限制。
欢迎提交Issue和Pull Request!
pip install -e .
本项目采用MIT许可证。详见 LICENSE 文件。
本项目为个人开发的第三方工具,与墨问官方无关。使用前请确保遵守墨问的服务条款。