@@ -153,17 +153,17 @@ function createOAuthCallback({ runStepEmitter, runStepDeltaEmitter }) {
153153/**
154154 * @param {Object } params
155155 * @param {ServerResponse } params.res - The Express response object for sending events.
156- * @param {string } params.userId - The user ID from the request object.
156+ * @param {IUser } params.user - The user from the request object.
157157 * @param {string } params.serverName
158158 * @param {AbortSignal } params.signal
159159 * @param {string } params.model
160160 * @param {number } [params.index]
161161 * @param {Record<string, Record<string, string>> } [params.userMCPAuthMap]
162162 * @returns { Promise<Array<typeof tool | { _call: (toolInput: Object | string) => unknown}>> } An object with `_call` method to execute the tool input.
163163 */
164- async function reconnectServer ( { res, userId , index, signal, serverName, userMCPAuthMap } ) {
164+ async function reconnectServer ( { res, user , index, signal, serverName, userMCPAuthMap } ) {
165165 const runId = Constants . USE_PRELIM_RESPONSE_MESSAGE_ID ;
166- const flowId = `${ userId } :${ serverName } :${ Date . now ( ) } ` ;
166+ const flowId = `${ user . id } :${ serverName } :${ Date . now ( ) } ` ;
167167 const flowManager = getFlowStateManager ( getLogStores ( CacheKeys . FLOWS ) ) ;
168168 const stepId = 'step_oauth_login_' + serverName ;
169169 const toolCall = {
@@ -192,7 +192,7 @@ async function reconnectServer({ res, userId, index, signal, serverName, userMCP
192192 flowManager,
193193 } ) ;
194194 return await reinitMCPServer ( {
195- userId ,
195+ user ,
196196 signal,
197197 serverName,
198198 oauthStart,
@@ -212,7 +212,7 @@ async function reconnectServer({ res, userId, index, signal, serverName, userMCP
212212 *
213213 * @param {Object } params
214214 * @param {ServerResponse } params.res - The Express response object for sending events.
215- * @param {string } params.userId - The user ID from the request object.
215+ * @param {IUser } params.user - The user from the request object.
216216 * @param {string } params.serverName
217217 * @param {string } params.model
218218 * @param {Providers | EModelEndpoint } params.provider - The provider for the tool.
@@ -221,16 +221,8 @@ async function reconnectServer({ res, userId, index, signal, serverName, userMCP
221221 * @param {Record<string, Record<string, string>> } [params.userMCPAuthMap]
222222 * @returns { Promise<Array<typeof tool | { _call: (toolInput: Object | string) => unknown}>> } An object with `_call` method to execute the tool input.
223223 */
224- async function createMCPTools ( {
225- res,
226- userId,
227- index,
228- signal,
229- serverName,
230- provider,
231- userMCPAuthMap,
232- } ) {
233- const result = await reconnectServer ( { res, userId, index, signal, serverName, userMCPAuthMap } ) ;
224+ async function createMCPTools ( { res, user, index, signal, serverName, provider, userMCPAuthMap } ) {
225+ const result = await reconnectServer ( { res, user, index, signal, serverName, userMCPAuthMap } ) ;
234226 if ( ! result || ! result . tools ) {
235227 logger . warn ( `[MCP][${ serverName } ] Failed to reinitialize MCP server.` ) ;
236228 return ;
@@ -240,7 +232,7 @@ async function createMCPTools({
240232 for ( const tool of result . tools ) {
241233 const toolInstance = await createMCPTool ( {
242234 res,
243- userId ,
235+ user ,
244236 provider,
245237 userMCPAuthMap,
246238 availableTools : result . availableTools ,
@@ -258,7 +250,7 @@ async function createMCPTools({
258250 * Creates a single tool from the specified MCP Server via `toolKey`.
259251 * @param {Object } params
260252 * @param {ServerResponse } params.res - The Express response object for sending events.
261- * @param {string } params.userId - The user ID from the request object.
253+ * @param {IUser } params.user - The user from the request object.
262254 * @param {string } params.toolKey - The toolKey for the tool.
263255 * @param {string } params.model - The model for the tool.
264256 * @param {number } [params.index]
@@ -270,7 +262,7 @@ async function createMCPTools({
270262 */
271263async function createMCPTool ( {
272264 res,
273- userId ,
265+ user ,
274266 index,
275267 signal,
276268 toolKey,
@@ -288,7 +280,7 @@ async function createMCPTool({
288280 ) ;
289281 const result = await reconnectServer ( {
290282 res,
291- userId ,
283+ user ,
292284 index,
293285 signal,
294286 serverName,
0 commit comments