@@ -38,6 +38,7 @@ import ConnectionsIndex from '@/views/connections/index.vue'
38
38
import { CopilotMessage , CopilotRole , CopilotPresetPrompt , StreamError } from ' @/types/copilot'
39
39
import { needsUserInput } from ' @/utils/ai/preset'
40
40
import { SessionManager } from ' @/utils/ai/SessionManager'
41
+ import { callMCPTool , MCP_CALL_REGEX , processMCPCalls } from ' @/utils/ai/mcp'
41
42
42
43
@Component ({
43
44
components: {
@@ -72,6 +73,10 @@ export default class Copilot extends Vue {
72
73
content: ' ' ,
73
74
}
74
75
76
+ get shouldProcessMCP() {
77
+ return localStorage .getItem (' mcpEnabled' ) === ' true' && this .sessionManager .getState ().mcpData ?.hasMCP === true
78
+ }
79
+
75
80
/**
76
81
* Finds the current connection record from ConnectionsDetail component
77
82
* Returns undefined if no record is found
@@ -155,8 +160,8 @@ export default class Copilot extends Vue {
155
160
this .currentPublishMsg = ' '
156
161
}
157
162
158
- private buildMessageHistory(): Array <{ role: CopilotRole ; content: string }> {
159
- const systemPrompt = this .sessionManager .getSystemPrompt (this .currentLang )
163
+ private async buildMessageHistory(): Promise < Array <{ role: CopilotRole ; content: string }> > {
164
+ const systemPrompt = await this .sessionManager .getSystemPrompt (this .currentLang )
160
165
161
166
return [
162
167
{
@@ -207,7 +212,7 @@ export default class Copilot extends Vue {
207
212
apiKey ,
208
213
}),
209
214
temperature: 0.8 ,
210
- messages: this .buildMessageHistory (),
215
+ messages: await this .buildMessageHistory (),
211
216
abortSignal: this .abortController .signal ,
212
217
onError: this .handleStreamError ,
213
218
})
@@ -218,7 +223,15 @@ export default class Copilot extends Vue {
218
223
this .$nextTick (throttledScroll )
219
224
}
220
225
221
- responseMessage .content = this .responseStreamText
226
+ if (this .shouldProcessMCP ) {
227
+ const processedContent = await processMCPCalls (this .responseStreamText )
228
+ responseMessage .content = processedContent
229
+ // AI TOOL CALL RESULT
230
+ console .log (processedContent )
231
+ } else {
232
+ responseMessage .content = this .responseStreamText
233
+ }
234
+
222
235
await this .saveAndDisplayResponse (responseMessage )
223
236
}
224
237
@@ -331,6 +344,17 @@ export default class Copilot extends Vue {
331
344
}
332
345
}
333
346
347
+ /**
348
+ * Lifecycle hook when component is mounted
349
+ */
350
+ private async mounted() {
351
+ // Reload MCP data when component is mounted
352
+ await this .sessionManager .reloadMCPData (this .currentLang )
353
+ }
354
+
355
+ /**
356
+ * Lifecycle hook when component is created
357
+ */
334
358
private created() {
335
359
this .loadMessages ({ reset: true })
336
360
}
@@ -377,4 +401,73 @@ export default class Copilot extends Vue {
377
401
}
378
402
}
379
403
}
404
+
405
+ /* MCP Tool Call result styles */
406
+ mcp-result {
407
+ display : block ;
408
+ margin : 8px 0 ;
409
+ padding : 12px ;
410
+ border-radius : 6px ;
411
+ font-family : monospace ;
412
+ white-space : pre-wrap ;
413
+ }
414
+
415
+ mcp-result [success = ' true' ] {
416
+ background-color : rgba (19 , 206 , 102 , 0.1 );
417
+ border : 1px solid rgba (19 , 206 , 102 , 0.3 );
418
+ }
419
+
420
+ mcp-result [success = ' false' ] {
421
+ background-color : rgba (245 , 108 , 108 , 0.1 );
422
+ border : 1px solid rgba (245 , 108 , 108 , 0.3 );
423
+ }
424
+
425
+ mcp-result server,
426
+ mcp-result tool,
427
+ mcp-result args {
428
+ display : block ;
429
+ margin-bottom : 4px ;
430
+ font-weight : bold ;
431
+ }
432
+
433
+ mcp-result server::before {
434
+ content : ' Server: ' ;
435
+ color : var (--color-text-light );
436
+ }
437
+
438
+ mcp-result tool::before {
439
+ content : ' Tool: ' ;
440
+ color : var (--color-text-light );
441
+ }
442
+
443
+ mcp-result args::before {
444
+ content : ' Arguments: ' ;
445
+ color : var (--color-text-light );
446
+ }
447
+
448
+ mcp-result result,
449
+ mcp-result error {
450
+ display : block ;
451
+ margin-top : 8px ;
452
+ padding : 8px ;
453
+ background-color : var (--color-bg-lighter );
454
+ border-radius : 4px ;
455
+ overflow-x : auto ;
456
+ }
457
+
458
+ mcp-result result::before {
459
+ content : ' Result:' ;
460
+ display : block ;
461
+ margin-bottom : 4px ;
462
+ font-weight : bold ;
463
+ color : var (--color-text-light );
464
+ }
465
+
466
+ mcp-result error::before {
467
+ content : ' Error:' ;
468
+ display : block ;
469
+ margin-bottom : 4px ;
470
+ font-weight : bold ;
471
+ color : var (--color-text-light );
472
+ }
380
473
</style >
0 commit comments