Repository navigation
feat(mcp): shared parameter types, refusals and resolver for bm_* tools - #1835
Conversation
Foundations for the 1.0 tool surface (#1829, tracking #1827). Every bm_* tool will name its target, project, time window, paging, filters and item kinds the same way, so the types live in one module with the description a model reads and the hidden aliases older callers and host tools use: - NoteIdentifier (alias file_path) and DirectoryPath - ProjectParam (alias project_id), classified once by parse_project into a name or an external id so routing never receives both - Since (aliases timeframe, after_date), Page, PageSize (max 100) - Filters (alias metadata_filters) and Items (alias entity_types; "entity" reads as "note") refusals.refusal() builds the tool error every bm_* refusal raises: the code, what was wrong, and the call to try instead, as text or JSON (#1813). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
The shared resolver for the 1.0 tools (#1829). open_project_target() classifies the `project` argument, lets a '<project>/path' prefix choose or confirm the project through the POSIX tools' routing, and yields a client for that project. resolve_note() resolves the routed target to an external id with strict matching: a miss is a NOT_FOUND refusal pointing to bm_search, and a bare project name is an INVALID_ARGUMENTS refusal pointing to bm_list. Other resolution failures pass through unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
open_project_target() now refuses a target that climbs out of its project
('../x', '~', an absolute path, or a symlink out of a local project) with an
OUTSIDE_PROJECT refusal, before any tool reads or writes. Remote projects are
checked lexically; only a local project's root is resolved against the
filesystem (#1807). A leading '/' anchors at the project root, so '/' and
'/specs' stay valid targets. The refusal follows the caller's output_format.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk
Signed-off-by: phernandez <paul@basicmachines.co>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3bc2ee675
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex review on #1835: - open_project_target takes `kind`. A "path" (a directory, or a file to create) must not climb out of the project; an "identifier" resolves through the project-scoped API and is not checked as a path, so a note titled 'Home ~ Plan' can be addressed by title. - items=[null] reaches validation and is refused instead of being dropped into the default note search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6171126e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
items='[null]' or '[null, "relation"]' went through parse_str_list, which drops nulls, so the malformed request became a default or relation-only search. A JSON-array string is now decoded first and gets the same null check as a native list. Codex review on #1835. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d571f9f7d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two notes with one title make the strict resolve answer 409; resolve_note passed that through as a raw client error, so JSON callers got text. It now matches on the API's status: 404 is NOT_FOUND, 409 is AMBIGUOUS with the API's detail naming the candidates. Codex review on #1835. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d28fa83e99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A project prefix that conflicts with `project`, an unqualified path in a multi-project session, and an ambiguous mount raised routing exceptions that reached the client as plain text. open_project_target turns them into INVALID_ARGUMENTS / AMBIGUOUS refusals with routing's own message, so JSON callers get the refusal shape. Codex review on #1835. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
Codex review on #1835: - open_project_target takes `kind`. A "path" (a directory, or a file to create) must not climb out of the project; an "identifier" resolves through the project-scoped API and is not checked as a path, so a note titled 'Home ~ Plan' can be addressed by title. - items=[null] reaches validation and is refused instead of being dropped into the default note search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
items='[null]' or '[null, "relation"]' went through parse_str_list, which drops nulls, so the malformed request became a default or relation-only search. A JSON-array string is now decoded first and gets the same null check as a native list. Codex review on #1835. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
Two notes with one title make the strict resolve answer 409; resolve_note passed that through as a raw client error, so JSON callers got text. It now matches on the API's status: 404 is NOT_FOUND, 409 is AMBIGUOUS with the API's detail naming the candidates. Codex review on #1835. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk Signed-off-by: phernandez <paul@basicmachines.co>
Bottom of the 1.0 tool-surface stack. Closes #1829 (tracking #1827).
What
mcp/tool_params.py: the parameter types everybm_*tool will use, each carrying the description a model reads and the hidden aliases older callers and host tools send.NoteIdentifier(aliasfile_path),DirectoryPathProjectParam(aliasproject_id).parse_projectclassifies it once intoProjectByNameorProjectById, so routing never gets both.Since(aliasestimeframe,after_date),Page,PageSize(max 100)Filters(aliasmetadata_filters),Items(aliasentity_types;"entity"reads as"note")mcp/refusals.py:refusal(code, message, try_instead=...)builds the tool error every refusal raises, as text or JSON (MCP tools report refusals inconsistently (isError false for read_content/read_note/move_note refusals) #1813).mcp/note_targets.py: the one resolver.open_project_targetroutes a target through the POSIX tools'resolve_project_path_routeand opens the project client.resolve_noteresolves exactly: a miss isNOT_FOUNDpointing tobm_search, and a bare project name isINVALID_ARGUMENTSpointing tobm_list.No tool uses these yet; #1830–#1832 stack on this branch.
Deviations from #1829
workspaceis not a hidden alias.workspace+projectcombine two values into one, which a parameter alias cannot express.project="workspace/project"already routes, and theprojectdescription says so.Tests
tests/mcp/test_tool_params.py: a probe tool on a throwaway FastMCP server checks aliases, string coercion, bounds and that the schema lists only primary names. Plusparse_project, item translation and refusal formats.tests/mcp/test_note_targets.py: the real ASGI stack checks routing by name, by external id and by<project>/prefix;NOT_FOUND; bare project names; and that non-404 failures pass through.just fast-teston both files: 27 passed.just fast-check: lint, format and typecheck clean.🤖 Generated with Claude Code
https://claude.ai/code/session_018CoZ3jWnMJsyQsik4tPySk