av
This tool covers attribute view and database-style operations.
When to read this page: you need to inspect or mutate a real SiYuan attribute view instead of using Markdown tables.
Related pages:
Common Actions
| Group | Actions |
|---|---|
| Read | get, render, get_attribute_view_keys, get_attribute_view_filter_sort, search, get_primary_key_values |
| Row operations | add_rows, remove_rows, duplicate_rows |
| Column operations | add_column, remove_column, set_column_options |
| Scalar cell updates | set_cells |
| View structure and configuration | duplicate, add_view, set_filters, set_sorts, set_group, set_column_visibility, set_column_order |
| Relation cell updates | set_relation |
| Templates | set_new_item_templates, create_from_template |
| Relation and rollup schema | configure_two_way_relation, configure_rollup |
Parameters and Semantics
rendercan also create and materialize an AV whencreateIfNotExist=trueandblockIDis provided. In this mode,blockIDis the target parent/insertion context, and MCP inserts a SiYuan-style spun AV block through a transaction.- To render an existing AV, pass the AV ID as
id. For smoother Agent workflows,renderalso acceptsavIDas a compatibility alias, andav.searchresults include reusablerenderArgs. - Keep the
blockIDreturned byrender(createIfNotExist=true). Later AV reads and writes usually only needavID; MCP resolves the owning database block from row bindings, mirror database blocks, or the blocks-table AV block record. PassblockIDwhen you need an exact database-block view context, when multiple mirrors are possible, or as an explicit fallback for a brand-new empty AV. set_cellsis typed byvalueTypeand accepts either single-cell fields or acells/itemsarray. It deliberately rejectsvalueType="relation"; useset_relationfor a complete relation value so MCP can verify destination write permission and a two-way reverse cell.rowIDandset_relation.itemIDrefer to the AV row item ID, not the source/bound document block ID. Although SiYuan names the relation payload arrayblockIDs,set_relation.relatedItemIDscontains destination AV row item IDs.set_column_optionsaccepts the complete desired option list for oneselectormSelectkey. It is a replacement, not a patch: names omitted from the list are removed through the native transaction operation. An empty list is valid. SiYuan can retain a temporary append order when new names are introduced; MCP returnsintermediate_option_orderin that case and never sends a second, hidden reorder transaction.duplicate_rowsaccepts ordered, canonical bound row item IDs that are present in a persistent top-level view. It creates detached text-record copies; it does not accept detached source rows, cell value IDs, or bound source block IDs. Primary-key text and permitted cell values are copied, while rollup/created/updated values follow SiYuan's native copy behavior. A copied two-way relation writes its reverse destination AV values too.set_new_item_templatesreplaces, never patches, the whole ordered native template array. It requiresdefaultTemplateID(use""to clear it), validates every template field against the raw current keys and select/mSelect options, then reads back the entire array, ordering, and default. SiYuan can otherwise silently prune a missing select option while creating a row; MCP refuses that preflight rather than changing the AV options automatically.create_from_templateuses SiYuan’s narrow native creation API, not a generic JSON write. Its result distinguishesitemID(new AV row) fromblockID(bound document/block). It reads back every requested default field. A document template must declare an explicitsaveLocation, because an inherited global document-creation location cannot be authorized safely before the write.configure_two_way_relationis limited to an existing source relation key and a named destination AV. It verifies both writable AV carriers and both relation metadata directions after one native transaction; it refuses an existing source relation whose retarget would touch a third AV.configure_rolluptakes nativeRollupCalcdata without custom calculation aliases. SiYuan removes filters which reference a reconfigured rollup key; this is reported as a native side effect.- AV writes follow SiYuan frontend transaction operations where possible, including row/column/cell operations and database block
updatedrefresh metadata. duplicatefollows SiYuan's copy-as-mirror flow: it duplicates the AV definition, spins the AV block DOM, and inserts the mirror database block through a transaction.previousIDcontrols the insertion position when provided; otherwiseblockIDor an automatically resolved owning database block is used as the default insertion context.- View-local configuration is deliberately explicit.
add_view,set_filters,set_sorts,set_group,set_column_visibility, andset_column_orderrequire all ofavID,blockID, andviewID. TheblockIDmust be a realNodeAttributeViewcarrier foravID, and its currentcustom-sy-av-viewmust equalviewID; MCP rejects a stale carrier instead of accepting the kernel's current-view fallback. add_viewcreates a namedtable,gallery, orkanbanview in one native transaction. Kanban is permitted only when an existing select field is available, because the kernel otherwise creates a select field and adds it to every existing view.add_viewdoes not curate the carrier-visible-view list; use the existingblock.set_attrsaction deliberately when that is the reviewed objective.set_filtersandset_sortstake complete replacements, never patches.filters: []clears all filters; raw AV JSON may serialize its persisted empty AND root without the emptyfiltersmember, and MCP treats only that known normalization as equivalent.set_groupacceptsfield: ""to clear grouping.set_column_orderrequires the complete existing field-ID set exactly once. Column visibility and order apply to the layout-specific fields of the exact carrier-selected view.
Safety Rules
- AV operations are real database operations, not Markdown table edits.
- Use
avfor structured data instead of faking database behavior in Markdown. set_column_optionsandduplicate_rowsare dangerous W2 mutations: they require explicit confirmation and a strictvalidateOnly=truepreflight before execution.duplicate_rowsalso requiresrworrwdon the source AV carrier and every resolved reverse-relation destination carrier.- If either action reports
outcome_unknownorreadback_mismatch, do not retry automatically. Inspect the exact source and relation destinations first. - These six view configuration actions are strict writes. Call with
validateOnly: true, then repeat with the issuedexpectedStateHashand a new UUIDv7requestId. Sisyphus uses one HTTP dispatch, then raw/api/av/getAttributeViewplus carrier attrs/DOM for readback; it never usesrenderAttributeViewas persistence proof and does not automatically retry an unknown response. set_new_item_templates,create_from_template,configure_two_way_relation,configure_rollup, andset_relationare dangerous actions and require user confirmation plus a current strict-write preflight hash.- All template, relation, and rollup postimages are read with
getAttributeView; these paths never userenderAttributeViewas a readback shortcut. An unknown write response is never replayed.
Examples
MCP:
json
{
"action": "get",
"id": "<attribute-view-id>"
}json
{
"action": "add_column",
"avID": "<attribute-view-id>",
"keyName": "Status",
"keyType": "select"
}json
{
"action": "set_filters",
"avID": "<attribute-view-id>",
"blockID": "<exact-node-attribute-view-carrier>",
"viewID": "<carrier-selected-view-id>",
"filters": [
{
"combination": "and",
"filters": [
{
"column": "<status-key-id>",
"operator": "=",
"value": {"type": "select", "mSelect": [{"content": "In progress"}]}
}
]
}
],
"validateOnly": true
}CLI:
bash
siyuan av get --id <attribute-view-id>
siyuan av render --av-id <attribute-view-id>
siyuan av add-column --av-id <attribute-view-id> --key-name Status --key-type select
siyuan av add-rows --av-id <attribute-view-id> --block-ids <block-id>
siyuan av add-rows --av-id <attribute-view-id> --primary-key-texts "Plain text row"
siyuan av set-column-visibility --av-id <attribute-view-id> --block-id <carrier-block-id> --view-id <view-id> --key-id <key-id> --hidden true --validate-onlyAction List
getrenderget_attribute_view_keysget_attribute_view_filter_sortsearchadd_rowsremove_rowsadd_columnremove_columnset_cellsset_column_optionsduplicate_rowsset_new_item_templatescreate_from_templateconfigure_two_way_relationconfigure_rollupset_relationduplicateget_primary_key_valuesadd_viewset_filtersset_sortsset_groupset_column_visibilityset_column_order