File tree Expand file tree Collapse file tree 4 files changed +28
-4
lines changed
common/src/templates/initial-agents-dir/types Expand file tree Collapse file tree 4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -141,12 +141,12 @@ export type MCPConfig =
141141 command : string
142142 args ?: string [ ]
143143 env ?: Record < string , string >
144- headers ?: Record < string , string >
145144 }
146145 | {
147146 type ?: 'http' | 'sse'
148147 url : string
149148 params ?: Record < string , string >
149+ headers ?: Record < string , string >
150150 }
151151
152152// ============================================================================
Original file line number Diff line number Diff line change @@ -141,12 +141,12 @@ export type MCPConfig =
141141 command : string
142142 args ?: string [ ]
143143 env ?: Record < string , string >
144- headers ?: Record < string , string >
145144 }
146145 | {
147146 type ?: 'http' | 'sse'
148147 url : string
149148 params ?: Record < string , string >
149+ headers ?: Record < string , string >
150150 }
151151
152152// ============================================================================
Original file line number Diff line number Diff line change @@ -134,12 +134,12 @@ export type MCPConfig =
134134 command : string
135135 args ?: string [ ]
136136 env ?: Record < string , string >
137- headers ?: Record < string , string >
138137 }
139138 | {
140139 type ?: 'http' | 'sse'
141140 url : string
142141 params ?: Record < string , string >
142+ headers ?: Record < string , string >
143143 }
144144
145145// ============================================================================
Original file line number Diff line number Diff line change 66 getCancelledAdditionalMessages ,
77} from '@codebuff/agent-runtime/util/messages'
88import { MAX_AGENT_STEPS_DEFAULT } from '@codebuff/common/constants/agents'
9- import { getMCPClient , listMCPTools } from '@codebuff/common/mcp/client'
9+ import { getMCPClient , listMCPTools , callMCPTool } from '@codebuff/common/mcp/client'
1010import { toOptionalFile } from '@codebuff/common/old-constants'
1111import { toolNames } from '@codebuff/common/tools/constants'
1212import { clientToolCallSchema } from '@codebuff/common/tools/list'
@@ -552,6 +552,30 @@ async function handleToolCall({
552552 const toolName = action . toolName
553553 const input = action . input
554554
555+ // Handle MCP tool calls when mcpConfig is present
556+ if ( action . mcpConfig ) {
557+ try {
558+ const mcpClientId = await getMCPClient ( action . mcpConfig )
559+ const result = await callMCPTool ( mcpClientId , {
560+ name : toolName ,
561+ arguments : input ,
562+ } )
563+ return { output : result }
564+ } catch ( error ) {
565+ return {
566+ output : [
567+ {
568+ type : 'json' ,
569+ value : {
570+ errorMessage :
571+ error instanceof Error ? error . message : String ( error ) ,
572+ } ,
573+ } ,
574+ ] ,
575+ }
576+ }
577+ }
578+
555579 let result : ToolResultOutput [ ]
556580 if ( toolNames . includes ( toolName as ToolName ) ) {
557581 clientToolCallSchema . parse ( action )
You can’t perform that action at this time.
0 commit comments