Tencent/WeKnora · error

failed to update MCP service

Error message

failed to update MCP service: %w

What it means

Thrown by ClearMCPCredential when mcpServiceRepo.Update fails to persist the credential change (after the field was cleared in memory). A database write failure; on success the client connection is also closed to force reconnect.

Solutions

  1. Check database connectivity and retry the clear request
  2. Verify the service row was not concurrently deleted
  3. Retry is safe: the operation is idempotent for already-empty fields
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/mcp_service.go:576 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/855b1c0ceee4db0c. Report an issue: GitHub.

Appendix: source

Thrown at internal/application/service/mcp_service.go:576

		if existing.AuthConfig.APIKey != "" {
			existing.AuthConfig.APIKey = ""
			changed = true
		}
	case "token":
		if existing.AuthConfig.Token != "" {
			existing.AuthConfig.Token = ""
			changed = true
		}
	default:
		return fmt.Errorf("unknown credential field: %s", field)
	}
	if !changed {
		return nil
	}

	existing.UpdatedAt = time.Now()
	if err := s.mcpServiceRepo.Update(ctx, existing); err != nil {
		return fmt.Errorf("failed to update MCP service: %w", err)
	}

	s.mcpManager.CloseClient(id)
	logger.GetLogger(ctx).Infof(
		"MCP credential cleared by user: id=%s field=%s, connection closed",
		secutils.SanitizeForLog(id), field,
	)
	return nil
}

// GetMCPServiceResources retrieves the list of resources from an MCP service
func (s *mcpServiceService) GetMCPServiceResources(
	ctx context.Context,
	tenantID uint64,
	id string,
) ([]*types.MCPResource, error) {
	// Get service
	service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)

View on GitHub (pinned to 988cbb0330)