opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(mcp): add restart all MCP servers functionality

Open Timorleiderman opened this issue 1 month ago • 2 comments

Summary

  • Add ability to restart all MCP servers without restarting opencode
  • Useful for developers working on MCP servers who need to quickly reconnect after code changes

Changes

  • Add MCP.restartAll() function to disconnect and reconnect all connected/failed servers
  • Add POST /mcp/restart API endpoint
  • Add r keybind in MCP dialog to restart all servers
  • Add /restart-mcp slash command
  • Add "Restart MCPs" to command palette
  • Regenerate SDK with new endpoint

Usage

  1. Open MCP dialog with /mcp, then press r to restart all
  2. Use /restart-mcp slash command
  3. Use command palette → "Restart MCPs"

Timorleiderman avatar Dec 26 '25 20:12 Timorleiderman

the api already allows u to disconnect and reconnect mcp servers I think u can just use that instead?

rekram1-node avatar Dec 26 '25 21:12 rekram1-node

Good point! Updated the implementation to use the existing disconnect and connect endpoints instead of adding a new API endpoint. The restart logic now lives entirely on the client side - it:

  1. Gets all MCP servers with status "connected" or "failed"
  2. Calls disconnect on each in parallel
  3. Calls connect on each in parallel
  4. Refreshes the status No new API surface added.

Timorleiderman avatar Dec 26 '25 21:12 Timorleiderman