@Summary Disconnect MCP server OAuth2 token @x-apidocgen {"skip": true} EXPERIMENTAL: this endpoint is experimental and is subject to change. Removes the user's stored OAuth2 token for an MCP server.
(rw http.ResponseWriter, r *http.Request)
| 1143 | // EXPERIMENTAL: this endpoint is experimental and is subject to change. |
| 1144 | // Removes the user's stored OAuth2 token for an MCP server. |
| 1145 | func (api *API) mcpServerOAuth2Disconnect(rw http.ResponseWriter, r *http.Request) { |
| 1146 | ctx := r.Context() |
| 1147 | apiKey := httpmw.APIKey(r) |
| 1148 | |
| 1149 | mcpServerID, ok := parseMCPServerConfigID(rw, r) |
| 1150 | if !ok { |
| 1151 | return |
| 1152 | } |
| 1153 | |
| 1154 | //nolint:gocritic // Users manage their own tokens. |
| 1155 | err := api.Database.DeleteMCPServerUserToken(dbauthz.AsSystemRestricted(ctx), database.DeleteMCPServerUserTokenParams{ |
| 1156 | MCPServerConfigID: mcpServerID, |
| 1157 | UserID: apiKey.UserID, |
| 1158 | }) |
| 1159 | if err != nil { |
| 1160 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 1161 | Message: "Failed to disconnect OAuth2 token.", |
| 1162 | Detail: err.Error(), |
| 1163 | }) |
| 1164 | return |
| 1165 | } |
| 1166 | |
| 1167 | rw.WriteHeader(http.StatusNoContent) |
| 1168 | } |
| 1169 | |
| 1170 | // parseMCPServerConfigID extracts the MCP server config UUID from the |
| 1171 | // "mcpServer" path parameter. |
nothing calls this directly
no test coverage detected