Token导航 LogoToken导航

MCP Server · 文档知识

Siyuan MCP Extended

为思源笔记提供模型上下文协议(MCP)服务,支持AI助手与思源笔记的无缝交互。

stdio官方级别未说明来源级核验工具 32@porkll/siyuan-mcp
知识管理开发工具TypeScriptClaude协议服务Claude DesktopCursor

快速开始

作者 / 组织
jjdunlop
提供方
jjdunlop
运行时
Node.js

工具数量

32

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

Siyuan MCP Extended 属于文档知识类 MCP Server,公开资料标注 32 个工具,通过stdio 本地进程接入,适配 Claude Desktop、Claude、Cursor,有可以直接复制的安装命令;接入前要先准备 访问 Token。

分类

文档知识

传输方式

stdio

认证方式

访问 Token

部署方式

公开资料未说明

安装与配置

安装命令

npx @porkll/siyuan-mcp

客户端配置示例

{
  "mcpServers": {
    "siyuan-mcp-extended": {
      "command": "npx",
      "args": [
        "@porkll/siyuan-mcp"
      ]
    }
  }
}

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 32 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

SiYuan MCP Server

中文文档 | English

A Model Context Protocol (MCP) server for SiYuan Note, enabling AI assistants like Claude, Cursor, and other MCP-compatible tools to interact with your SiYuan notes seamlessly.

⚠️ Important Notice | 重要声明

English:

The code in this project is primarily developed with AI assistance. While functional testing has been performed, comprehensive code review has not been completed. Before using this project, please be aware of and accept the following:

  • The code may contain undiscovered issues or potential risks
  • Conduct necessary code reviews and testing before use
  • Users assume all risks and responsibilities arising from the use of this project
  • Thorough validation is recommended before production use

Use with caution and at your own risk.


中文:

本项目代码主要由 AI 辅助开发,仅进行了功能性测试,未对所有代码进行完整审查。使用本项目前,请充分了解并接受以下内容:

  • 代码可能存在未发现的问题或潜在风险
  • 请在使用前进行必要的代码审查和测试
  • 使用者需自行承担使用本项目所产生的风险和责任
  • 建议在生产环境使用前进行充分的验证

请谨慎使用,并对自己的选择负责。


Fork notice: The block-level tools, SQL query tool, and additional document management tools (get_block, update_block, append_block, insert_block, move_block, get_block_attrs, set_block_attrs, execute_sql, rename_document, remove_document, get_hpath_by_id, get_child_blocks, get_section_content, get_document_for_block, find_block_in_document) were added with AI assistance and have not been fully tested. Use at your own risk.

✨ Features

  • 🚀 Full MCP (Model Context Protocol) implementation
  • 📝 32 tools for comprehensive SiYuan Note operations
  • 🔍 Unified search, raw SQL queries, and scoped document search
  • 📁 Document management (create, read, update, rename, delete, move, tree)
  • 🧱 Block-level operations (get, update, insert, append, move, attributes)
  • 📅 Daily note support with auto-creation
  • 📚 Notebook operations
  • 📸 Snapshot management (backup & restore)
  • 🏷️ Tag management (list, replace)
  • 💻 Written in TypeScript with full type definitions
  • 🌐 Works with Claude Desktop, Cursor, and any MCP-compatible client

📦 Installation

Option 1: Install from Source (Recommended)

# Clone the repository
git clone https://github.com/porkll/siyuan-mcp.git
cd siyuan-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Install globally
npm install -g .

Option 2: Install from npm

# Install globally
npm install -g @porkll/siyuan-mcp

# Or use npx (no installation needed)
npx @porkll/siyuan-mcp

After global installation, the siyuan-mcp command will be available globally.

🔧 Configuration

Prerequisites

  1. Get your SiYuan API Token:

- Open SiYuan Note - Go to Settings → About → API Token - Copy the token

  1. Ensure SiYuan is running:

- Default URL: http://127.0.0.1:6806 - If using a different port, adjust the baseUrl accordingly

Configure for Cursor

Edit your MCP configuration file at ~/.cursor/mcp.json:

