Repository navigation
feat(mcp): query_notes, the read tool over note.query - #247
Merged
Merged
Conversation
Agents run Obsidian Bases filters, or a .base file's view, through note.query (ADR-0037, plan 0010 Phase 2). Rows carry the properties the call names, never a note's body. A view that shows a notice in the app (a type outside the subset, or groupOrder) is a tool error that names the view, never empty files. Through lodge the vault is the scope's. The tests cover ADR-0037's check 7: the read tool list of 6, a read scope through lodge's /mcp pinned to its vault with notice, the view notices as tool errors with no files, the limit's edges and a refused this filter. specs/mcp.md gains the tool and its Queries section.
….base path json/v2 writes U+0085, U+2028 and U+2029 raw, and YAML reads them as line breaks, so a filter literal or a property name with one reached the compiler changed. The tool now writes them as JSON escapes. An unnamed view's notice says so, and a path must name a .base file. Tests pin that no input changes the base the tool builds, and that the default limit is 200.
Contributor
Author
Cross-review record
Revert testIn a scratch worktree at
The tests of Gates: |
bketelsen
approved these changes
Nov 18, 2026
5 tasks done
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
Adds the MCP read tool
query_notesovernote.query: plan 0010, Phase 2, as ADR-0037 ("MCPquery_notesis a read tool") shapes it. Its contract is in docs/specs/mcp.md.filters(a Bases statement string, or an object with one ofand,or,not) andpath(a.basefile, with an optionalview);properties(default none);sort(withfiltersonly);limit1 to 1000, default 200.files: [{path, title, url, properties, writable}],totalandnotice(the read tools' sentence).writableappears only under a limited scope, as inlist_notes. An attachment'stitleis itsfile.basename. The result never holds a note's body.filtersgoes tonote.queryas thesourceof a base with 1 table view: the properties are itsorder, andsortis itssort. This form has nothis, so notesd refuses a statement that uses it.pathevaluates the base's view as written.propertiesnames columns of that view (KEYandnote.KEYare the same column). Any other name is an error that lists the view's columns.sortis an error in this form, because the view sets its own order.groupOrder) is a tool error. Its text names the view and the notice, for exampleview "Board": views[1]: view type kanban is outside the subset. It never returns emptyfiles.Docs:
specs/mcp.md(the read tool list goes from 5 to 6, a new Queries section, thewritablelist, and the content rule gains the frontmatter clause), plan 0010 (status, and check 7 built),specs/bases.mdanddesign/vault.md(back-links).Shape choices
ADR-0037 gives a rough shape, and this PR pins these points in the spec:
path,propertiespicks columns of the view.note.queryreturns values only for the view's columns, so another property needs a contract change.sortwithpathis refused:note.querycannot reorder a view.formula.*,this.*, an unknownfile.*) is an error, not a silent null.limit: 0is the default, as forlist_notesandlist_tasks.Risk tier
Risk tier: 2 — a new read-only MCP tool; behaviour change in code. No path in
.github/risk-paths.jsonis touched (internal/mcpserver/http.go,internal/lodgeapp/lodgeapp.goandapi/scope.goare unchanged): the tool uses the existing scope and vault binding.Verification
make cigreen (host, with the nsl ui-check), before the first pushinternal/mcpserver/query_test.go(filters as a string and an object, properties with nulls, sort, limit edges 0/1/1000/1001/-1, path mode,thiswith a path and refused without one, the kanban,groupOrderand first-view-kanban errors with nofiles, input refusals), andTestQueryNotesThroughLodgeIsPinnedToTheScopesVaultininternal/mcpserver/http_test.go(through lodge's socket withkittest: a read scope's rows are pinned to its vault withnoticeandurl, view errors,writableunderwrite=Garden/). The tool lists change from 5 to 6 read tools and from 8 to 9 tools.