-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add MCP server start/stop controls #428
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
base: main
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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()andmcp_stop()backend commands with singleton pattern enforcement - Implemented
ProcessType::McpServein 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
Resolves conflicts by combining: - Filesystem agent source detection from PR winfunc#397 - MCP server start/stop controls from PR winfunc#428 - i18n translations from PR winfunc#424
Summary
Backend Changes
mcp_serve()command to spawnclaude mcp serveprocessmcp_stop()command to terminate running MCP serve processProcessType::McpServeto process registry with singleton enforcementregister_mcp_serve_process()andget_running_mcp_serve()methodsmcp_get_server_status()to check registry for running processFrontend Changes
onSuccesscallback in MCPManager for status refreshWhy
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