@@ -219,6 +219,18 @@ func (s *Agent) Init(ctx context.Context) error {
219
219
},
220
220
)
221
221
222
+ if s .MCPClientEnabled {
223
+ if err := s .InitializeMCPClient (ctx ); err != nil {
224
+ klog .Errorf ("Failed to initialize MCP client: %v" , err )
225
+ return fmt .Errorf ("failed to initialize MCP client: %w" , err )
226
+ }
227
+
228
+ // Update MCP status in session
229
+ if err := s .UpdateMCPStatus (ctx , s .MCPClientEnabled ); err != nil {
230
+ klog .Warningf ("Failed to update MCP status: %v" , err )
231
+ }
232
+ }
233
+
222
234
if ! s .EnableToolUseShim {
223
235
var functionDefinitions []* gollm.FunctionDefinition
224
236
for _ , tool := range s .Tools .AllTools () {
@@ -234,19 +246,6 @@ func (s *Agent) Init(ctx context.Context) error {
234
246
}
235
247
s .workDir = workDir
236
248
237
- // Initialize MCP client if enabled
238
- if s .MCPClientEnabled {
239
- if err := s .InitializeMCPClient (ctx ); err != nil {
240
- klog .Errorf ("Failed to initialize MCP client: %v" , err )
241
- return fmt .Errorf ("failed to initialize MCP client: %w" , err )
242
- }
243
-
244
- // Update MCP status in session
245
- if err := s .UpdateMCPStatus (ctx , s .MCPClientEnabled ); err != nil {
246
- klog .Warningf ("Failed to update MCP status: %v" , err )
247
- }
248
- }
249
-
250
249
return nil
251
250
}
252
251
0 commit comments