Skip to content

Conversation

@fardeenxyz
Copy link

Summary

  • Add ability to start and stop Claude Code as an MCP server from the GUI
  • Add status polling to show running state in real-time
  • Implement singleton pattern to ensure only one MCP server runs at a time

Backend Changes

  • Add mcp_serve() command to spawn claude mcp serve process
  • Add mcp_stop() command to terminate running MCP serve process
  • Add ProcessType::McpServe to process registry with singleton enforcement
  • Add register_mcp_serve_process() and get_running_mcp_serve() methods
  • Update mcp_get_server_status() to check registry for running process

Frontend Changes

  • Add Start/Stop MCP Server buttons to MCPImportExport component
  • Add status polling (2s interval) to show running state
  • Wire onSuccess callback in MCPManager for status refresh
  • Fix duplicate toast notification bug

Why

The MCP server allows external tools to communicate with Claude Code via the Model Context Protocol over stdio transport. This enables integrations with other AI tools and IDEs.

Testing

  • Tested start/stop functionality locally
  • Verified singleton pattern prevents multiple instances
  • Confirmed status polling updates UI correctly

Add ability to start and stop Claude Code as an MCP server from the GUI.

Backend changes:
- Add mcp_serve() command to spawn 'claude mcp serve' process
- Add mcp_stop() command to terminate running MCP serve process
- Add ProcessType::McpServe to process registry with singleton pattern
- Add register_mcp_serve_process() and get_running_mcp_serve() methods
- Update mcp_get_server_status() to check registry for running process

Frontend changes:
- Add Start/Stop MCP Server buttons to MCPImportExport component
- Add status polling (2s interval) to show running state
- Wire onSuccess callback in MCPManager for status refresh
- Fix duplicate toast notification bug

The MCP server allows external tools to communicate with Claude Code
via the Model Context Protocol over stdio transport.
Copilot AI review requested due to automatic review settings January 10, 2026 19:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds MCP (Model Context Protocol) server start/stop controls to Claude Code, enabling it to run as a server that other applications can connect to via stdio transport. The implementation includes backend process management with singleton enforcement, frontend UI controls with real-time status polling, and fixes for duplicate toast notifications.

Changes:

  • Added mcp_serve() and mcp_stop() backend commands with singleton pattern enforcement
  • Implemented ProcessType::McpServe in the process registry with PID-based tracking
  • Added Start/Stop MCP Server buttons with 2-second status polling in the UI
  • Fixed duplicate toast notification bug in import functionality

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src-tauri/src/commands/mcp.rs Added mcp_serve() and mcp_stop() commands, updated mcp_get_server_status() to check registry
src-tauri/src/process/registry.rs Added McpServe process type, register_mcp_serve_process() and get_running_mcp_serve() methods
src-tauri/src/main.rs Registered mcp_stop command handler
src/lib/api.ts Added mcpStop() API method
src/components/MCPImportExport.tsx Added status polling, start/stop buttons, fixed duplicate toast notifications
src/components/MCPManager.tsx Wired onSuccess callback for status refresh

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Make singleton enforcement atomic by checking for existing MCP server
inside the register_mcp_serve_process() lock. This prevents two
concurrent start commands from both passing the check and spawning
duplicate processes.

Additional improvements:
- Use std::mem::forget() to document intentional process detachment
- Kill spawned process if registration fails (cleanup on race loss)
- Move singleton check comment from caller to enforcement point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant