MCPcopy
hub / github.com/multica-ai/multica / InitiateListModels

Method InitiateListModels

server/internal/handler/runtime_models.go:288–314  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Handlers --------------------------------------------------------------------------- InitiateListModels creates a pending model list request for a runtime. Called by the frontend; the daemon picks it up on its next heartbeat

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

286// InitiateListModels creates a pending model list request for a runtime.
287// Called by the frontend; the daemon picks it up on its next heartbeat.
288func (h *Handler) InitiateListModels(w http.ResponseWriter, r *http.Request) {
289 runtimeID := chi.URLParam(r, "runtimeId")
290 runtimeUUID, ok := parseUUIDOrBadRequest(w, runtimeID, "runtime_id")
291 if !ok {
292 return
293 }
294
295 rt, err := h.Queries.GetAgentRuntime(r.Context(), runtimeUUID)
296 if err != nil {
297 writeError(w, http.StatusNotFound, "runtime not found")
298 return
299 }
300 if _, ok := h.requireWorkspaceMember(w, r, uuidToString(rt.WorkspaceID), "runtime not found"); !ok {
301 return
302 }
303 if rt.Status != "online" {
304 writeError(w, http.StatusServiceUnavailable, "runtime is offline")
305 return
306 }
307
308 req, err := h.ModelListStore.Create(r.Context(), uuidToString(rt.ID))
309 if err != nil {
310 writeError(w, http.StatusInternalServerError, "failed to enqueue model list request: "+err.Error())
311 return
312 }
313 writeJSON(w, http.StatusOK, req)
314}
315
316// GetModelListRequest returns the status of a model list request.
317func (h *Handler) GetModelListRequest(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 8

parseUUIDOrBadRequestFunction · 0.85
GetAgentRuntimeMethod · 0.80
writeErrorFunction · 0.70
uuidToStringFunction · 0.70
writeJSONFunction · 0.70
CreateMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected