-
Notifications
You must be signed in to change notification settings - Fork 269
feat(mcp): generate manual SYNOPSIS blocks from the tool registry #1393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e460c70
feat(mcp): generate manual SYNOPSIS blocks from the tool registry
phernandez 5626d0f
fix(mcp): bound the generated-field flip to the frontmatter
phernandez 67b2059
test(mcp): cover the extractor's missing-block error branch
phernandez 823cc65
fix(mcp): escape control characters in generated SYNOPSIS defaults
phernandez 398d349
fix(mcp): render default-factory parameters as optional in SYNOPSIS
phernandez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| """Regenerate the registry-owned sections of the bundled manual. | ||
|
|
||
| The MCP SYNOPSIS block on every section-3 page whose tool this build registers is | ||
| mechanical: it must show exactly the call the tool schema advertises. This script | ||
| renders those blocks from the live registry (``mcp.list_tools()``) and rewrites | ||
| them in place, flipping the page's ``generated:`` field to ``registry`` so the | ||
| ownership split is declared. Curated sections — DESCRIPTION, PARAMETERS, | ||
| EXAMPLES, GOTCHAS, SEE ALSO — are never touched. | ||
|
|
||
| Run after changing any MCP tool signature: | ||
|
|
||
| just man-regen (or: uv run python scripts/update_man_pages.py) | ||
|
|
||
| A test (tests/test_man_pages.py) holds every shipped block byte-equal to the | ||
| rendering, so a forgotten run fails CI with a pointer here. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import asyncio | ||
|
|
||
| from basic_memory.man import ( | ||
| bundled_pages, | ||
| declare_registry_ownership, | ||
| render_synopsis, | ||
| replace_mcp_synopsis, | ||
| ) | ||
| from basic_memory.mcp.server import mcp | ||
| import basic_memory.mcp.tools # noqa: F401 (importing registers the tools) | ||
|
|
||
|
|
||
| async def main() -> None: | ||
| tools = {tool.name: tool for tool in await mcp.list_tools(run_middleware=False)} | ||
| changed: list[str] = [] | ||
| for page in bundled_pages(): | ||
| # Pages for tools this build does not register (hosted-only ones like | ||
| # cloud_info) stay hand-owned: there is no schema here to render from. | ||
| if page.section != 3 or page.tool not in tools: | ||
| continue | ||
| text = page.read() | ||
| updated = replace_mcp_synopsis( | ||
| text, render_synopsis(page.tool, tools[page.tool].parameters) | ||
| ) | ||
| updated = declare_registry_ownership(updated) | ||
| if updated != text: | ||
| page.path.write_text(updated, encoding="utf-8") | ||
| changed.append(page.title) | ||
| if changed: | ||
| print(f"updated {len(changed)} page(s): {', '.join(changed)}") | ||
| else: | ||
| print("all pages already match the registry") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| --- | ||
| title: basic-memory-diagnostics(3) | ||
| type: manpage | ||
| section: 3 | ||
| name: basic-memory-diagnostics | ||
| summary: report version, system, and redacted configuration for troubleshooting | ||
| generated: registry | ||
| tool: basic_memory_diagnostics | ||
| verified: 0.23.2 local | ||
| --- | ||
|
|
||
| # basic-memory-diagnostics(3) | ||
|
|
||
| ## NAME | ||
|
|
||
| **basic-memory-diagnostics** — report version, system, and redacted configuration for troubleshooting | ||
|
|
||
| ## SYNOPSIS | ||
|
|
||
| ``` | ||
| basic_memory_diagnostics() | ||
| ``` | ||
|
|
||
| ## DESCRIPTION | ||
|
|
||
| Returns a markdown report for support requests and install debugging: the | ||
| basic-memory package version and API version, the Python version, platform, | ||
| and architecture, and the config file path with its contents as a JSON block. | ||
| Secrets and API keys are redacted before anything is emitted. | ||
|
|
||
| Read-only by contract: the tool only computes the config path — it never | ||
| creates the data directory or touches the database, so it works on a broken | ||
| or half-installed setup, which is exactly when it is needed. | ||
|
|
||
| ## MCP USAGE | ||
|
|
||
| Verified locally (0.23.2): | ||
|
|
||
| ``` | ||
| basic_memory_diagnostics() | ||
| # → "# Basic Memory Diagnostics | ||
| # | ||
| # ## Version | ||
| # - basic-memory: 0.23.2 | ||
| # - API: v2 | ||
| # | ||
| # ## System | ||
| # - Python: 3.14.5 (...) | ||
| # - Platform: macOS-26.6-arm64-arm-64bit-Mach-O | ||
| # - Architecture: arm64 | ||
| # | ||
| # ## Configuration | ||
| # - Config path: ~/.basic-memory/config.json | ||
| # - Config exists: True | ||
| # ```json | ||
| # { redacted config ... } | ||
| # ```" | ||
| ``` | ||
|
|
||
| ## GOTCHAS | ||
|
|
||
| - [gotcha] The config JSON block lists every configured project with its path and mode — redaction removes secrets, not project names, so treat the report as private when sharing #privacy | ||
| - [gotcha] A missing or unreadable config file is reported inline (`<config file not found>` / `<error reading config: ...>`) instead of failing — no result is still a diagnostic #resilience | ||
|
|
||
| ## SEE ALSO | ||
|
|
||
| - see_also [[list-memory-projects(3)]] | ||
| - see_also [[cloud-info(3)]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.