SiYuan MCP Server
Provides tools for reading, writing, and managing a SiYuan Note workspace: run SQL queries against SiYuan's SQLite for blocks, documents, tags, and backlinks; create, update, and move documents; insert and batch-edit blocks; upload assets; list notebooks; and full CRUD for Attribute View databases (create databases embedded in documents, add/remove fields, write and update entries, manage views with layouts, grouping, filters and sorts, select options, and document-backed rows).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SiYuan MCP Server create a doc called Weekly Plan in my Work notebook"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
SiYuan MCP Server
A Model Context Protocol (MCP) server for SiYuan Note, enabling AI assistants (Claude, Cursor, etc.) to read, write, and manage your SiYuan workspace — including full CRUD for Attribute View databases (SiYuan's relational database system, similar to Notion databases).
v2.1 — Optimized for LLMs
v2 reduces the tool surface from 70 to 26 focused tools (17 core + 9 database automation), because LLMs perform better with fewer, well-designed tools. All read operations are consolidated into siyuan_sql (leveraging SiYuan's built-in SQLite), while Attribute View databases retain dedicated tools (they use JSON storage, not SQLite).
v2.1 adds automatic view selection for read_database (prefers the unfiltered "Default" view), viewId parameter support, and post-write transaction flushing for reliable cross-device sync.
Related MCP server: SiYuan MCP Server
Tool Surface
Core tools
Tool | What it does |
| Run SQL reads against SiYuan's SQLite for blocks, docs, tags, backlinks, and search |
| Read an AV database, list databases, filter entries, or fetch a single entry |
| Get all notebook IDs, document tree (2 levels), and database IDs in one call |
| Create a document or subdocument (nested path: |
| Rename, replace content, and/or move a document |
| Delete a document (with cascade + dryRun support) |
| Insert a block (markdown, heading, list, code, etc.) |
| Update a block's content |
| Batch insert/update/delete blocks in one call |
| Create an AV database (standalone or embedded in a document) |
| Create one or more entries in a database |
| Update cells across one or more entries |
| Delete entries from a database |
| Add or remove fields (columns) in a database |
| Set custom attributes on any block |
| Upload a file (base64) to the workspace |
| List notebooks (optionally create one) |
New database automation tools
Tool | What it does |
| List database views with current layout, grouping, filters, and sorts |
| Add a table, kanban, or gallery view |
| Change a view's layout, name, grouping, filters, or sorts |
| Remove a database view |
| Convert an existing detached row into a document-backed row |
| Create a document and add it as a document-backed database row |
| List the current options for a select/multi-select field |
| Define or update the options for a select/multi-select field |
| Rename a notebook by ID |
Supported AV field types (create/write): text, number, checkbox, select, mSelect, date, url, email, phone, mAsset, relation
Supported AV field types (create/configure): relation, rollup
Read-only/system-computed field types: created, updated, lineNumber, template
Installation
Prerequisites
SiYuan Note running (local or remote)
Node.js 18+
Get your API token
In SiYuan: Settings > About > API token > copy.
Option 1 — npx (recommended)
Add to your MCP client config (Claude Desktop, Cursor, etc.):
{
"mcpServers": {
"siyuan": {
"command": "npx",
"args": ["-y", "siyuan-query-mcp@latest"],
"env": {
"SIYUAN_API_TOKEN": "your-token-here"
}
}
}
}For remote SiYuan or non-default port:
"env": {
"SIYUAN_API_TOKEN": "your-token-here",
"SIYUAN_API_URL": "http://192.168.1.100:6806"
}Option 2 — From source
git clone https://github.com/MyrkoF/siyuan-mcp.git
cd siyuan-mcp/siyuan-mcp-server
npm install && npm run build{
"mcpServers": {
"siyuan": {
"command": "node",
"args": ["/path/to/siyuan-mcp-server/dist/index.js"],
"env": {
"SIYUAN_API_TOKEN": "your-token-here"
}
}
}
}Configuration
Variable | Required | Description |
| Yes | SiYuan API token (Settings > About) |
| No | SiYuan base URL. If omitted, auto-discovers port 6806-6808. |
Legacy aliases: SIYUAN_TOKEN, SIYUAN_BASE_URL
Workspace Map (recommended)
Generate a workspace map with workspace_map and paste it into your AI client's Project Instructions. This gives the LLM all notebook and database IDs upfront, skipping discovery calls.
Call workspace_mapReturns notebook tree (2 levels) + all database IDs, formatted as Markdown.
Quick Start Workflows
Create a document with a database
1. create_document(notebook: "id", path: "/My Page", title: "My Page")
→ returns document block ID
2. create_database(notebookId: "id", name: "My DB",
parentDocId: "<doc ID from step 1>",
fields: [{name: "Status", type: "select"}, {name: "Due", type: "date"}])
→ database appears embedded inside the documentRead and query data
# SQL for documents, blocks, tags, backlinks:
siyuan_sql(stmt: "SELECT * FROM blocks WHERE type='d' AND content LIKE '%project%'")
# AV databases (not in SQLite):
read_database(id: "avId")
read_database(id: "avId", filter: {field: "Status", value: "Active"})Move documents
update_document(id: "docId", parentId: "targetParentDocId")
# Combine with rename:
update_document(id: "docId", title: "New Name", parentId: "targetId")Database Views & Filtering
SiYuan's renderAttributeView API returns data through the lens of a view — each view can have its own filters and sorts. By default, the API uses whichever view was last active in the GUI, which means filtered views can hide entries from MCP consumers.
Convention: "Default" view
Create a view named Default (no filters) in each database you want to access programmatically. The MCP server will automatically prefer this view when no viewId is specified, ensuring you always get all entries regardless of GUI state.
If no "Default" view exists, the server falls back to the current active view (original behavior).
You can also pass viewId explicitly to read_database to target any specific view:
read_database(id: "avId", viewId: "specificViewId")How AV Writes Work
SiYuan uses dual storage for Attribute View databases:
Layer | Contains | Updated by |
Kernel in-memory model | Live state | SiYuan |
JSON files ( | Persisted state | SiYuan (sync from kernel) |
All entry/field operations use SiYuan's official /api/av/ endpoints (kernel-native). Only create_database writes to the JSON file directly (no HTTP API exists for DB creation). Everything is pure HTTP — no local filesystem access required.
MCP Resources
The server exposes static guides as MCP resources:
siyuan://static/guide— Object model, ID lookup, field types, what doesn't worksiyuan://static/workflows— Step-by-step CRUD workflows for all operations
Read them in your MCP client to get detailed usage guidance.
Consumer smoke test
After building, you can validate the full issue-#1 database automation flow against a live SiYuan instance:
SIYUAN_API_TOKEN=your-token-here npm run smoke:siyuanThe smoke test creates a temporary notebook, exercises:
relation field creation with back-reference
rollup field creation and readback
relation cell writes
view add/update
select option management
detached row → document binding
document-backed row creation
notebook rename
Then it removes the temporary notebook.
Tested live against SiYuan 3.6.4.
Development
npm install
npm run build
npx tsc --noEmit # type-check onlyAttribution
This project is a fork of GALIAIS/siyuan-mcp-server.
The original project provided the foundational MCP server structure for SiYuan. This fork adds:
v2 tool consolidation — 70 tools reduced to 26 focused tools for better LLM performance
SQL-first reads —
siyuan_sqlreplaces 15+ read toolsFull Attribute View database CRUD — create, read, write, update, delete databases and entries
Database embedding —
create_databasewithparentDocIdembeds the database inside a pageDocument move —
update_documentwithparentIdmoves documents between parentsWorkspace Map — one-call ID reference for Project Instructions
Universal deployment — pure HTTP, no
SIYUAN_WORKSPACE_PATHneeded
License
MIT — see LICENSE
Available Tools
26 toolsadd_viewC
Add a new table, kanban, or gallery view to a database.
Inputs: avId (required), name (required), type (required), sorts, +2 more.
batch_block_opsB
Execute multiple block operations in one call. Each operation: action "insert", "update", or "delete".
Inputs: operations (required).
bind_row_to_docB
Convert an existing detached row into a document-backed row bound to an existing document.
Inputs: avId (required), docId (required), entryId (required).
create_databaseA
Create a new Attribute View database. With parentDocId: embeds the database TABLE INSIDE that document (appears as content in the page). Without parentDocId: creates a standalone DB page at notebook root. Do NOT include "block" in fields — the primary Name field is auto-created.
Inputs: name (required), notebookId (required), fields, parentDocId.
create_doc_backed_rowC
Create a new document and add it to the database as a document-backed row.
Inputs: avId (required), path (required), title (required), notebookId (required), +2 more.
create_documentA
Create a document (or subdocument) in a notebook. Use nested path for subdocuments: path:"/Parent/Child". Returns the document block ID — use it as parentDocId in create_database to embed a DB inside this doc.
Inputs: path (required), title (required), notebook (required), content.
delete_db_rowsC
Delete one or more entries from a database.
Inputs: avId (required), entryIds (required).
delete_documentA
Delete a document. Use dryRun:true to preview without deleting. Set cascade:true to also delete child documents.
Inputs: id (required), dryRun, cascade.
delete_viewC
Delete a database view by ID.
Inputs: avId (required), viewId (required).
insert_blockB
Insert a markdown block into a document. To embed an existing database, use:
Inputs: content (required), parentID (required), previousID.
list_notebooksB
List all notebooks, or create a new one. Without params: returns all notebooks with IDs. With name: creates a new notebook.
Inputs: icon, name.
list_select_optionsB
List the current options for a select or multi-select database field.
Inputs: avId (required), fieldId (required).
list_viewsA
List database views and their current layout/group/filter/sort configuration.
Inputs: avId (required).
manage_db_fieldsA
Add or remove fields (columns) in a database. Renaming is not supported by SiYuan API — use the GUI.
Inputs: avId (required), action (required), name, type, +3 more.
read_databaseA
Read Attribute View (database) data: fields, entries, values. Supports modes: list all DBs (mode:"list"), read full DB (id only), filter entries (id + filter), get single entry (id + entryId).
Inputs: id, mode, filter, viewId, +1 more.
rename_notebookC
Rename a notebook by ID.
Inputs: name (required), notebookId (required).
set_block_attrsB
Set custom attributes (key-value metadata) on any block. Also used for tags.
Inputs: id (required), attrs (required).
set_select_optionsC
Set or update the available options for a select or multi-select database field.
Inputs: avId (required), fieldId (required), options (required).
siyuan_sqlA
Execute a SQL SELECT on SiYuan's SQLite database. Use for ALL reads: blocks, documents, tags, backlinks, search. Read the siyuan://static/sql-schema resource for table schema and example queries. NOTE: Attribute View (database) data is NOT in SQLite — use read_database instead.
Inputs: stmt (required).
update_blockB
Replace the content of an existing block.
Inputs: id (required), content (required).
update_db_cellsC
Update field values in one or more database entries. Each update targets an entry and specifies which cells to change.
Inputs: avId (required), updates (required).
update_documentA
Rename, replace content, and/or move a document. Provide title to rename, content to replace body, parentId to move under another doc.
Inputs: id (required), title, content, parentId.
update_viewB
Update an existing database view layout, name, grouping, filters, or sorts.
Inputs: avId (required), viewId (required), name, type, +3 more.
upload_assetB
Upload a file as a SiYuan asset. Provide base64-encoded file content.
Inputs: data (required), name (required), assetsDirPath.
workspace_mapA
Get a map of the SiYuan workspace: all notebooks, top-level documents (2 levels), and all Attribute View database IDs. Call this first to orient yourself.
Inputs: no named parameters.
write_db_rowsC
Create one or more entries (rows) in a database. Each row can have a name and initial field values.
Inputs: avId (required), rows (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 26 tools
Most tools target clearly distinct resource+action pairs, and descriptions actively help (siyuan_sql explicitly defers database reads to read_database, workspace_map is flagged as the entry point). The main friction is that insert_block/update_block duplicate the 'insert'/'update' actions of batch_block_ops, and list_notebooks secretly doubles as create, so a few boundaries need the description to resolve.
The dominant pattern is verb_noun snake_case (create_document, update_block, delete_view, set_select_options, upload_asset), which is predictable. Deviations are minor but present: workspace_map and batch_block_ops are bare noun phrases, and siyuan_sql is namespaced unlike anything else.
26 tools is at the heavy end, and the domain (notebooks, documents, blocks, attribute-view databases, views, fields, rows, options, assets) genuinely justifies most of them. Still, redundancy exists — insert_block/update_block overlap with batch_block_ops, and there are five view/field management tools alongside a dual-purpose list_notebooks — so the surface could be trimmed.
Core lifecycle is covered: notebooks (create/rename), documents (create/update/delete), blocks (insert/update/attr, delete via batch), databases (rows/fields/views/select options full CRUD), and assets. Notable gaps remain: no delete_notebook, no standalone delete_block, no asset listing/removal, and field renaming is explicitly unsupported, forcing agents to drop to SQL or the GUI.
Maintenance
Related MCP Connectors
Connect AI to your flomo notes. Search, create, edit notes and manage tags via MCP.
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
MCP-native collaborative markdown editor with real-time AI document editing
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
Related MCP Servers
- AlicenseCqualityCmaintenanceEnables AI assistants to interact with SiYuan Note for comprehensive notebook management, document editing, and block-level content operations. It supports advanced features like full-text search and SQL queries via secure API integration.335 npm40ISC
- AlicenseBqualityDmaintenanceEnables AI assistants to create, read, update, and manage SiYuan notes, supporting notebook management, document operations, block editing, database attribute views, search, file operations, and export.111MIT
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with SiYuan Note through its API, supporting notebook and document management, block operations, search, file operations, and more.69137 npm75MIT
- AlicenseBqualityDmaintenanceEnables AI models to interact with SiYuan Note systems, allowing management of notebooks, documents, blocks, files, and more through natural language.3ISC