MCPcopy
hub / github.com/continuedev/continue / withTokenRefresh

Method withTokenRefresh

extensions/cli/src/services/MCPService.ts:161–178  ·  view source on GitHub ↗

* Generic wrapper for client operations that handles 401 errors with token refresh * Only applies to SSE/HTTP connections, not stdio

(
    serverName: string,
    operation: () => Promise<T>,
  )

Source from the content-addressed store, hash-verified

159 * Only applies to SSE/HTTP connections, not stdio
160 */
161 private async withTokenRefresh<T>(
162 serverName: string,
163 operation: () => Promise<T>,
164 ): Promise<T> {
165 const connection = this.connections.get(serverName);
166 if (!connection) {
167 throw new Error(`Connection ${serverName} not found`);
168 }
169
170 const serverConfig = connection.config;
171 if (!serverConfig || "command" in serverConfig) {
172 // For stdio connections, just execute normally (no token refresh possible)
173 return await operation();
174 }
175
176 // No auth/token refresh available - just execute the operation directly
177 return await operation();
178 }
179
180 /**
181 * Run a tool by name

Callers 3

runToolMethod · 0.95
connectServerMethod · 0.95
getConnectedClientMethod · 0.95

Calls 1

getMethod · 0.65

Tested by

no test coverage detected