{
  "mcpServers": {
    "siyuan-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@porkll/siyuan-mcp",
        "stdio",
        "--token",
        "YOUR_API_TOKEN_HERE",
        "--baseUrl",
        "http://127.0.0.1:6806"
      ]
    }
  }
}

Note: If you installed globally, you can use "command": "siyuan-mcp" instead of "command": "npx".

Configure for Claude Desktop

Edit the configuration file at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "siyuan-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@porkll/siyuan-mcp",
        "stdio",
        "--token",
        "YOUR_API_TOKEN_HERE",
        "--baseUrl",
        "http://127.0.0.1:6806"
      ]
    }
  }
}

Note: If you installed globally, you can use "command": "siyuan-mcp" instead of "command": "npx".

Verify Installation

After configuration, restart your MCP client (Cursor/Claude Desktop) and try:

  • "List all my SiYuan notebooks"
  • "Search for documents containing 'project plan'"
  • "Create a new meeting note in my work notebook"
  • "Show me the 5 most recently modified documents"

🛠️ Available MCP Tools

Once configured, you can interact with SiYuan through natural language. The server provides 32 tools:

🔍 Search & Query

  • unified_search - Search by content, filename, tag, or any combination (use types: ["d"] for document-only results)
  • execute_sql - Execute raw SQL queries against the SiYuan database
  • find_block_in_document - Search for blocks within a specific document by content keyword

📄 Document Operations

  • get_document_content - Get the markdown content of a document
  • create_document - Create a new document
  • append_to_document - Append content to an existing document
  • update_document - Update (overwrite) document content
  • move_documents - Move one or more documents to a new location
  • get_document_tree - Get document tree structure with specified depth
  • rename_document - Rename a document
  • remove_document - Delete a document
  • get_hpath_by_id - Resolve a block ID to its human-readable path

🧱 Block Operations

  • get_block - Get a single block's content by ID (kramdown format)
  • update_block - Update a single block's content by ID
  • append_block - Append a child block to a parent block
  • insert_block - Insert a block before or after an existing block
  • move_block - Move a block within or between documents
  • get_child_blocks - Get the immediate children of a block (navigate document structure)
  • get_section_content - Get full readable markdown for a section by heading block ID
  • get_document_for_block - Look up which document a block belongs to (returns doc ID + path)
  • get_block_attrs - Get all attributes of a block (including custom attributes)
  • set_block_attrs - Set attributes on a block (e.g. custom-status, custom-priority)

📅 Daily Note

  • append_to_daily_note - Append to today's daily note (auto-creates if needed)
  • set_daily_note_format - Configure the folder structure and file naming for daily notes (per notebook)

📚 Notebook Management

  • list_notebooks - List all notebooks
  • get_recently_updated_documents - Get recently updated documents
  • create_notebook - Create a new notebook

📸 Snapshot Management

  • create_snapshot - Create a data snapshot for backup
  • list_snapshots - List available snapshots
  • rollback_to_snapshot - Rollback to a specific snapshot

🏷️ Tag Management

  • list_all_tags - List all unique tags in workspace

- Supports filtering by prefix (prefix parameter) - Supports limiting by depth level (depth parameter, starts from 1, tags separated by /)

  • batch_replace_tag - Batch replace or remove tags across all documents

Usage Examples

Ask your AI assistant naturally:

"List all my SiYuan notebooks"
"Search for documents about machine learning"
"Create a new document called 'Project Ideas' in my Work notebook"
"Show me the 10 most recently modified documents"
"Append 'Meeting notes: discussed Q4 goals' to today's daily note"
"Create a snapshot before I make major changes"
"What's the tree structure of my 'Projects' notebook?"
"Move document X to the root of my Work notebook"
"Move documents X and Y under document Z"
"Set my daily note format to use year/month folders"

📖 Tool Parameters Reference

move_documents

Move one or more documents to a new location.

Parameters:

  • from_ids (string[]) - Required. Array of document IDs to move

- For a single document, use an array with one element: ["20210101000000-abc1234"] - For multiple documents: ["20210101000000-abc1234", "20210102000000-def5678"]

  • to_parent_id (string) - OPTION 1: Target parent document ID. Documents will be moved under this document as children. Cannot be used together with to_notebook_root.
  • to_notebook_root (string) - OPTION 2: Target notebook ID. Documents will be moved to the root (top level) of this notebook. Cannot be used together with to_parent_id.

