basic-memory
basic-memory copied to clipboard
feat(mcp): add basic_memory_diagnostics tool for version and system info
Closes #187
Summary
Implements the basic_memory_diagnostics MCP tool requested in issue #187, following the converged requirements from the comment thread.
What changed:
- Added
src/basic_memory/mcp/tools/basic_memory_diagnostics.py— a new read-only MCP tool that surfaces:- Basic Memory version (
__version__and__api_version__) - Python version and platform details
- Config file path and contents, with
cloud_api_keyredacted
- Basic Memory version (
- Registered the tool in
src/basic_memory/mcp/tools/__init__.py(import +__all__entry) - Added tests in
tests/mcp/tools/test_basic_memory_diagnostics.pycovering the happy path and the redaction behavior
Design decisions per issue thread:
- Tool name is
basic_memory_diagnostics(renamed from the earlier draft name per reviewer request) - Tool listing was intentionally omitted per reviewer feedback
- Tool is strictly read-only; no writes or side effects
How it was tested
- Unit tests added alongside the implementation; all pass via
uv run pytest tests/mcp/tools/test_basic_memory_diagnostics.py - Manually verified the tool is registered and appears in MCP tool enumeration
Review notes
src/basic_memory/mcp/tools/basic_memory_diagnostics.pyrecomputes the config path asmanager.config_dir / CONFIG_FILE_NAME, butConfigManageralready exposesself.config_file(config.py:825) which is the same value. Usingmanager.config_filewould be marginally cleaner, though the current form is correct and arguably clearer about what file it reads.- The import for
basic_memory_diagnosticsinsrc/basic_memory/mcp/tools/__init__.pyis appended at the end of the import block (after the schema tools) rather than grouped alphabetically with the other tool imports. Purely cosmetic; the__all__list itself is correctly alphabetized. - The
except Exceptionbranch in the tool (malformed config JSON) is marked# pragma: no coverand is not exercised by a test. Low risk since it is defensive, but a malformed-JSON test would close the gap.
🤖 Generated with Claude Code
This is tested and good to go, but needs to ship in v0.next and we have a maintenance release ahead of it.