File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 * MCP Service - Clean stateless service for MCP operations
33 */
44
5+ import { UnauthorizedError } from '@modelcontextprotocol/sdk/client/auth.js'
56import { db } from '@sim/db'
67import { mcpServers } from '@sim/db/schema'
78import { createLogger } from '@sim/logger'
@@ -407,8 +408,11 @@ class McpService {
407408 result . value . tools . length
408409 )
409410 )
410- } else if ( result . reason instanceof McpOauthAuthorizationRequiredError ) {
411- // Pending user authorization — not a failure. Leave status as-is.
411+ } else if (
412+ result . reason instanceof McpOauthAuthorizationRequiredError ||
413+ result . reason instanceof UnauthorizedError
414+ ) {
415+ // Pending user authorization or expired refresh — not a hard failure.
412416 logger . info ( `[${ requestId } ] Skipping server ${ server . name } : OAuth authorization pending` )
413417 } else {
414418 failedCount ++
@@ -539,7 +543,10 @@ class McpService {
539543 error : undefined ,
540544 } )
541545 } catch ( error ) {
542- if ( error instanceof McpOauthAuthorizationRequiredError ) {
546+ if (
547+ error instanceof McpOauthAuthorizationRequiredError ||
548+ error instanceof UnauthorizedError
549+ ) {
543550 summaries . push ( {
544551 id : config . id ,
545552 name : config . name ,
You can’t perform that action at this time.
0 commit comments