* 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>,
)
| 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 |
no test coverage detected