Skip to content

fix(mcp): correct the search_notes examples in the tool description - #1386

Merged
phernandez merged 1 commit into
mainfrom
fix/search-notes-docstring-examples
Aug 30, 2026
Merged

fix(mcp): correct the search_notes examples in the tool description#1386
phernandez merged 1 commit into
mainfrom
fix/search-notes-docstring-examples

Conversation

@phernandez

@phernandez phernandez commented Aug 30, 2026

Copy link
Copy Markdown
Member

What

Fixes the search_notes docstring examples.

Why

Two bugs, both surfaced by the Codex review of #1380 (thanks @FBISiri — the doc generator there reproduced the docstring faithfully, which is how they became visible):

  1. Argument order. The signature is search_notes(query, project, ...), but all 27 examples were written search_notes("my-project", "keyword"), binding the project name to query and the keyword to project. Anyone copying them searches for the project name inside a project named after the query. Examples now read search_notes("keyword", project="my-project").
  2. Escapes. search_notes("\"exact phrase\" AND keyword", ...) — Python resolves the \" at module load, so the runtime docstring read search_notes(""exact phrase" AND keyword", ...), which is not valid Python. Now search_notes('"exact phrase" AND keyword', project="research").

Scope note: @mcp.tool(description=...) passes a one-line description for this tool, so MCP clients never received the docstring — this is the developer reference and the input to any documentation generator (the manual's planned registry generator included). Verified by listing the tools from the server: search_notes ships a 79-character description.

Split out of #1385, which is being redirected into the manual work (#610 / #952) rather than landing a separate doc generator; this fix stands on its own.

Not in this PR

delete_note.py and edit_note.py error messages carry the same class of wrong-order examples (search_notes("{project}", "{identifier}"), read_note("{project}", ...), delete_note("{project}", ...)), with unit tests asserting on the strings — and unlike this docstring, those are runtime text a model reads. Separate fix.

Verification

  • uv run pytest tests/mcp/test_tool_search.py — 66 passed
  • ruff check / ruff format --check on search.py clean
  • The phrase example parses: ast.parse("search_notes('\"exact phrase\" AND keyword', project='research')")

🤖 Generated with Claude Code

https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp

The examples were wrong in two ways:

- Argument order. The signature is search_notes(query, project, ...) but
  all 27 examples read search_notes("my-project", "keyword"), which binds
  the project name to `query` and the keyword to `project`. Anyone who
  copies them searches for the project name inside a project named after
  the query. Examples now pass the query positionally and the project as
  a keyword.
- Escapes. The phrase-and-keyword example was written with \"exact
  phrase\" escapes, which Python resolves at module load, so the runtime
  docstring read search_notes(""exact phrase" AND keyword", ...) — not
  valid Python. Single outer quotes keep the rendered call valid.

Scope note: the decorator passes its own short description=, so MCP
clients never received this docstring. It is the developer reference and
what any documentation generator reads (the Codex review of #1380 found
both bugs through exactly that path — thanks @FBISiri).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez
phernandez force-pushed the fix/search-notes-docstring-examples branch from 4e53aa0 to cf041d1 Compare August 30, 2026 17:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T17:09:15.933859Z cf041d1 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@phernandez
phernandez merged commit ef0b55e into main Aug 30, 2026
26 checks passed
@phernandez
phernandez deleted the fix/search-notes-docstring-examples branch August 30, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant