basic-memory icon indicating copy to clipboard operation
basic-memory copied to clipboard

feat(mcp): add basic_memory_diagnostics tool for version and system info

Open groksrc opened this issue 5 months ago • 1 comments

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_key redacted
  • Registered the tool in src/basic_memory/mcp/tools/__init__.py (import + __all__ entry)
  • Added tests in tests/mcp/tools/test_basic_memory_diagnostics.py covering 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.py recomputes the config path as manager.config_dir / CONFIG_FILE_NAME, but ConfigManager already exposes self.config_file (config.py:825) which is the same value. Using manager.config_file would be marginally cleaner, though the current form is correct and arguably clearer about what file it reads.
  • The import for basic_memory_diagnostics in src/basic_memory/mcp/tools/__init__.py is 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 Exception branch in the tool (malformed config JSON) is marked # pragma: no cover and 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

groksrc avatar Jun 11 '26 06:06 groksrc

This is tested and good to go, but needs to ship in v0.next and we have a maintenance release ahead of it.

groksrc avatar Jun 12 '26 01:06 groksrc