document
This tool covers document CRUD, tree navigation, metadata, and daily-note oriented document operations.
When to read this page: you need to create, move, query, or convert documents.
Related pages:
Common Actions
| Group | Actions |
|---|---|
| Create and read | create, lookup, get_doc |
| Tree navigation | get_child_blocks, get_child_docs, list_tree, search_docs |
| Metadata and mutations | rename, move, remove, set_attr, duplicate |
| Daily note / conversion | create_daily_note, heading_to_doc, doc_to_heading |
Parameters and Semantics
createtakes either a human-readablepath, orparentPath+title; omitmarkdownto create an empty document. Preferpathfor child documents. TheparentPath+titlemode accepts either a human-readable parent path or a storage path ending in.syreturned bylookup.lookupresolves byid, storagepath, or human-readablehpath/hPath; useincludeto requestid,ids,path,hpath, ordocInfo.- The returned
idPathincludes availableid/ids. When several documents share the same hpath,include: ["ids"]returns all matching IDs; the tool includes a SQL fallback. rename,remove, andmoveoften need a storage path if you are not using document IDs.get_child_docsrequires a documentid; it does not acceptnotebook + path.list_treeusesnotebook + path, andpathis a storage path such as/or/20240318112233-abc123.sy, not a human-readable path.- If bulk
removehits SiYuan's shortindexingwindow, retry by deleting one document at a time withnotebook + storage path. set_attrwrites document metadata attributes by document ID.
Markdown and Title Rules
createmarkdown does not need a same-name leading# Title; if present, it is stripped to avoid duplicate visible titles.createaccepts((id 'title')), naked((id)), and#tag#directly. Naked refs are expanded to explicit anchors; if lookup fails, MCP falls back to((id 'id'))with a warning.createallows footnote-style refs such as[^1]and[text](siyuan://blocks/id), but the result includes a hint because they do not create SiYuan backlinks.get_docreturns the same editable Markdown shape asfs.read, preserving((id 'title'))and#tag#.
Safety Rules
removeandmoverequire explicit confirmation.- Always resolve document path type before mutating by path.
Examples
MCP:
json
{
"action": "create",
"notebook": "<notebook-id>",
"path": "/Inbox/Weekly Note",
"markdown": "Weekly report body"
}json
{
"action": "lookup",
"id": "<doc-id>",
"include": "path"
}CLI:
bash
siyuan document create --notebook <notebook-id> --path "/Inbox/Weekly Note" --markdown "Weekly report body"
siyuan document lookup --id <doc-id> --include pathAction List
createlookuprenameremovemoveget_child_blocksget_child_docsset_attrlist_treesearch_docsget_doccreate_daily_noteduplicateheading_to_docdoc_to_heading