Skip to content

Commit d7b505f

Browse files
committed
fix(mcp): resolve userId before JWT generation for agent block auth
1 parent 34d210c commit d7b505f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/sim/tools/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,11 +1552,13 @@ async function executeMcpTool(
15521552

15531553
const baseUrl = getInternalApiBaseUrl()
15541554

1555+
const mcpScope = resolveToolScope(params, executionContext)
1556+
15551557
const headers: Record<string, string> = { 'Content-Type': 'application/json' }
15561558

15571559
if (typeof window === 'undefined') {
15581560
try {
1559-
const internalToken = await generateInternalToken(executionContext?.userId)
1561+
const internalToken = await generateInternalToken(mcpScope.userId)
15601562
headers.Authorization = `Bearer ${internalToken}`
15611563
} catch (error) {
15621564
logger.error(`[${actualRequestId}] Failed to generate internal token:`, error)
@@ -1587,8 +1589,6 @@ async function executeMcpTool(
15871589
)
15881590
}
15891591

1590-
const mcpScope = resolveToolScope(params, executionContext)
1591-
15921592
if (mcpScope.callChain && mcpScope.callChain.length > 0) {
15931593
headers[SIM_VIA_HEADER] = serializeCallChain(mcpScope.callChain)
15941594
}

0 commit comments

Comments
 (0)