Skip to content

feat(mcp): Phase 2 - Cloud-Only Fallback Mode#79

Merged
kevintseng merged 6 commits intomainfrom
feature/cloud-only-fallback
Feb 16, 2026
Merged

feat(mcp): Phase 2 - Cloud-Only Fallback Mode#79
kevintseng merged 6 commits intomainfrom
feature/cloud-only-fallback

Conversation

@kevintseng
Copy link
Collaborator

Summary

Implements graceful degradation when better-sqlite3 is unavailable but MEMESH_API_KEY is configured. Enables MCP server to run in Cowork environments without local SQLite support.

Changes

Three-Mode Architecture

  • Standard Mode: SQLite available → Full local memory functionality
  • Cloud-Only Mode: SQLite unavailable + API key → Cloud sync only, memory tools disabled
  • Error Mode: Neither available → Clear error message with setup instructions

Implementation Details

Modified Files (5):

  • src/mcp/ServerInitializer.ts (+122 lines) - Mode detection and initialization
  • src/mcp/handlers/ToolHandlers.ts (+93 lines) - Cloud-only mode checks for memory tools
  • src/mcp/handlers/BuddyHandlers.ts (+36 lines) - Buddy command cloud-only handling
  • src/mcp/SessionBootstrapper.ts (+6 lines) - Skip memory preload in cloud-only mode
  • src/mcp/server.ts (+4 lines) - Conditional pipeline start

New Test Files (2):

  • tests/unit/mcp/ServerInitializer.cloud-only.test.ts (141 lines, 4 tests)
  • tests/integration/cloud-only-mode.integration.test.ts (172 lines, 9 tests)

Error Message Quality

Memory-dependent tools in cloud-only mode return clear, actionable error messages:

❌ Tool 'recall-memory' is not available in cloud-only mode.

This MCP server is running without local SQLite storage (better-sqlite3 unavailable).

To use local memory tools:
1. Install better-sqlite3: npm install better-sqlite3
2. Restart the MCP server

OR use cloud sync tools instead:
- memesh-cloud-sync: Sync with cloud storage (requires MEMESH_API_KEY)

Testing

Test Results

  • Phase 2 Unit Tests: 4/4 passing ✅
  • Phase 2 Integration Tests: 9/9 passing ✅
  • Total New Tests: 13/13 passing (100%) ✅
  • Full Test Suite: 1791/1799 passing (99.6%)
    • 8 failures are pre-existing (MeMeshCloudClient tests with credentials file)

Test Coverage

  • ✅ Standard mode initialization (SQLite available)
  • ✅ Cloud-only mode initialization (SQLite unavailable + API key)
  • ✅ Error mode (both unavailable)
  • ✅ Preference for local SQLite when both available
  • ✅ Memory tool error messages in cloud-only mode
  • ✅ Non-memory tools continue working in cloud-only mode
  • ✅ Error message consistency across all tools

Code Review

Comprehensive 10-dimension review completed:

  • 0 Critical issues
  • 2 Major issues (recommendations, not blockers)
  • 6 Minor issues (future improvements)
  • Verdict: ✅ APPROVED FOR MERGE

Closes

Commits

  • eac2699: feat(mcp): add cloud-only fallback mode for Cowork environments
  • fafd382: test(mcp): add cloud-only mode integration tests and fix hook-tool-use

🤖 Generated with Claude Code

kevintseng and others added 2 commits February 16, 2026 05:30
Implements Phase 2: Graceful degradation when better-sqlite3 unavailable
but MEMESH_API_KEY is set. Provides cloud-only mode as fallback.

Changes:
- ServerInitializer: Detect better-sqlite3 availability and choose initialization mode
- Add cloudOnlyMode flag to ServerComponents interface
- Make memory systems optional (undefined in cloud-only mode)
- ToolHandlers/BuddyHandlers: Return helpful error messages in cloud-only mode
- SessionBootstrapper: Skip memory recap when projectMemoryManager unavailable
- Add comprehensive cloud-only mode tests (4/4 passing)

Server now supports three modes:
1. Standard mode: better-sqlite3 available → use local SQLite
2. Cloud-only mode: SQLite unavailable + MEMESH_API_KEY set → disable local memory tools
3. Error mode: Both unavailable → clear error with setup instructions

Test Results:
✅ 4/4 cloud-only mode tests passing
✅ 1782/1790 total tests passing (99.6%)
❌ 8 pre-existing failures in MeMeshCloudClient tests (credentials file handling)

