Commit 1b20e6c
refactor(mcp): convert search.py prompt to context manager pattern
Convert search_prompt MCP prompt 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 44-57)
- Update SPEC-16 checklist (16 of 16 main tools converted - prompts done!)
The search_prompt helps users search and explore their knowledge base by:
- Searching across all content in basic-memory
- Providing helpful context about search results
- Supporting optional timeframe filtering (e.g., '1d', '1 week')
- Formatting results with rich context for better understanding
This conversion maintains the prompt's search 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)
- Prompt function properly scoped (client inside async with block)
Part of Phase 0.3: Converting 16 MCP tools/prompts to 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 c951aed commit 1b20e6c
2 files changed
Lines changed: 13 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
48 | 49 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | | - | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments