Commit def8cb3
refactor(mcp): convert project_info.py resource to context manager pattern
Convert project_info MCP resource from module-level client import to the new
get_client() context manager pattern, enabling proper dependency injection.
Changes:
- Import get_client() instead of client from async_client module
- Wrap function body in 'async with get_client() as client:' block
- Indent all code inside context manager (lines 63-71)
- Update SPEC-16 checklist - Phase 0.3 COMPLETE! (All 16 tools/prompts/resources converted)
The project_info resource provides comprehensive project information via MCP:
- Project configuration and metadata
- Entity, observation, and relation counts
- Graph metrics (most connected entities, isolated entities)
- Recent activity and growth over time
- System status (database, watch service, version)
This conversion maintains the resource's functionality while:
- Ensuring proper client lifecycle management
- Enabling cloud app to inject custom transport via factory
- Allowing tests to mock client behavior
- Following httpx best practices for async context managers
- Moving auth to client creation instead of per-request
Testing:
- Typecheck passed (0 errors, 0 warnings)
- Resource function properly scoped (client inside async with block)
✅ Phase 0.3 Complete: All 16 MCP tools/prompts/resources converted!
- 13 tools in tools/ directory
- 2 prompts in prompts/ directory
- 1 resource in resources/ directory
Next: Phase 0.4 - Update CLI commands to use context manager pattern.
Related to SPEC-16 MCP Cloud Service Consolidation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 1b20e6c commit def8cb3
2 files changed
Lines changed: 10 additions & 8 deletions
File tree
- specs
- src/basic_memory/mcp/resources
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | | - | |
| 467 | + | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
64 | 62 | | |
65 | | - | |
66 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
67 | 66 | | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
0 commit comments