@@ -83,8 +83,6 @@ export class AgentBlockHandler implements BlockHandler {
8383 streaming : streamingConfig . shouldUseStreaming ?? false ,
8484 } )
8585
86- this . logRequestDetails ( providerRequest , messages , streamingConfig )
87-
8886 return this . executeProviderRequest ( providerRequest , block , responseFormat , context )
8987 }
9088
@@ -153,16 +151,6 @@ export class AgentBlockHandler implements BlockHandler {
153151 private async formatTools ( inputTools : ToolInput [ ] , context : ExecutionContext ) : Promise < any [ ] > {
154152 if ( ! Array . isArray ( inputTools ) ) return [ ]
155153
156- logger . info ( `[AgentHandler] formatTools called with ${ inputTools . length } tools` , {
157- tools : inputTools . map ( ( t ) => ( {
158- type : t . type ,
159- usageControl : t . usageControl ,
160- params : t . params ,
161- } ) ) ,
162- hasWorkspaceId : ! ! context . workspaceId ,
163- workspaceId : context . workspaceId ,
164- } )
165-
166154 const tools = await Promise . all (
167155 inputTools
168156 . filter ( ( tool ) => {
@@ -235,7 +223,7 @@ export class AgentBlockHandler implements BlockHandler {
235223 isCustomTool : true ,
236224 _context : {
237225 workflowId : context . workflowId ,
238- workspaceId : context . workspaceId , // Include workspaceId for MCP tools
226+ workspaceId : context . workspaceId ,
239227 } ,
240228 } ,
241229 false , // skipProxy
@@ -254,20 +242,16 @@ export class AgentBlockHandler implements BlockHandler {
254242 }
255243
256244 private async createMcpTool ( tool : ToolInput , context : ExecutionContext ) : Promise < any > {
257- // Extract MCP tool information from the tool input
258245 const { serverId, toolName, params } = tool . params || { }
259246
260247 if ( ! serverId || ! toolName ) {
261248 logger . error ( 'MCP tool missing required parameters:' , { serverId, toolName } )
262249 return null
263250 }
264251
265- // Fetch tool schema from MCP server via API
266252 try {
267- // Prepare headers with internal authentication
268253 const headers : Record < string , string > = { 'Content-Type' : 'application/json' }
269254
270- // Add internal authorization for server-side calls
271255 if ( typeof window === 'undefined' ) {
272256 try {
273257 const { generateInternalToken } = await import ( '@/lib/auth/internal' )
@@ -279,15 +263,13 @@ export class AgentBlockHandler implements BlockHandler {
279263 }
280264 }
281265
282- // Add workspaceId and workflowId to the URL for workspace scoping (required by MCP API)
283266 const url = new URL ( `${ process . env . NEXT_PUBLIC_APP_URL } /api/mcp/tools/discover` )
284267 url . searchParams . set ( 'serverId' , serverId )
285268 if ( context . workspaceId ) {
286269 url . searchParams . set ( 'workspaceId' , context . workspaceId )
287270 } else {
288271 throw new Error ( 'workspaceId is required for MCP tool discovery' )
289272 }
290- // Add workflowId for internal JWT authentication context
291273 if ( context . workflowId ) {
292274 url . searchParams . set ( 'workflowId' , context . workflowId )
293275 } else {
@@ -312,8 +294,6 @@ export class AgentBlockHandler implements BlockHandler {
312294 throw new Error ( `MCP tool ${ toolName } not found on server ${ serverId } ` )
313295 }
314296
315- // Transform MCP tool schema to agent-compatible format
316- // Don't double-prefix if serverId already starts with 'mcp-'
317297 const toolId = serverId . startsWith ( 'mcp-' )
318298 ? `${ serverId } -${ toolName } `
319299 : `mcp-${ serverId } -${ toolName } `
@@ -327,10 +307,8 @@ export class AgentBlockHandler implements BlockHandler {
327307 executeFunction : async ( callParams : Record < string , any > ) => {
328308 logger . info ( `Executing MCP tool ${ toolName } on server ${ serverId } ` )
329309
330- // Prepare headers with internal authentication
331310 const headers : Record < string , string > = { 'Content-Type' : 'application/json' }
332311
333- // Add internal authorization for server-side calls
334312 if ( typeof window === 'undefined' ) {
335313 try {
336314 const { generateInternalToken } = await import ( '@/lib/auth/internal' )
@@ -342,7 +320,6 @@ export class AgentBlockHandler implements BlockHandler {
342320 }
343321 }
344322
345- // Call MCP tool execution API
346323 const execResponse = await fetch (
347324 `${ process . env . NEXT_PUBLIC_APP_URL } /api/mcp/tools/execute` ,
348325 {
@@ -352,7 +329,7 @@ export class AgentBlockHandler implements BlockHandler {
352329 serverId,
353330 toolName,
354331 arguments : { ...params , ...callParams } ,
355- workspaceId : context . workspaceId , // Pass workspace context for scoping
332+ workspaceId : context . workspaceId ,
356333 } ) ,
357334 }
358335 )
@@ -368,7 +345,6 @@ export class AgentBlockHandler implements BlockHandler {
368345 throw new Error ( result . error || 'MCP tool execution failed' )
369346 }
370347
371- // Transform MCP result to standard tool output format
372348 return {
373349 success : true ,
374350 output : result . data . output || { } ,
@@ -558,7 +534,7 @@ export class AgentBlockHandler implements BlockHandler {
558534 azureApiVersion : inputs . azureApiVersion ,
559535 responseFormat,
560536 workflowId : context . workflowId ,
561- workspaceId : context . workspaceId , // Include workspaceId for MCP tools
537+ workspaceId : context . workspaceId ,
562538 stream : streaming ,
563539 messages,
564540 environmentVariables : context . environmentVariables || { } ,
@@ -586,12 +562,6 @@ export class AgentBlockHandler implements BlockHandler {
586562 )
587563 }
588564
589- private logRequestDetails (
590- providerRequest : any ,
591- messages : Message [ ] | undefined ,
592- _streamingConfig : StreamingConfig
593- ) { }
594-
595565 private async executeProviderRequest (
596566 providerRequest : any ,
597567 block : SerializedBlock ,
@@ -655,7 +625,7 @@ export class AgentBlockHandler implements BlockHandler {
655625 azureApiVersion : providerRequest . azureApiVersion ,
656626 responseFormat : providerRequest . responseFormat ,
657627 workflowId : providerRequest . workflowId ,
658- workspaceId : providerRequest . workspaceId , // Include workspaceId for MCP tools
628+ workspaceId : providerRequest . workspaceId ,
659629 stream : providerRequest . stream ,
660630 messages : 'messages' in providerRequest ? providerRequest . messages : undefined ,
661631 environmentVariables : context . environmentVariables || { } ,
0 commit comments