File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -258,6 +258,9 @@ export const Info = Schema.Struct({
258258 description :
259259 "Enable Anthropic's native tools (web_search_20260209, web_fetch_20260209) for Anthropic models" ,
260260 } ) ,
261+ sequential_mcp_tools : Schema . optional ( Schema . Boolean ) . annotate ( {
262+ description : "Execute MCP tool calls sequentially instead of in parallel" ,
263+ } ) ,
261264 } ) ,
262265 ) ,
263266} )
Original file line number Diff line number Diff line change @@ -455,15 +455,19 @@ NOTE: At any point in time through this workflow you should feel free to ask the
455455 } )
456456 }
457457
458+ const cfg = yield * config . get ( )
459+ const sequential = cfg . experimental ?. sequential_mcp_tools ?? false
460+ let mcpQueue = Promise . resolve < unknown > ( undefined )
461+
458462 for ( const [ key , item ] of Object . entries ( yield * mcp . tools ( ) ) ) {
459463 const execute = item . execute
460464 if ( ! execute ) continue
461465
462466 const schema = yield * Effect . promise ( ( ) => Promise . resolve ( asSchema ( item . inputSchema ) . jsonSchema ) )
463467 const transformed = ProviderTransform . schema ( input . model , schema )
464468 item . inputSchema = jsonSchema ( transformed )
465- item . execute = ( args , opts ) =>
466- run . promise (
469+ item . execute = ( args , opts ) => {
470+ const work = ( ) => run . promise (
467471 Effect . gen ( function * ( ) {
468472 const ctx = context ( args , opts )
469473 yield * plugin . trigger (
@@ -530,6 +534,13 @@ NOTE: At any point in time through this workflow you should feel free to ask the
530534 return output
531535 } ) ,
532536 )
537+ if ( sequential ) {
538+ const next = mcpQueue . then ( ( ) => work ( ) , ( ) => work ( ) )
539+ mcpQueue = next . then ( ( ) => { } , ( ) => { } )
540+ return next
541+ }
542+ return work ( )
543+ }
533544 tools [ key ] = item
534545 }
535546
You can’t perform that action at this time.
0 commit comments