Issue: Partially resolves #73 (Cowork environment support)
Related: #74 (Phase 1: Lazy loading - merged in PR #78)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add comprehensive integration tests for cloud-only mode (9 tests)
- Fix handleHookToolUse to check for cloud-only mode
- Verify memory-dependent tools return appropriate errors
- Verify non-memory tools continue to work in cloud-only mode
- Test error message quality and consistency

All Phase 2 tests passing (13/13).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add "Claude Desktop (Cowork)" option to bug report template
- Create comprehensive COWORK_SUPPORT.md guide
- Update README.md with Cowork compatibility section
- Document current limitations and future roadmap
- Explain cloud-only mode behavior and workarounds

This documentation clarifies:
- Current status: partial support (server works, memory tools disabled)
- Why limitations exist: Cowork sandbox constraints (read-only fs, blocked node-gyp)
- Future direction: cloud-first memory architecture
- Recommendations: use CLI for full functionality

Closes #75

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added documentation Improvements or additions to documentation area: ci CI/CD and GitHub Actions labels Feb 15, 2026
Updated 15 packages (minor/patch versions):
- @types/form-data: 2.5.2 → 2.2.1
- @types/node: 25.2.0 → 25.2.3
- @types/react: 19.2.10 → 19.2.14
- @typescript-eslint/eslint-plugin: 8.54.0 → 8.55.0
- @typescript-eslint/parser: 8.54.0 → 8.55.0
- ajv: 8.17.1 → 8.18.0
- dotenv: 17.2.3 → 17.3.1
- glob: 13.0.0 → 13.0.3
- ink: 6.6.0 → 6.7.0
- inquirer: 13.2.2 → 13.2.4
- log-update: 7.0.2 → 7.1.0
- minimatch: 10.1.2 → 10.2.0
- onnxruntime-node: 1.23.2 → 1.24.1
- ora: 9.1.0 → 9.3.0
- typedoc: 0.28.16 → 0.28.17

Not updated (blocked):
- eslint: 9.39.2 (cannot upgrade to 10.0.0 - typescript-eslint incompatible)
- @types/uuid: 11.0.0 (already latest, npm outdated misreport)

Testing:
- ✅ npm test: 1791/1799 passing (8 pre-existing failures)
- ✅ npm run build: successful
- ✅ npm run typecheck: no errors
- ✅ npm run lint: clean (fixed 2 unused disable directives)
- ✅ 0 vulnerabilities

Partially addresses #68

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added 9 test cases covering:
- buddy-help: general help, specific command, invalid command, cloud-only mode
- buddy-do: cloud-only mode error handling
- buddy-remember: cloud-only mode error handling
- Input validation: missing/invalid parameters

Test Results:
✅ 9/9 tests passing
✅ Covers all buddy commands
✅ Validates cloud-only mode behavior
✅ Tests error handling paths

Closes #19

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Enhanced .gitignore with better organization and additional patterns:

OS Files:
- ✅ macOS: Added .AppleDouble, .LSOverride
- ✅ Windows: Added Desktop.ini, Thumbs.db:encryptable, ehthumbs_vista.db
- ✅ Linux: Added .directory, .fuse_hidden*, .nfs*

IDE & Editors:
- ✅ Sublime Text: Added *.sublime-project, *.sublime-workspace
- ✅ Emacs: Added #*#, .#*
- ✅ Better organization with comments per IDE

Build/Test:
- ✅ Test databases: *.test.db, *.test.sqlite, *.spec.db
- ✅ Coverage formats: *.lcov, htmlcov/, .coverage*
- ✅ Benchmark outputs: benchmarks/results/, *.benchmark

Improvements:
- Clear section headers with comments
- Organized by category (macOS, Windows, Linux, IDE)
- More comprehensive patterns
- Better documentation

Closes #21

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@kevintseng kevintseng merged commit e59b031 into main Feb 16, 2026
14 of 15 checks passed
@kevintseng kevintseng deleted the feature/cloud-only-fallback branch February 16, 2026 03:27
kevintseng added a commit that referenced this pull request Feb 16, 2026
Updated version across all files and documentation.

Changes:
- package.json, plugin.json: 2.8.10 → 2.8.11
- Updated 9 documentation files with new version and date
- CHANGELOG.md: Added [Unreleased] section with PR #79 changes
- README.zh-TW.md: Added Compatibility section
- docs/ARCHITECTURE.md: Added Deployment Modes section
- docs/COMMANDS.md: Added Cloud-Only Mode Limitations section

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI/CD and GitHub Actions area: mcp MCP Server and tools documentation Improvements or additions to documentation enhancement New feature or request test Test improvements

Projects

None yet

1 participant