Skip to content

feat(mcp): ship the manual in the package and serve it as resources - #1389

Merged
phernandez merged 9 commits into
mainfrom
feat/610-bundled-manual
Aug 30, 2026
Merged

feat(mcp): ship the manual in the package and serve it as resources#1389
phernandez merged 9 commits into
mainfrom
feat/610-bundled-manual

Conversation

@phernandez

@phernandez phernandez commented Aug 30, 2026

Copy link
Copy Markdown
Member

Second slice of #610, built on the #952 manual. Closes #404.

What

The manual's section 3 — one Unix-style page per MCP tool, write-note(3), search-notes(3), … — now ships in the package and is served over MCP.

  • src/basic_memory/man/man3/ — the 21 section-3 pages, pulled from the cloud manual project and made canonical here as portable notes (frontmatter intact minus the cloud-assigned permalink). Every install ships the same pages: local, cloud, offline. Verified in a built wheel.
  • basic_memory.man — page model, a lenient page-reference parser, and man(1)-style resolution. Parse, don't validate: all of these name the same page —
    search-notes(3) · search-notes.3 · search-notes-3 · 3/search-notes · man3/search-notes · search_notes · search-notes%283%29 · man3/search-notes(3).md
    — the section is optional and the lowest wins, as in man.
  • MCP resourcesmemory://man is the index (apropos), memory://man/{ref*} answers any spelling of a page. Every page is also registered as a concrete resource, so clients that browse resources/list (Claude Desktop's picker, Cursor's @) see each page with its summary. Unknown pages raise a ResourceError pointing at the index. The server instructions now send agents to memory://man/<tool>(3) before first use of a tool.
  • bm man <topic> prints a page as Markdown (any spelling; a first argument that isn't a subcommand is a topic, like man), bm man list is apropos, bm man install is unchanged.

Why this shape

We had two per-tool references in flight: the hand-verified manual (cloud-only) and a flat generated docs/mcp-tools.md (#1380/#1385). The manual is the system of record, but it wasn't in the repo — a GitHub visitor or a local-first install had no per-tool reference at all. Bundling section 3 fixes that without a second generator, and resources make the pages reachable from any MCP client with zero projects configured. Both URI shapes are accepted because an agent's first guess is whichever form its training weighted; the parser meets it there.

Tests

tests/test_man_pages.py, tests/mcp/test_man_resources.py, tests/cli/test_man_command.py — 47 tests. One pins the section-3 corpus against the tool registry with the gaps named explicitly (basic_memory_diagnostics has no page; cloud_info is hosted-only), and one asserts every SYNOPSIS names exactly the parameters in the live tool schema — so a new tool, a new parameter, or a retired page surfaces as a test change rather than silently drifting. The index marks pages whose tool this server does not register.

Not in this PR (next slices)

Verification

  • ruff check / ruff format --check clean on changed files; ty check src tests test-int clean; pyright clean on the new modules
  • uv build --wheel includes all pages under basic_memory/man/man3/
  • bm man stays in skip_init_commands, so reading a page never touches the database

🤖 Generated with Claude Code

https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp

Second slice of #610, grown out of the #952 manual:

- src/basic_memory/man/man3/: the 23 section-3 pages (one per MCP tool)
  pulled from the `manual` project and made canonical in the package, as
  portable notes -- frontmatter intact minus the cloud-assigned permalink.
  Every install now ships the same pages: local, cloud, offline.
- basic_memory.man: the page model, a lenient page-reference parser, and
  man(1)-style resolution. Parse, don't validate: search-notes(3),
  search-notes.3, 3/search-notes, man3/search-notes, search_notes and
  percent-encoded forms all name the same page; the section is optional
  and the lowest wins, as in man.
- MCP resources: memory://man is the index (apropos) and
  memory://man/{ref*} answers any spelling of a page. Every page is also
  registered as a concrete resource so clients that browse resources/list
  see each one with its summary. Unknown pages raise a ResourceError that
  points at the index. Server instructions send agents to a tool's page
  before first use.
- bm man <topic> prints a page as Markdown (any spelling; a first argument
  that is not a subcommand is a topic, like man), bm man list is apropos,
  bm man install is unchanged.
- Tests pin the section-3 corpus against the tool registry: the one tool
  without a page (basic_memory_diagnostics) and the three pages without a
  local tool (canvas, cloud_info, release_notes) are named explicitly, so
  a new tool or a retired page shows up as a test change.

Supersedes the flat generated reference from #1380/#1385 (#404); the
registry generator for SYNOPSIS/PARAMETERS is the next slice.

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-30T18:50:59.908022Z 98f23d7 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: f28f6ea23e

ℹ️ 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 src/basic_memory/man/man3/delete-project(3).md Outdated
Comment thread src/basic_memory/mcp/server.py Outdated
Comment thread src/basic_memory/man/man3/list-directory(3).md Outdated
phernandez added a commit that referenced this pull request Aug 30, 2026
…tool schema

Codex review of #1389 caught pages whose SYNOPSIS no longer matched the
shipped tool: delete-project(3) omitted the destructive delete_notes flag
and promised file retention unconditionally; list-directory(3) claimed
there was no structured output while output_format, sort, page, and
page_size exist. A scan found the same drift in edit-note(3)
(replace_subsections, metadata) and write-note(3) (workspace).

All four pages now document the current parameters, and a test asserts
that every section-3 SYNOPSIS names exactly the parameters in the live
tool schema, so the next added parameter fails CI instead of waiting for
a reader. The server instruction no longer promises a page for every
tool (basic_memory_diagnostics has none yet); it points at the index.

The verified: stamps are unchanged -- the examples on those pages ran on
0.21.6 and were not re-run here; the SYNOPSIS is now checked by test.

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

Codex review of #1389 caught pages whose SYNOPSIS no longer matched the
shipped tool: delete-project(3) omitted the destructive delete_notes flag
and promised file retention unconditionally; list-directory(3) claimed
there was no structured output while output_format, sort, page, and
page_size exist. A scan found the same drift in edit-note(3)
(replace_subsections, metadata) and write-note(3) (workspace).

All four pages now document the current parameters, and a test asserts
that every section-3 SYNOPSIS names exactly the parameters in the live
tool schema, so the next added parameter fails CI instead of waiting for
a reader. The server instruction no longer promises a page for every
tool (basic_memory_diagnostics has none yet); it points at the index.

The verified: stamps are unchanged -- the examples on those pages ran on
0.21.6 and were not re-run here; the SYNOPSIS is now checked by test.

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 feat/610-bundled-manual branch from 7e47e80 to 2d8b1c9 Compare August 30, 2026 17:58

@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: 2d8b1c9e04

ℹ️ 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 src/basic_memory/man/man3/recent-activity(3).md Outdated
…mode

The page told readers to omit project for cross-project discovery. In the
normal case a session's active project or the configured default resolves
first, so omitting project returns that project's activity and discovery
only runs when nothing resolves. Document the resolution order, fix the
parameter line, and add a gotcha with the ways to survey every project.

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 feat/610-bundled-manual branch from ecc4536 to 4db7044 Compare August 30, 2026 18:03

@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: 4db7044990

ℹ️ 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 src/basic_memory/man/man3/canvas(3).md Outdated
Comment thread src/basic_memory/man/man3/read-content(3).md Outdated
…read_content fidelity

Codex review of #1389, third pass:

- canvas(3) and release-notes(3) documented tools removed in #1111 and
  #1145 that exist on neither the local nor the hosted server; dropped.
- cloud-info(3) documents a tool that only the hosted server registers;
  the page now says so in its summary and description, and the
  memory://man index marks any page whose tool this server does not
  register, computed from the live registry, so the same corpus stays
  honest on both servers.
- read-content(3) promised raw bytes for everything. Text is byte-exact;
  images are resized and re-encoded as JPEG; other binaries are returned
  base64 up to 350,000 bytes and error above. The page now says which.

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: b6c380b6b7

ℹ️ 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 src/basic_memory/man/man3/write-note(3).md Outdated
write_note stores the title in frontmatter and derives the permalink from
it; the body is saved as given, so a note whose content has no heading
ends up with no H1. The page now says so and tells callers to include
the heading themselves.

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: 2911605f37

ℹ️ 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 src/basic_memory/man/man3/delete-note(3).md Outdated
Comment thread src/basic_memory/man/man3/cloud-info(3).md Outdated
… relations

Codex review of #1389, fifth pass:

- cloud-info(3) and read-content(3) still linked to release-notes(3) and
  canvas(3) after those pages were dropped. Removed, and a test now
  asserts every [[name(3)]] link in the bundle lands on a bundled page.
- delete-note(3) said relations to a deleted note become permanently
  unresolved. Since #1344 the target id is cleared and the link text
  kept, and the forward-reference pass relinks when a note with that
  name is written again. The page now describes that recovery and keeps
  the archive-over-delete pattern for the right reason.

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: a0f2b978ac

ℹ️ 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 src/basic_memory/man/__init__.py Outdated
Comment thread src/basic_memory/man/man3/chatgpt-search(3).md
Comment thread src/basic_memory/man/man3/delete-note(3).md Outdated
Comment thread src/basic_memory/man/man3/move-note(3).md Outdated
Codex review of #1389, sixth pass:

- find_page now accepts the tool name as an alias for the page name, so
  memory://man/search(3) and memory://man/fetch(3) reach chatgpt-search(3)
  and chatgpt-fetch(3) as the server instruction promises. An exact page
  name still wins over an alias.
- chatgpt-search(3) and chatgpt-fetch(3) state that the tools answer only
  OpenAI clients; everyone else gets 'Unsupported MCP client'.
- delete-note(3), move-note(3), and write-note(3) examples showed a
  structured response without asking for it; they now pass
  output_format="json" so the shown shape is what a copy returns.
- move-note(3) qualifies permalink preservation: it is the default, and
  update_permalinks_on_move=True (or a note with no permalink) rewrites
  the permalink from the destination path.

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: cb30369348

ℹ️ 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 src/basic_memory/man/man3/build-context(3).md Outdated
phernandez added a commit that referenced this pull request Aug 30, 2026
Codex review of #1389, seventh pass, generalized: eleven GOTCHAS entries
across nine pages described defects as 'fixed in #N, pending release',
'on main, unreleased', or 'verified fixed at HEAD'. Those fixes (#908,
#971, #981, cloud#1173) are in this tree, and the pages now ship with the
tree, so each entry told readers about a bug they do not have. Removed,
and a test asserts no bundled page carries such a stamp again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014pmKq6bqCi6Zp6BTHuZjrp
Signed-off-by: phernandez <paul@basicmachines.co>
Codex review of #1389, seventh pass, generalized: eleven GOTCHAS entries
across nine pages described defects as 'fixed in #N, pending release',
'on main, unreleased', or 'verified fixed at HEAD'. Those fixes (#908,
#971, #981, cloud#1173) are in this tree, and the pages now ship with the
tree, so each entry told readers about a bug they do not have. Removed,
and a test asserts no bundled page carries such a stamp again.

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 feat/610-bundled-manual branch from 5023821 to c8fc6aa Compare August 30, 2026 18:37

@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: c8fc6aaa47

ℹ️ 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 src/basic_memory/man/man3/write-note(3).md Outdated
…project

resolve_project_parameter promotes the session's cached active project
over the configured default, so omitting project after touching another
project writes there, not to the default. The page said the opposite.

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 merged commit fe9e846 into main Aug 30, 2026
27 checks passed
@phernandez
phernandez deleted the feat/610-bundled-manual branch August 30, 2026 19:12
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

1 participant