handleMCPInstall installs a registry server into one or more clients at a scope, mirroring the metadata install endpoint's multi-target shape.
(w http.ResponseWriter, r *http.Request)
| 257 | // handleMCPInstall installs a registry server into one or more clients at a |
| 258 | // scope, mirroring the metadata install endpoint's multi-target shape. |
| 259 | func (s *Server) handleMCPInstall(w http.ResponseWriter, r *http.Request) { |
| 260 | if r.Method != http.MethodPost { |
| 261 | methodNotAllowed(w) |
| 262 | return |
| 263 | } |
| 264 | var input struct { |
| 265 | Server string `json:"server"` |
| 266 | Clients []string `json:"clients"` |
| 267 | Client string `json:"client"` |
| 268 | Scope string `json:"scope"` |
| 269 | } |
| 270 | if err := decodeJSON(r, &input); err != nil { |
| 271 | writeError(w, http.StatusBadRequest, err.Error()) |
| 272 | return |
| 273 | } |
| 274 | clients := input.Clients |
| 275 | if len(clients) == 0 && input.Client != "" { |
| 276 | clients = []string{input.Client} |
| 277 | } |
| 278 | if len(clients) == 0 { |
| 279 | writeError(w, http.StatusBadRequest, "no target clients specified") |
| 280 | return |
| 281 | } |
| 282 | if input.Server == "" { |
| 283 | writeError(w, http.StatusBadRequest, "server is required") |
| 284 | return |
| 285 | } |
| 286 | scope := input.Scope |
| 287 | if scope == "" { |
| 288 | scope = "user" |
| 289 | } |
| 290 | for _, clientName := range clients { |
| 291 | if _, err := s.services.MCP.InstallFromRegistry(clientName, scope, input.Server); err != nil { |
| 292 | writeResult(w, nil, err) |
| 293 | return |
| 294 | } |
| 295 | } |
| 296 | writeJSON(w, map[string]any{"status": "installed", "server": input.Server, "clients": clients}) |
| 297 | } |
| 298 | |
| 299 | // handleMCPUninstall removes an MCP server from one or more clients. |
| 300 | func (s *Server) handleMCPUninstall(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected