Repository navigation
Description
Refactor MCP server as managed service and enable browser mode support
Summary
Refactor MCP server to be a managed Tauri service (like NodeService, EmbeddingService) and create a standalone dev-mcp binary for browser mode development, enabling AI agent integration across both development modes.
Current State
Tauri Mode:
- MCP server spawned as background task via
initialize_mcp_server()after database init - Works correctly but not structured as a managed service
- Inconsistent with other services (NodeService, Embedding Service, etc.)
Browser Mode:
- NO MCP server available
- AI agents cannot connect during browser development
- Limits ability to test MCP integration
Proposed Changes
Phase 1: Refactor MCP to Managed Service (Tauri Mode)
-
Create
McpServerService(src-tauri/src/services/mcp_server_service.rs):pub struct McpServerService { node_service: Arc<NodeService>, embedding_service: Arc<NodeEmbeddingService>, port: u16, // Potential future: health status, metrics, connection count } impl McpServerService { pub fn new(...) -> Self { ... } pub fn start(&self) -> anyhow::Result<()> { ... } pub fn port(&self) -> u16 { ... } }
-
Register as managed service in
commands/db.rs::init_services():let mcp_service = McpServerService::new(...); mcp_service.start()?; app.manage(mcp_service);
-
Remove
lib.rs::initialize_mcp_server()(functionality moved to service) -
Move core logic from
mcp_integration.rsto new service module
Phase 2: Enable Browser Mode MCP
-
Create
dev-mcpbinary (src-tauri/src/bin/dev-mcp.rs):- Similar structure to
dev-proxy.rs - Connects to SurrealDB HTTP server (port 8000)
- Initializes NodeService and EmbeddingService
- Starts MCP server on port 3100
- Similar structure to
-
Add npm script in
packages/desktop-app/package.json:"dev:browser:mcp": "cd src-tauri && cargo run --bin dev-mcp"
-
Update
dev:browserconcurrently command:"dev:browser": "concurrently 'bun run dev:browser:db' 'sleep 2 && bun run dev:browser:proxy' 'sleep 2 && bun run dev:browser:mcp' 'sleep 4 && bun run dev:browser:frontend'"
Benefits
✅ Unified architecture across browser and Tauri modes
✅ Consistent service pattern (all services managed the same way)
✅ Better testability (MCP can be tested independently)
✅ Lifecycle control (potential for start/stop/restart methods)
✅ Browser mode MCP (AI agents can connect during development)
✅ Future-ready (easier to add health checks, metrics, etc.)
Technical Details
Port Configuration:
- Uses
MCP_PORTenvironment variable (defaults to 3100) - No conflicts with dev-proxy (3001) or SurrealDB (8000)
State Sharing:
- Both dev-proxy and dev-mcp share NodeService (different Arc instances, same DB)
- MCP is stateless (no SSE subscription needed - queries fresh from NodeService)
- dev-proxy handles SSE for browser real-time sync
Event Propagation:
- NodeService emits domain events
- dev-proxy's SSE handler forwards to browser
- MCP queries return fresh data (stateless request/response)
Acceptance Criteria
-
McpServerServicecreated insrc-tauri/src/services/module - MCP registered as managed service in
init_services() -
initialize_mcp_server()function removed fromlib.rs -
dev-mcpbinary created insrc-tauri/src/bin/ - Browser mode launches MCP server automatically
- MCP server accessible on port 3100 in both modes
- AI agents can connect in browser mode
- Existing Tauri mode MCP functionality unchanged
- Tests pass (existing MCP integration tests still work)
- Documentation updated (architecture docs, development guide)
Labels
refactoring, mcp, architecture, developer-experience
Activity
Add MCP server support for browser mode development (closes #715)
WIP: Fix MCP→UI reactivity for task status updates (Issue #715)
WIP: Identify root cause - TaskNodeViewer needed (Issue #715)
Fix MCP→UI reactivity for task status updates (Issue #715)
Add browser-side SSE event filtering (Issue #715)
Simplify client ID architecture - dev-proxy as single logical client …
WIP: TaskNodeViewer + debug reactive loop issue (Issue #715)
WIP: Fix Svelte reactive loops and SSE filtering bugs (Issue #715)
malibio commentedon Dec 2, 2025
Session Update - WIP Commit 81f4ae8
Fixed Svelte reactive loops and began SSE filtering fixes.
Completed:
Remaining:
Current Issue:
Task status toggle shows update briefly then reverts - browser receiving own changes via SSE despite filtering attempt.
Fix SSE feedback loop - complete domain event filtering (Issue #715)
Fix naming convention: properties object now uses camelCase (Issue #715)
Fix children-tree API to use typed serialization (Issue #715)
Fix get_nodes_in_subtree to enrich task nodes with spoke data (Issue #…
Fix inherited task nodes reverting to text on first keystroke (Issue #…
Fix task node date clearing and UI bugs (Issue #715)
Refactor MCP server as managed service and enable browser mode support (
Refactor MCP server as managed service and enable browser mode support (
Refactor MCP server as managed service and enable browser mode support (
Refactor MCP server as managed service and enable browser mode support (