-
Notifications
You must be signed in to change notification settings - Fork 155
feat: Feature/517 local mcp cloud mode #522
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
Conversation
|
Claude finished @phernandez's task in 2m 29s —— View job PR Review: Feature/517 Local MCP Cloud ModeReviewed this PR against the Basic Memory team checklist. This feature adds Code Quality & Standards✅ Follows Basic Memory's coding conventions
✅ Literate Programming Style AppliedExcellent use of decision point comments in key files: src/basic_memory/mcp/async_client.py:88-91 # Trigger: BASIC_MEMORY_FORCE_LOCAL env var is set
# Why: allows local MCP server and CLI commands to route locally
# even when cloud_mode_enabled is True
# Outcome: uses ASGI transport for in-process local API callssrc/basic_memory/cli/commands/mcp.py:45-48 # Force local routing for local MCP server
# Why: The local MCP server should always talk to the local API, not the cloud proxy.
# Even when cloud_mode_enabled is True, stdio MCP runs locally and needs local API access.✅ Architecture Consistency
|
This PR allows users to use local MCP server alongside cloud sync by adding explicit routing control to CLI commands. ## Problem When cloud_mode_enabled=true, all API requests routed to cloud proxy. This prevented: - Local MCP server from working (it should always route locally) - CLI commands from accessing local API when desired - Using local knowledge base while cloud syncing ## Solution 1. **Core Infrastructure** - Add BASIC_MEMORY_FORCE_LOCAL env var check in async_client.py - Create routing.py utility with force_routing() context manager 2. **MCP Command** - Auto-set BASIC_MEMORY_FORCE_LOCAL=true before starting MCP server - Local MCP always routes to local API (stdio can't work with cloud) 3. **CLI Commands with --local/--cloud flags** - status: Show local or cloud sync status - tool commands: write_note, read_note, build_context, etc. - project commands: list, add, remove, info 4. **Blocked Commands Fixed** - project default: Now works with --local flag in cloud mode - project sync-config: Now works with --local flag in cloud mode - project move: Now works with --local flag in cloud mode ## Usage ```bash # Local MCP works regardless of cloud mode bm mcp --project myproject # Force local routing for any command bm status --local bm tool write_note --local --title "Note" --folder "notes" --content "..." bm project list --local # Force cloud routing (requires auth) bm status --cloud ``` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
The test_sync_preserves_timestamps test was failing intermittently with Postgres due to timing precision differences between filesystem timestamps and database timestamps. The 1 second tolerance was too tight - increased to 2 seconds which is already used for Windows. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
Add comprehensive integration tests for CLI routing flags: - Test both flags error validation (5 tests) - Test MCP command forces local routing (1 test) - Test tool commands accept flags (10 tests) - Test project commands accept flags (7 tests) - Test status command accepts flags (2 tests) Total: 25 integration tests covering flag acceptance and error handling. Environment variable behavior during execution is tested in unit tests (tests/cli/test_routing.py) which can properly monkeypatch modules. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
- Add "Routing Flags" section to README.md with usage examples - Add BASIC_MEMORY_FORCE_LOCAL to environment variables table - Add "CLI Routing Flags" section to CLAUDE.md under Cloud Features - Document key behaviors: auto-local for MCP server, commands requiring --local Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
c626742 to
3084b77
Compare
|
Claude finished @phernandez's task in 2m 36s —— View job PR Review: Feature/517 Local MCP Cloud ModeComprehensive review completed against the Basic Memory team checklist. SummaryThis PR adds Code Quality & Standards✅ Follows Basic Memory's Coding Conventions
✅ Literate Programming StyleExcellent use of decision point comments throughout: src/basic_memory/mcp/async_client.py:88-91 # Trigger: BASIC_MEMORY_FORCE_LOCAL env var is set
# Why: allows local MCP server and CLI commands to route locally
# even when cloud_mode_enabled is True
# Outcome: uses ASGI transport for in-process local API callssrc/basic_memory/cli/commands/project.py:377-380 # Trigger: cloud mode enabled without --local flag
# Why: default project is a local configuration concept
# Outcome: require explicit --local flag to modify local config in cloud modeMinor suggestion: ✅ No Commented-Out CodeClean implementation without cruft. Testing & Documentation✅ Comprehensive Test Coverage
Test quality is high with proper fixtures, atomic tests, and good coverage of error conditions. ✅ Documentation Now CompleteREADME.md (lines 360-374) documents the routing flags with:
CLAUDE.md (CLI Routing Flags section) provides:
Previous review concern addressed: The missing user documentation has been added in commit ℹ️ Timestamp Test FixCommit Basic Memory Architecture✅ Preserves Local-First Architecture
✅ Proper Separation of Concerns
✅ MCP Server Force-Local BehaviorThe MCP command correctly forces local routing (src/basic_memory/cli/commands/mcp.py:45-48): # Force local routing for local MCP server
# Why: The local MCP server should always talk to the local API, not the cloud proxy.
# Even when cloud_mode_enabled is True, stdio MCP runs locally and needs local API access.
os.environ["BASIC_MEMORY_FORCE_LOCAL"] = "true"This enables the important use case of running both local MCP (Claude Desktop/Code) and cloud MCP (web/mobile) simultaneously. ✅ Follows Async Client Patterns
Security & Performance✅ Security
✅ Performance
Compatibility✅ Windows Path Handling
✅ Environment Variable HandlingThe finally:
# Restore original value
if original_force_local is None:
os.environ.pop("BASIC_MEMORY_FORCE_LOCAL", None)
else:
os.environ["BASIC_MEMORY_FORCE_LOCAL"] = original_force_localThis pattern is cross-platform compatible. Tests verify cleanup works correctly. Detailed Checklist ResultsCode Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
Compatibility
Architecture ReviewCommand Behavior ConsistencyThe PR implements two different patterns for commands in cloud mode: Pattern 1: Commands that accept both
Pattern 2: Commands that require
Example from project.py:380-384: if config.cloud_mode_enabled and not local:
console.print(
"[red]Error: 'default' command requires --local flag in cloud mode[/red]\n"
"[yellow]Hint: Use 'bm project default <name> --local' to set local default[/yellow]"
)
raise typer.Exit(1)Analysis: This is intentional and well-reasoned. Commands that modify local-only configuration concepts (like default project) require explicit Issues Found✅ None CriticalAll items from the previous review have been addressed:
Final Recommendation✅ APPROVE - Ready to Merge This PR successfully implements CLI routing flags with:
The feature enables the important use case of running both local and cloud MCP simultaneously, which is valuable for users who want to use Claude Desktop/Code locally while also accessing their knowledge graph from web/mobile. Strengths
Minor Suggestions (Non-Blocking)
|
No description provided.