Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(mcp): resolve userId before JWT generation for agent block auth
  • Loading branch information
waleedlatif1 committed Apr 4, 2026
commit d7b505fdd2932bfcdd53a56eed8ff5c59ea8a648
6 changes: 3 additions & 3 deletions apps/sim/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,11 +1552,13 @@ async function executeMcpTool(

const baseUrl = getInternalApiBaseUrl()

const mcpScope = resolveToolScope(params, executionContext)

const headers: Record<string, string> = { 'Content-Type': 'application/json' }

if (typeof window === 'undefined') {
try {
const internalToken = await generateInternalToken(executionContext?.userId)
const internalToken = await generateInternalToken(mcpScope.userId)
Comment thread
waleedlatif1 marked this conversation as resolved.
headers.Authorization = `Bearer ${internalToken}`
} catch (error) {
logger.error(`[${actualRequestId}] Failed to generate internal token:`, error)
Expand Down Expand Up @@ -1587,8 +1589,6 @@ async function executeMcpTool(
)
}

const mcpScope = resolveToolScope(params, executionContext)

if (mcpScope.callChain && mcpScope.callChain.length > 0) {
headers[SIM_VIA_HEADER] = serializeCallChain(mcpScope.callChain)
}
Expand Down
Loading