MCPcopy Index your code
hub / github.com/coder/coder / updateMCPServerConfig

Method updateMCPServerConfig

coderd/mcp.go:552–827  ·  view source on GitHub ↗

@Summary Update MCP server config @x-apidocgen {"skip": true} EXPERIMENTAL: this endpoint is experimental and is subject to change. nolint:revive // HTTP handler writes to ResponseWriter.

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

Source from the content-addressed store, hash-verified

550//
551//nolint:revive // HTTP handler writes to ResponseWriter.
552func (api *API) updateMCPServerConfig(rw http.ResponseWriter, r *http.Request) {
553 ctx := r.Context()
554 apiKey := httpmw.APIKey(r)
555 if !api.Authorize(r, policy.ActionUpdate, rbac.ResourceDeploymentConfig) {
556 httpapi.Forbidden(rw)
557 return
558 }
559
560 mcpServerID, ok := parseMCPServerConfigID(rw, r)
561 if !ok {
562 return
563 }
564
565 var req codersdk.UpdateMCPServerConfigRequest
566 if !httpapi.Read(ctx, rw, r, &req) {
567 return
568 }
569
570 // Pre-validate custom headers before entering the transaction.
571 var customHeadersJSON string
572 if req.CustomHeaders != nil {
573 var chErr error
574 customHeadersJSON, chErr = marshalCustomHeaders(*req.CustomHeaders)
575 if chErr != nil {
576 httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
577 Message: "Invalid custom headers.",
578 Detail: chErr.Error(),
579 })
580 return
581 }
582 }
583
584 var updated database.MCPServerConfig
585 err := api.Database.InTx(func(tx database.Store) error {
586 existing, err := tx.GetMCPServerConfigByID(ctx, mcpServerID)
587 if err != nil {
588 return err
589 }
590
591 displayName := existing.DisplayName
592 if req.DisplayName != nil {
593 displayName = strings.TrimSpace(*req.DisplayName)
594 }
595
596 slug := existing.Slug
597 if req.Slug != nil {
598 slug = strings.TrimSpace(*req.Slug)
599 }
600
601 description := existing.Description
602 if req.Description != nil {
603 description = strings.TrimSpace(*req.Description)
604 }
605
606 iconURL := existing.IconURL
607 if req.IconURL != nil {
608 iconURL = strings.TrimSpace(*req.IconURL)
609 }

Callers 1

updateMCPServerConfigFunction · 0.80

Calls 15

AuthorizeMethod · 0.95
APIKeyFunction · 0.92
ForbiddenFunction · 0.92
ReadFunction · 0.92
WriteFunction · 0.92
Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
IsUniqueViolationFunction · 0.92
IsCheckViolationFunction · 0.92
parseMCPServerConfigIDFunction · 0.85
marshalCustomHeadersFunction · 0.85
coalesceStringSliceFunction · 0.85

Tested by

no test coverage detected