Skip to content

docs(mcp): add downloadable MCP tool reference artifact - #1380

Closed
FBISiri wants to merge 1 commit into
basicmachines-co:mainfrom
FBISiri:docs/mcp-tool-reference
Closed

docs(mcp): add downloadable MCP tool reference artifact#1380
FBISiri wants to merge 1 commit into
basicmachines-co:mainfrom
FBISiri:docs/mcp-tool-reference

Conversation

@FBISiri

@FBISiri FBISiri commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Closes #404

What

Adds a generated MCP tool reference document (docs/mcp-tools.md) and
the script that produces it (scripts/generate_tool_docs.py).

Why

Issue #404 requested a downloadable tool usage documentation artifact.
This PR provides a comprehensive reference for all 20+ registered MCP tools,
auto-generated from source to stay current as tools evolve.

How

  • scripts/generate_tool_docs.py uses AST parsing (zero runtime deps) to
    extract tool names, docstrings, parameters, types, and defaults from
    src/basic_memory/mcp/tools/
  • Only documents tools registered in __all__ (no internal helpers)
  • Idempotent: running twice produces identical output
  • To regenerate: uv run scripts/generate_tool_docs.py

Testing

  • Ran the generator; verified all registered tools appear in output
  • Verified idempotency (second run produces zero diff)
  • No existing tests affected (new files only)

Closes basicmachines-co#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>

@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: 556dfadbee

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread docs/mcp-tools.md
Comment on lines +358 to +359
- `search_notes("my-project", "keyword")` - Find any content containing "keyword"
- `search_notes("work-docs", "'exact phrase'")` - Search for exact phrase match

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Correct the search_notes argument order in examples

When a reader follows these two-positional-argument examples, the actual search_notes(query, project, ...) signature binds "my-project" to query and "keyword" to project, causing a search for the wrong text in a likely nonexistent project. Rewrite all such examples using explicit query=... and project=... arguments, or reverse their positional order.

AGENTS.md reference: AGENTS.md:L466-L467

Useful? React with 👍 / 👎.

continue
out.append(f"- [{category}](#{_anchor(category)})")
for tool in entries:
out.append(f" - [`{tool.name}`](#{_anchor(tool.name)})")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disambiguate repeated heading anchors

When a category and tool have the same name, as with the existing Search category and search tool, both TOC entries are emitted as #search. Markdown renderers disambiguate the later heading, so the tool link jumps to the category rather than the tool documentation; track duplicate slugs or emit explicit unique anchors.

Useful? React with 👍 / 👎.

out.append(f"{tool.summary}\n")
detail = tool.description.strip()
if detail:
out.append(f"{detail}\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep docstring headings inside each tool section

When a tool description contains Markdown headings, as search_notes already does, appending it verbatim allows ## Search Syntax Examples to close the surrounding ### search_notes section. Its example headings consequently appear as peer tool entries and the parameter table falls under the final example heading in rendered outlines; normalize or demote embedded headings relative to the tool heading before rendering.

Useful? React with 👍 / 👎.

@phernandez

Copy link
Copy Markdown
Member

Thanks @FBISiri — this is the right shape for #404 and I'd like to land it.

To get it through CI and the review bot quickly I've cherry-picked your commit as-is (authorship preserved) onto an in-repo branch and added one follow-up commit addressing the three Codex findings above: #1385.

  • The search_notes("my-project", "keyword") argument-order finding is really a bug in the search_notes docstring in src/basic_memory/mcp/tools/search.py (the generator just faithfully reproduced it), so the fix lands there and the reference inherits it.
  • Anchor disambiguation now follows GitHub's -1/-2 suffix rule in document order.
  • Headings embedded in a docstring are nested one level under the tool heading.

I'll close this PR once #1385 merges so the credit stays attached to your commit. If you'd rather push the fixes here yourself, say so and I'll hold off.

@phernandez

Copy link
Copy Markdown
Member

Update, and a change of plan from my earlier comment — sorry for the churn.

While finishing #1385 we realized this overlaps with work already in the repo: Basic Memory has a per-tool manual written as Unix-style man pages (#952 — a search-notes(3) page for every MCP tool, with verified examples) and bm man install from #610. The maintainers' call is to fold documentation generation into that manual rather than keep a separate flat reference, so #1385 is going to draft instead of merging.

What carries forward from your work:

  • The Codex review of your PR exposed two real bugs in the search_notes tool description (argument order in all 27 examples, and an escaped-quote example that rendered as invalid Python). Those are fixed in fix(mcp): correct the search_notes examples in the tool description #1386, which credits this PR.
  • Your extraction approach and the "regenerate and diff in CI" drift gate are going into the manual's registry generator (see the roadmap in docs/manual-pages.md).

Thanks for the contribution — it moved #404 forward even though the file itself won't land in this shape. If you're interested in the manual-side generator, that issue will be linked from #610 once it's filed.

phernandez added a commit that referenced this pull request Aug 30, 2026
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>
@FBISiri

FBISiri commented Aug 30, 2026 via email

Copy link
Copy Markdown
Contributor Author

@phernandez

Copy link
Copy Markdown
Member

The manual-side follow-up is up as #1389 (bundled section-3 pages + memory://man resources + bm man <topic>), and your docstring fixes are in #1386. Thanks again.

@phernandez

Copy link
Copy Markdown
Member

Closing in favor of the manual-based approach: your docstring fixes landed via #1386 and the generator idea lives on as the manual's registry generator (#610 / #1389). Thanks @FBISiri — the review your PR triggered ended up fixing bugs well beyond docs.

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