这是一个基于模型上下文协议(MCP)的服务器,用于与Mowen笔记软件进行交互。通过此服务器,您可以在MCP支持的应用程序中直接创建、编辑和管理墨迹笔记,如cursor、Claude Desktop等。
该项目由烟花社区和Mowen共同创建。
{
"mcpServers": {
"mowen-mcp-server": {
"command": "D:\\mowen\\mowen-mcp-server.exe",
"args": [],
"env": {
"MOWEN_API_KEY": "xxxxxxxxxxxxxxx"
}
}
}
}
✨ 最新版本特性:支持文件上传功能!现在您可以将图像、音频和PDF文件插入到您的笔记中,支持本地文件和远程URL上传方式。
⚠️ 重要提示:文件路径必须使用绝对路径因为MCP服务器和客户端运行在不同的工作目录下。
# 本地图片文件
{
"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 .安装并添加:
{
"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"使用统一的富文本格式创建新的Mowen笔记
参数
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表示永不过期)重置Mojin 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"
}
]
)
根据Mowen 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: 登录Mojin小程序,在个人主页的开发者模块中找到API密钥。需要Pro会员权限。
A: 目前不支持,只能编辑通过API创建的笔记。
A: 使用引用段落{"type": "quote", "texts": [...]}格式,内部链接笔记使用{"type": "note", "note_id": "笔记ID"}格式。引用段落支持所有富文本格式(加粗、高亮、链接)。
A: note_id是在创建笔记时返回的笔记ID,或者Mowen中已存在的笔记ID。请注意,只有通过API创建的笔记才能被引用。
A: 我们统一了接口设计,使用富文本格式来支持更丰富的内容。即使是简单的文本也可以轻松地在段落中格式化:[{"texts": [{"text": "你的文本"}]}]
A: 如果之前使用的是create_note(content="文本"),现在需要改为create_note(paragraphs=[{"texts": [{"text": "文本"}]}]),富文本功能保持不变。
A: 必须使用绝对路径MCP服务器和客户端运行在不同的工作目录下,相对路径解析可能会失败。
"C:\\Users\\用户名\\Documents\\image.jpg" (Windows)"/Users/用户名/Documents/image.jpg" (macOS/Linux)"./image.jpg" 或 "image.jpg" (相对路径)A: 支持三种类型的文件:
A: 远程URL不受路径格式限制,但文件必须公开访问并符合文件类型和大小限制。
欢迎提交Issue和Pull Requests!
pip install -e .本项目采用MIT许可证。详情见LICENSE文档。
本项目是由个人开发的第三方工具,与官方Mowen平台无关。请在使用前确保遵守Mowen的服务条款。