SiYuan Note MCP Server

SiYuan Note MCP Server

site icon
2025.04.01 6
TypeScript笔记管理文档操作内容块控制文件和资源管理SQL 查询支持属性管理导出和转换系统功能开发效率
SiYuan Note MCP Server 是一个 MCP 服务器实现,提供与思源笔记系统的集成,使 AI 模型能够访问和操作笔记数据。它支持笔记本管理、文档操作、内容块控制、文件和资源管理、SQL 查询支持、属性管理、导出和转换等多种功能。
View on GitHub

Overview

基本能力

产品定位

SiYuan Note MCP Server 是一个 MCP 服务器实现,提供与思源笔记系统的集成,使 AI 模型能够访问和操作笔记数据。

核心功能

  • 笔记本管理 | Notebook Management
  • 文档操作 | Document Operations
  • 内容块控制 | Block Control
  • 文件和资源管理 | File and Asset Management
  • SQL 查询支持 | SQL Query Support
  • 属性管理 | Attribute Management
  • 导出和转换 | Export and Conversion
  • 系统功能 | System Functions

适用场景

  • AI 模型与思源笔记系统的集成
  • 自动化笔记管理
  • 批量文档操作
  • 内容块控制与管理
  • 文件和资源管理
  • SQL 查询与数据检索

工具列表

  • assets.uploadAssets - 上传资源文件 | Upload assets
  • attr.setBlockAttrs - 设置块属性 | Set block attributes
  • attr.getBlockAttrs - 获取块属性 | Get block attributes
  • block.insertBlock - 插入内容块 | Insert a block
  • block.updateBlock - 更新内容块 | Update block content
  • block.deleteBlock - 删除内容块 | Delete a block
  • block.moveBlock - 移动内容块 | Move a block
  • block.getBlockKramdown - 获取块的 Markdown 内容 | Get block Kramdown content
  • convert.pandoc - 使用 Pandoc 转换内容 | Convert content using Pandoc
  • export.exportNotebook - 导出笔记本 | Export notebook
  • export.exportDoc - 导出文档 | Export document
  • file.getFile - 获取文件内容 | Get file content
  • file.putFile - 写入文件内容 | Put file content
  • file.removeFile - 删除文件 | Remove file
  • file.readDir - 读取目录内容 | List files in directory
  • filetree.createDocWithMd - 使用 Markdown 创建文档 | Create document with Markdown
  • filetree.renameDoc - 重命名文档 | Rename document
  • filetree.removeDoc - 删除文档 | Remove document
  • filetree.moveDocs - 移动文档 | Move documents
  • filetree.getHPathByPath - 获取文档可读路径 | Get document HPath by path
  • filetree.getHPathByID - 通过 ID 获取文档可读路径 | Get document HPath by ID
  • network.forwardProxy - 网络请求代理 | Forward proxy request
  • notebook.lsNotebooks - 列出所有笔记本 | List all notebooks
  • notebook.openNotebook - 打开笔记本 | Open notebook
  • notebook.closeNotebook - 关闭笔记本 | Close notebook
  • notebook.renameNotebook - 重命名笔记本 | Rename notebook
  • notebook.createNotebook - 创建笔记本 | Create notebook
  • notebook.removeNotebook - 删除笔记本 | Remove notebook
  • notebook.getNotebookConf - 获取笔记本配置 | Get notebook configuration
  • notebook.setNotebookConf - 设置笔记本配置 | Set notebook configuration
  • notification.pushMsg - 发送消息通知 | Push message notification
  • notification.pushErrMsg - 发送错误通知 | Push error message notification
  • query.sql - 执行 SQL 查询 | Execute SQL query
  • query.block - 通过 ID 查询块 | Query block by ID
  • search.fullTextSearch - 全文搜索 | Full text search
  • sql.sql - 执行 SQL 查询 | Execute SQL query
  • system.getBootProgress - 获取启动进度 | Get boot progress
  • system.getVersion - 获取系统版本 | Get system version
  • system.getCurrentTime - 获取当前时间 | Get current time
  • template.renderTemplate - 渲染模板 | Render template
  • template.renderSprig - 渲染 Sprig 模板 | Render Sprig template

常见问题解答

  • 需要配置 SIYUAN_TOKEN 环境变量以进行 API 认证
  • 在思源笔记设置 - 关于 中查看 API 令牌

使用教程

使用依赖

  • Node.js >= 23.10.0
  • pnpm

安装教程

  1. 安装依赖 | Install dependencies:
pnpm install
  1. 设置环境变量 | Set environment variables:
# Windows
set SIYUAN_TOKEN=your-siyuan-token

# Linux/macOS
export SIYUAN_TOKEN=your-siyuan-token
  1. 启动服务 | Start service:
pnpm start

Docker 运行 | Docker Run

docker run --rm -i \
  -e SIYUAN_TOKEN=your-siyuan-token \
  mcp/siyuan

调试方式

  • 使用 help 命令查询详细说明,例如:
{
  "type": "help",
  "params": {
    "type": "block.insertBlock"
  }
}

本地构建 | Local Build

pnpm build

Docker 构建 | Docker Build

docker build -t mcp/siyuan .

许可证

该项目遵循 ISC 开源许可条款,请参阅 ISC 了解完整条款。