Repository navigation
wip: support parented MCP block writes - #17
Merged
Merged
Conversation
Adds :parent-id to upsertNodes block adds so a batch can write a nested block tree in a single call. A parent is either the unique temporary :id of another block add in the same batch, or the stable uuid of an existing ordinary visible block on the same page. Cross-page, hidden, recycled, tag/property, pseudochild, self-referential and cyclic parents are rejected before any transaction; dry-run still performs no transaction. The verified receipt resolves temporary parent ids to the generated block uuids and checks the actual persisted parent via worker DB readback. Inherited slices carried from the dirty priv WIP because the parent-id work is built on top of them (declared here, not new in this branch): - issue8 read slice in tools/cli/worker/api: get-block + read-upsert-blocks (receipt readback), entity serialization helpers, page-recycled gates and full-tree get-page-data (include-children?/max-blocks) in get-page-data, plus their cli/tools tests. - issue5 receipt base: opt-in :receipt option on upsert-nodes (cli.cljs, api export, worker handler, mcp-upsert.cljs adapter, receipt tests in cli_test) and the db_core test-api registry lines. - search: the dirty main checkout carries an in-flight scoped-search change (logseq.app.search options); it is NOT included in this branch. The searchBlocks test app-search-converts-page-uuid-and-limit-options in cli_test.cljs tests that app-bridge conversion and will fail until the scoped-search slice lands separately. Tests (isolated worktree, recompiled from this branch): logseq.api.db-based.issue6-test 10 tests / 41 assertions, 0 failures logseq.api.db-based.tools-test 35 tests / 183 assertions, 0 failures logseq.api.db-based.cli-test 18 tests / 67 assertions, 0 failures electron.mcp-server-test 1 test / 3 assertions, 0 failures clj-kondo (issue6 files) 0 errors / 0 warnings Unverified: Desktop -> MCP HTTP runtime chain, SQLite persistence after graph close/reopen, packaged CLI E2E, full repo test suite. Refs #6
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft WIP for #6 — writing parented block
trees in a single MCP
upsertNodesbatch.upsertNodesblock adds now accept an optional:parent-id, which may be::idof another block add in the same batch(child-before-parent and multi-level nesting both work), or
Same-page, same-call nesting is encoded through the importer's
:build/childrenrecursion; existing parents use an explicit uuid lookup ref. Missing, duplicate,
cross-page, hidden, recycled, tag/property/pseudochild, self-referential and
cyclic parents are rejected before any transaction.
dry-runperforms notransaction and returns planned uuids. The verified receipt (
{:receipt true})resolves temporary parent ids to generated block uuids and checks the actually
persisted parent via worker DB readback.
Inherited dependency scope (declared, not new in this branch)
This branch was isolated from the dirty
privcheckout where issue6 wasdeveloped. The parent-id slice is not separable from the following inherited
slices, which are carried here verbatim and not claimed as new work:
tools.cljs/cli.cljs/ worker handler / api export):get-block+read-upsert-blocks(receipt readback), entity serializationhelpers, recycled-page gates and full-tree
get-page-data(
include-children?/max-blocks), plus their cli/tools tests.:receiptoption onupsert-nodes,mcp-upsert.cljsadapter, receipt tests incli_test.cljs, and thedb_coretest-api registry lines.Search is explicitly out of scope: the main checkout's in-flight
scoped-search change (search options on
logseq.app.search) is NOT included.The scoped tests below do not establish app-bridge search behavior; search verification remains outside this PR.
Tests (isolated worktree, recompiled from this branch)
logseq.api.db-based.issue6-testlogseq.api.db-based.tools-testlogseq.api.db-based.cli-testelectron.mcp-server-testgit diff --checkclean. Compile: 0 warnings.Unverified surfaces (Draft stays WIP)
/mcp→logseq.cli.upsertNodes→ worker)Refs #6