Skip to content

docs(mcp): add generated MCP tool reference - #1385

Closed
phernandez wants to merge 4 commits into
mainfrom
docs/1380-mcp-tool-reference
Closed

docs(mcp): add generated MCP tool reference#1385
phernandez wants to merge 4 commits into
mainfrom
docs/1380-mcp-tool-reference

Conversation

@phernandez

Copy link
Copy Markdown
Member

Closes #404
Supersedes #1380

What

Adds a generated MCP tool reference (docs/mcp-tools.md) and the script that produces it (scripts/generate_tool_docs.py), then addresses the review findings on the original PR.

This branch cherry-picks @FBISiri's commit from #1380 unchanged (authorship preserved) and adds one follow-up commit on top. Thanks @FBISiri for the generator — the AST-based, zero-dependency approach and the __all__-as-source-of-truth rule are exactly right for this.

Follow-up commit (Codex findings on #1380)

  1. search_notes examples passed arguments in the wrong order. The signature is search_notes(query, project, ...) but every docstring example was search_notes("my-project", "keyword"), which binds the project name to query and the keyword to project. This is the tool description LLMs see, not just the generated doc. Examples now read search_notes("keyword", project="my-project"); the reference inherits the fix on regeneration.
  2. Duplicate heading anchors. The Search category and the search tool both slugged to #search, so the tool's TOC link landed on the category. Anchors are now assigned in document order with GitHub's -1, -2 suffix rule.
  3. Docstring headings closed the tool section. search_notes carries its own ## Search Syntax Examples / ### ... structure; emitted verbatim under the ### search_notes heading it ended the tool's section and its parameter table fell under the last example heading. Embedded headings are now nested one level below the tool heading (fenced code untouched).

Also: just tool-docs recipe, a README pointer under "MCP tools", and tests/test_generate_tool_docs.py covering the two rendering rules plus a deterministic run over the real tool package.

Verification

  • uv run pytest tests/test_generate_tool_docs.py — 4 passed
  • uv run pytest tests/mcp/test_tool_search.py tests/mcp/test_tool_delete_note.py — 83 passed
  • ruff check src tests test-int scripts/generate_tool_docs.py, ruff format --check, ty check src tests test-int (with the milvus extra) — clean
  • Generator run twice produces an identical docs/mcp-tools.md

Not in this PR

edit_note and delete_note runtime error messages carry the same search_notes("{project}", "{identifier}") ordering (with tests asserting on the strings). Same bug class, separate code path — worth its own small fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp

FBISiri and others added 2 commits August 30, 2026 10:44
Closes #404

Adds scripts/generate_tool_docs.py — an AST-based generator that
introspects all registered MCP tools and emits docs/mcp-tools.md,
a comprehensive reference covering every tool, its parameters,
types, and usage notes.

The generator has zero runtime dependencies (pure stdlib) and is
idempotent — running it twice produces an identical file.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: FBISiri <masteragentsiri@gmail.com>
Follow-up to the generator and reference contributed in #1380, covering the
three Codex findings there plus the wiring to make the artifact discoverable.

- Fix the search_notes docstring examples. The signature is
  search_notes(query, project, ...) but every example passed the project
  first, so a caller following them searched for the project name inside a
  project named after the query. Examples now pass the query positionally
  and the project as a keyword; the generated reference inherits the fix.
- Assign heading anchors in document order the way GitHub does, so the
  Search category and the search tool get #search and #search-1 instead of
  both pointing at the category.
- Nest headings embedded in a tool docstring under the tool's own heading.
  search_notes' "## Search Syntax Examples" no longer closes the tool
  section, so its parameter table stays under the tool in rendered outlines.
- Add a `just tool-docs` recipe, a README pointer to docs/mcp-tools.md, and
  tests for the generator (anchor disambiguation, heading nesting, and a
  deterministic run over the real tool package).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp
Signed-off-by: phernandez <paul@basicmachines.co>
@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-30T16:25:25.910745Z 72e57b0 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a8642d2951

ℹ️ 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".

Comment thread tests/test_generate_tool_docs.py
The generator tests compared two fresh renders, so a tool docstring or
signature change could land without regenerating docs/mcp-tools.md and
nothing would notice. Compare the checked-in file against the generator
output and point the failure at `just tool-docs`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp
Signed-off-by: phernandez <paul@basicmachines.co>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d41dadc982

ℹ️ 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".

Comment thread docs/mcp-tools.md Outdated
The docstring wrote the example with \"exact phrase\" escapes. Python
resolves them when the module loads, so the tool description sent to
clients (and the generated reference) read

    search_notes(""exact phrase" AND keyword", ...)

which is not valid Python and cannot be copied. Use single outer quotes
so the rendered call is valid as written.

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

Copy link
Copy Markdown
Member Author

Converting to draft: direction change, not a problem with the branch.

Basic Memory already has a per-tool manual — Unix-style pages as notes (#952; 23 section-3 pages, one per MCP tool, write-note(3), search-notes(3), …) with bm man install as the first slice of #610. The roadmap in docs/manual-pages.md names the missing piece as a registry generator feeding those pages' SYNOPSIS/PARAMETERS, with regenerate-and-diff in CI as the drift gate. That is the same idea as this generator, so rather than maintain a second, flat reference alongside the manual, we're folding the good parts of this PR into that work:

Leaving this open as a draft for reference until the follow-up is filed.

@FBISiri

FBISiri commented Aug 30, 2026 via email

Copy link
Copy Markdown

@phernandez

Copy link
Copy Markdown
Member Author

Follow-up filed: #1389 ships the manual's section 3 in the package and serves it as memory://man resources, with bm man <topic>. That supersedes this branch; the registry generator (the extraction idea from here) is the next slice.

@phernandez

Copy link
Copy Markdown
Member Author

Superseded by #1389 (merged manual work continues on #610). The branch stays for reference.

@phernandez phernandez closed this Aug 30, 2026
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.

[DOCS] create downloadable tool usage doc artifact

2 participants