Skip to content

Commit aaadbac

Browse files
committed
fix(mcp): return authType from create-server endpoint
The POST /api/mcp/servers handler omitted authType from the success response, so useCreateMcpServer always saw data.data.authType as undefined and never triggered the OAuth popup after creating an OAuth-protected server. Thread authType through performCreateMcpServer into the response so the client can decide whether to auto-start OAuth.
1 parent 37e57ee commit aaadbac

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

apps/sim/app/api/mcp/servers/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export const POST = withRouteHandler(
115115

116116
return createMcpSuccessResponse(
117117
result.updated
118-
? { serverId: result.serverId, updated: true }
119-
: { serverId: result.serverId },
118+
? { serverId: result.serverId, updated: true, authType: result.authType }
119+
: { serverId: result.serverId, authType: result.authType },
120120
result.updated ? 200 : 201
121121
)
122122
} catch (error) {

apps/sim/lib/mcp/orchestration/server-lifecycle.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export interface PerformMcpServerResult {
8383
serverId?: string
8484
server?: typeof mcpServers.$inferSelect
8585
updated?: boolean
86+
authType?: McpAuthType
8687
}
8788

8889
async function validateMcpServerUrl(url: string): Promise<PerformMcpServerResult | null> {
@@ -198,7 +199,7 @@ export async function performCreateMcpServer(
198199
})
199200

200201
await mcpService.clearCache(params.workspaceId)
201-
return { success: true, serverId, updated: true }
202+
return { success: true, serverId, updated: true, authType: resolvedAuthType }
202203
}
203204

204205
await db.insert(mcpServers).values({
@@ -268,7 +269,7 @@ export async function performCreateMcpServer(
268269
request: params.request,
269270
})
270271

271-
return { success: true, serverId, updated: false }
272+
return { success: true, serverId, updated: false, authType: resolvedAuthType }
272273
} catch (error) {
273274
logger.error('Failed to create MCP server', { error })
274275
return { success: false, error: 'Failed to register MCP server', errorCode: 'internal' }

0 commit comments

Comments
 (0)