Important: You must provide EXACTLY ONE destination: either to_parent_id OR to_notebook_root.

Examples:

// Move single document to notebook root
{
  from_ids: ["20210101000000-abc1234"],
  to_notebook_root: "20210101000000-notebook1"
}

// Move multiple documents under another document
{
  from_ids: ["20210101000000-abc1234", "20210102000000-def5678"],
  to_parent_id: "20210103000000-parent99"
}

batch_replace_tag

Batch replace all occurrences of a tag across all documents.

Parameters:

  • old_tag (string) - Required. Tag name to replace (without # symbol)
  • new_tag (string) - Required. New tag name (without # symbol, use empty string to remove)

Examples:

// Replace tag
{
  old_tag: "project",
  new_tag: "work-project"
}

// Remove tag
{
  old_tag: "deprecated",
  new_tag: ""
}

set_daily_note_format

Configure the folder structure and file naming format for daily notes in a notebook. The setting is saved in SiYuan's notebook configuration and persists across all clients.

Default format produces a structure like:

Daily Notes/
├── 2024/
│   ├── 01 - January/
│   │   └── 2024-01-15
│   └── 03 - March/
│       └── 2024-03-21
└── 2025/
    └── 07 - July/
        └── 2025-07-04

Parameters:

  • notebook_id (string) - Required. The notebook ID to configure
  • path_template (string) - Required. Path template using Go time format via Sprig

Template tokens:

TokenOutputExample
`{{now \date "2006"}}`4-digit year2024
`{{now \date "01"}}`2-digit month03
`{{now \date "January"}}`Full month nameMarch
`{{now \date "Jan"}}`Abbreviated monthMar
`{{now \date "02"}}`2-digit day21
`{{now \date "2006-01-02"}}`Full date2024-03-21

Examples:

// Default: year/month-name/date (Daily Notes/2024/03 - March/2024-03-21)
{
  notebook_id: "20210101000000-abc1234",
  path_template: '/Daily Notes/{{now | date "2006"}}/{{now | date "01"}} - {{now | date "January"}}/{{now | date "2006-01-02"}}'
}

// Flat: all notes in one folder (Journals/2024-03-21)
{
  notebook_id: "20210101000000-abc1234",
  path_template: '/Journals/{{now | date "2006-01-02"}}'
}

// Year only: grouped by year (Daily Notes/2024/2024-03-21)
{
  notebook_id: "20210101000000-abc1234",
  path_template: '/Daily Notes/{{now | date "2006"}}/{{now | date "2006-01-02"}}'
}

🔧 Advanced: Using as TypeScript Library

While primarily designed as an MCP server, you can also use this package as a TypeScript library in your own projects:

import { createSiyuanTools } from '@porkll/siyuan-mcp';

// Create an instance
const siyuan = createSiyuanTools('http://127.0.0.1:6806', 'your-token');

// Search operations
const files = await siyuan.searchByFileName('keyword', 10);
const blocks = await siyuan.searchByContent('content', 20);

// Document operations
const content = await siyuan.getFileContent(documentId);
await siyuan.createFile('notebookId', '/path/to/doc', '# Title\n\nContent');
await siyuan.appendToFile(documentId, 'New content');
await siyuan.overwriteFile(documentId, 'Replaced content');

// Daily note
await siyuan.appendToDailyNote('notebookId', 'Today I learned...');

// Notebook operations
const notebooks = await siyuan.listNotebooks();

// SQL queries
const results = await siyuan.search.query(`
  SELECT * FROM blocks 
  WHERE type='d' AND content LIKE '%keyword%'
  ORDER BY updated DESC
  LIMIT 10
`);

// Direct API access
await siyuan.block.insertBlockAfter(blockId, 'New block content');
await siyuan.document.moveDocument(['doc1', 'doc2'], 'targetNotebookId');
const tree = await siyuan.document.getDocTree('notebookId', 2);

Type Definitions

Full TypeScript types are included:

import type {
  SiyuanConfig,
  SiyuanApiResponse,
  Block,
  Notebook,
  NotebookConf,
  DocTreeNode,
  SearchOptions
} from '@porkll/siyuan-mcp';

💻 Development

Setup

# Clone and install
git clone https://github.com/porkll/siyuan-mcp.git
cd siyuan-mcp
npm install

# Build
npm run build

# Watch mode (auto-rebuild)
npm run watch

# Lint
npm run lint

# Format
npm run format

Manual Testing

# Start stdio server manually
npm run mcp:stdio -- --token YOUR_TOKEN --baseUrl http://127.0.0.1:6806

# Start HTTP server (for web clients)
npm run mcp:http -- --token YOUR_TOKEN --port 3000 --baseUrl http://127.0.0.1:6806

🏗️ Architecture

siyuan-mcp/
├── src/                    # Core TypeScript library
│   ├── api/               # SiYuan API clients
│   ├── types/             # Type definitions
│   └── utils/             # Helper utilities
├── mcp-server/            # MCP server implementation
│   ├── bin/               # CLI entry points
│   ├── core/              # MCP server core
│   ├── handlers/          # Tool handlers
│   └── transports/        # Stdio/HTTP transports
└── dist/                  # Compiled JavaScript

🔧 Tech Stack

  • Language: TypeScript 5.3+
  • Runtime: Node.js 18+
  • Module System: ES Modules
  • MCP SDK: @modelcontextprotocol/sdk
  • Protocol: MCP (Model Context Protocol)

❓ FAQ

How do I get my SiYuan API Token?

  1. Open SiYuan Note
  2. Go to Settings → About → API Token
  3. Copy the token

How do I find my notebook ID?

Ask your MCP client: "List all my SiYuan notebooks" and it will show IDs.

Or programmatically:

const notebooks = await siyuan.listNotebooks();
console.log(notebooks.map(nb => `${nb.name}: ${nb.id}`));

The server isn't working, what should I check?

  1. Is SiYuan running? (default: http://127.0.0.1:6806)
  2. Is your API token correct?
  3. Did you restart your MCP client after configuration?
  4. Check the logs in your MCP client

Can I use a different SiYuan port?

Yes! Just update the baseUrl parameter:

"--baseUrl", "http://127.0.0.1:YOUR_PORT"

Does this work with remote SiYuan instances?

Yes! Point baseUrl to your remote instance:

"--baseUrl", "http://your-server.com:6806"

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

📄 License

Apache-2.0

🔗 Related Projects

🙏 Acknowledgments

This project is primarily developed with AI assistance and built on top of the excellent SiYuan Note project.

工具与能力

工具数量

32

资源数量

0

提示词数量

0

能力标签

笔记管理TypeScript本地部署AI集成协议服务开发工具API接口

支持客户端

Claude DesktopClaudeCursor

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

读长文档提问

把 PDF、Markdown 和笔记交给模型,按章节追问细节。

整理知识库

把零散资料归档、打标签,检索时更容易命中。

批量出摘要

提取要点,输出能直接引用的段落。

选择建议

值得选的地方

  • 工具数量 32 个,一次接入能覆盖的操作比单点工具更全。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已经适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好 Node.js,换机器要重新装一遍。
  • 需要自备访问 Token,没有凭据没法直接试。
  • 公开摘要偏短,具体能力和限制要回到仓库确认。

更适合

  • 需要在文档知识场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到访问 Token的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Siyuan MCP Extended

MCP World · 本页

32stdio有1 个2026-05-17
Cherry Studio

MCP World

0未说明未标注1 个2026-05-17
Pdf Math Translate

MCP World

0stdio有1 个2026-05-17
report generation

MCP World

0stdio有1 个2026-05-17
Anything To Notebooklm

MCP World

0stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Siyuan MCP Extended 怎么安装?

公开资料给出的安装命令是 npx @porkll/siyuan-mcp,运行环境为 Node.js。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Siyuan MCP Extended 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Node.js;保存后完全退出客户端再打开,配置才会生效。

Siyuan MCP Extended 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Siyuan MCP Extended 需要 API Key 吗?

公开资料标注的认证方式是访问 Token,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Siyuan MCP Extended 支持哪些客户端?

公开资料标注支持 Claude Desktop、Claude、Cursor;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

来源信息

继续浏览同类 MCP