Markdown到Notion MCP服务器
该项目是一个模型上下文协议(MCP)服务器,用于将Markdown内容转换为Notion API块。
它使用 @tryfabric/martian 库来解析Markdown并将其转换为与Notion API兼容的格式。
先决条件
- Node.js(v18或更高版本)
安装与使用
使用npx(推荐)
使用此MCP服务器的最简单方法是使用npx,它允许您在不全局安装的情况下运行它:
npx mcp-mdnotion这将自动下载并运行服务器的最新版本。
npx的配置
使用npx时,使用以下设置配置MCP客户端:
对于Claude Desktop(Claude_Desktop_config.json):
{
"mcpServers": {
"markdown-to-notion": {
"command": "npx",
"args": ["mcp-mdnotion"]
}
}
}全球安装
或者,您可以全局安装该软件包:
npm install -g mcp-mdnotion然后配置您的MCP客户端以使用全局安装:
{
"servers": {
"markdown-to-notion": {
"type": "stdio",
"command": "mcp-mdnotion"
}
}
}地方发展
对于本地开发或如果您想修改代码:
- 克隆存储库:
git clone https://github.com/mikamboo/mcp-mdnotion.git
cd mcp-mdnotion- 安装依赖项:
npm install快速开始
- 立即开始使用npx:
npx mcp-mdnotion- 配置您的MCP客户端 (例如,VS Code、Claude Desktop)使用具有上述npx配置的服务器。
- 测试转换:
使用 markdown-to-notion MCP客户端中的工具,用于转换markdown,如下所示:
# Hello World
This is a **bold** paragraph with *italic* text.构建
要生成项目,请运行以下命令:
npm run build这将编译TypeScript代码并输出JavaScript文件 build 目录。
运行服务器
要运行MCP服务器,请执行以下命令:
node build/index.js服务器将启动并监听标准I/O上的请求。
用法
服务器公开了一个工具: markdown-to-notion.
markdown-to-notion
此工具将给定的Markdown字符串转换为Notion块。
输入:
markdown(string):要转换的Markdown内容。
输出:
- 表示Notion块的JSON字符串。
例子:
如果您向服务器发送以下请求:
{
"tool": "markdown-to-notion",
"input": {
"markdown": "# Hello World\n\nThis is a paragraph."
}
}服务器将响应:
{
"content": [
{
"type": "text",
"text": "[\n {\n \"object\": \"block\",\n \"type\": \"heading_1\",\n \"heading_1\": {\n \"rich_text\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"content\": \"Hello World\"\n }\n }\n ]\n }\n },\n {\n \"object\": \"block\",\n \"type\": \"paragraph\",\n \"paragraph\": {\n \"rich_text\": [\n {\n \"type\": \"text\",\n \"text\": {\n \"content\": \"This is a paragraph.\"\n }\n }\n ]\n }\n }\n]"
}
]
}与MCP客户端集成
VS代码与副本
- 创建或更新
.vscode/mcp.json在您的项目中:
{
"servers": {
"markdown-to-notion": {
"type": "stdio",
"command": "npx",
"args": ["mcp-mdnotion"]
}
}
}- 重新启动VS Code或重新加载MCP服务器。
- 使用该工具,要求Copilot将markdown转换为Notion格式。
克劳德桌面
- 打开您的Claude Desktop配置文件:
- 窗户: %APPDATA%\Claude\claude_desktop_config.json - macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - Linux: ~/.config/Claude/claude_desktop_config.json
- 添加服务器配置:
{
"mcpServers": {
"markdown-to-notion": {
"command": "npx",
"args": ["mcp-mdnotion"]
}
}
}- 重新启动克劳德桌面。
其他MCP客户端
对于其他MCP客户端,请使用npx命令配置:
- 命令:
npx - 论据:
["mcp-mdnotion"] - 类型:
stdio
开发与发布
发布到npm
此项目使用GitHub Actions在创建新标签时自动发布到npm。
设置
- 创建一个npm帐户 并获取访问令牌:
- 首选 并创建一个帐户 - 转到npm配置文件中的访问令牌 - 创建新的“自动化”令牌
- 将令牌添加到GitHub Secrets:
- 转到您的GitHub存储库→ 设置→ 秘密和变量→ 行动 - 添加一个名为的新秘密 NPM_TOKEN 使用您的npm令牌值
发布过程
使用内置的npm脚本创建版本:
# For bug fixes (1.0.0 → 1.0.1)
npm run release:patch
# For new features (1.0.0 → 1.1.0)
npm run release:minor
# For breaking changes (1.0.0 → 2.0.0)
npm run release:major这些命令将:
- 更新中的版本
package.json - 创建一个git标签
- 将更改和标签推送到GitHub
- 触发GitHub操作以发布到npm
手工出版
如果您更喜欢手动发布:
npm run build
npm publish参考文献
- https://github.com/tryfabric/martian
- https://modelcontextprotocol.io/quickstart/server
