MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / handleMCPInstall

Method handleMCPInstall

internal/sidecar/server.go:259–297  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

257// handleMCPInstall installs a registry server into one or more clients at a
258// scope, mirroring the metadata install endpoint's multi-target shape.
259func (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.
300func (s *Server) handleMCPUninstall(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 7

methodNotAllowedFunction · 0.85
decodeJSONFunction · 0.85
writeErrorFunction · 0.85
writeResultFunction · 0.85
InstallFromRegistryMethod · 0.80
writeJSONFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected