Skip to content

Commit e493277

Browse files
authored
Merge pull request #336 from iceljc/features/refine-chat-window
add mcp display
2 parents ee73070 + 7affba7 commit e493277

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

src/routes/chat/[agentId]/[conversationId]/agent-info/chat-agent-info.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
<span>{agent?.functions?.length || 0} {agent?.functions?.length > 1 ? 'functions' : 'function'}{', '}</span>
3636
{/if}
3737
{#if !!agent?.utilities}
38-
<span>{agent?.utilities?.length || 0} {agent?.utilities?.length > 1 ? 'utilities' : 'utility'}</span>
38+
<span>{agent?.utilities?.length || 0} {agent?.utilities?.length > 1 ? 'utilities' : 'utility'}{', '}</span>
39+
{/if}
40+
{#if !!agent?.mcp_tools}
41+
<span>{agent?.mcp_tools?.length || 0} {agent?.mcp_tools?.length > 1 ? 'MCPs' : 'MCP'}</span>
3942
{/if}
4043
</div>
4144
</div>

src/routes/page/agent/[agentId]/agent-components/agent-mcp-tool.svelte

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
export let handleAgentChange = () => {};
1414
1515
export const fetchMcpTools = () => {
16-
const candidates = innerTools?.filter(x => !!x.name)?.map(x => {
16+
const candidates = innerMcps?.filter(x => !!x.name)?.map(x => {
1717
/** @type {import('$commonTypes').NameBase[]} */
1818
const functions = [];
1919
@@ -50,16 +50,16 @@
5050
}
5151
5252
export const fetchOriginalMcpTools = () => {
53-
return innerTools;
53+
return innerMcps;
5454
}
5555
5656
export const refresh = () => init();
5757
5858
/** @type {any[]} */
59-
let toolOptions = [];
59+
let mcpOptions = [];
6060
6161
/** @type {import('$agentTypes').AgentMcpTool[]} */
62-
let innerTools = [];
62+
let innerMcps = [];
6363
6464
6565
onMount(async () => {
@@ -70,15 +70,15 @@
7070
name: x.name
7171
};
7272
}) || [];
73-
toolOptions = [
73+
mcpOptions = [
7474
{
7575
id: '',
7676
name: ''
7777
},
7878
...list
7979
];
8080
}).catch(() => {
81-
toolOptions = [];
81+
mcpOptions = [];
8282
});
8383
init();
8484
});
@@ -95,7 +95,7 @@
9595
9696
/** @param {import('$agentTypes').AgentMcpTool[]} list */
9797
function innerRefresh(list) {
98-
innerTools = list?.map(x => {
98+
innerMcps = list?.map(x => {
9999
return {
100100
name: x.name,
101101
server_id: x.server_id,
@@ -110,21 +110,21 @@
110110
* @param {number} idx
111111
*/
112112
function changeTool(e, idx) {
113-
const found = innerTools.find((_, index) => index === idx);
113+
const found = innerMcps.find((_, index) => index === idx);
114114
if (!found) return;
115115
116116
const val = e.target.value;
117-
const name = toolOptions.find(x => x.id == val)?.name || '';
117+
const name = mcpOptions.find(x => x.id == val)?.name || '';
118118
119119
found.name = name;
120120
found.server_id = val;
121-
innerRefresh(innerTools);
121+
innerRefresh(innerMcps);
122122
handleAgentChange();
123123
}
124124
125125
function addTool() {
126-
innerTools = [
127-
...innerTools,
126+
innerMcps = [
127+
...innerMcps,
128128
{
129129
name: '',
130130
server_id: '',
@@ -137,7 +137,7 @@
137137
138138
/** @param {number} idx */
139139
function deleteTool(idx) {
140-
innerTools = innerTools.filter((_, index) => index !== idx);
140+
innerMcps = innerMcps.filter((_, index) => index !== idx);
141141
handleAgentChange();
142142
}
143143
@@ -146,11 +146,11 @@
146146
* @param {number} uid
147147
*/
148148
function toggleTool(e, uid) {
149-
const found = innerTools.find((_, index) => index === uid);
149+
const found = innerMcps.find((_, index) => index === uid);
150150
if (!found) return;
151151
152152
found.disabled = !e.target.checked;
153-
innerRefresh(innerTools);
153+
innerRefresh(innerMcps);
154154
handleAgentChange();
155155
}
156156
@@ -161,7 +161,7 @@
161161
* @param {string} type
162162
*/
163163
function changeContent(e, tid, id, type) {
164-
const found = innerTools.find((_, index) => index === tid);
164+
const found = innerMcps.find((_, index) => index === tid);
165165
if (!found) return;
166166
167167
const val = e.target.value;
@@ -172,7 +172,7 @@
172172
}
173173
}
174174
175-
innerRefresh(innerTools);
175+
innerRefresh(innerMcps);
176176
handleAgentChange();
177177
}
178178
@@ -181,14 +181,14 @@
181181
* @param {string} type
182182
*/
183183
function addToolContent(id, type) {
184-
const found = innerTools.find((_, index) => index === id);
184+
const found = innerMcps.find((_, index) => index === id);
185185
if (!found || found.disabled) return;
186186
187187
if (type === 'function') {
188188
found.functions.push({ name: '' });
189189
}
190190
191-
innerRefresh(innerTools);
191+
innerRefresh(innerMcps);
192192
handleAgentChange();
193193
}
194194
@@ -198,31 +198,31 @@
198198
* @param {string} type
199199
*/
200200
function deleteToolContent(uid, id, type) {
201-
const found = innerTools.find((_, index) => index === uid);
201+
const found = innerMcps.find((_, index) => index === uid);
202202
if (!found || found.disabled) return;
203203
204204
if (type === 'function') {
205205
const fns = found.functions?.filter((_, index) => index !== id) || [];
206206
found.functions = fns;
207207
}
208208
209-
innerRefresh(innerTools);
209+
innerRefresh(innerMcps);
210210
handleAgentChange();
211211
}
212212
</script>
213213
214214
<Card>
215215
<CardBody>
216216
<div class="text-center">
217-
<h5 class="mt-1 mb-3">MCP Tools</h5>
217+
<h5 class="mt-1 mb-3">MCP</h5>
218218
</div>
219219
220220
<div class="agent-utility-container">
221-
{#each innerTools as tool, uid (uid)}
221+
{#each innerMcps as tool, uid (uid)}
222222
<div class="utility-wrapper">
223223
<div class="utility-row utility-row-primary">
224224
<div class="utility-label fw-bold">
225-
<div class="line-align-center">{`Tool #${uid + 1}`}</div>
225+
<div class="line-align-center">{`MCP #${uid + 1}`}</div>
226226
<div class="utility-tooltip">
227227
<div class="line-align-center">
228228
<Input
@@ -235,7 +235,7 @@
235235
class="line-align-center"
236236
data-bs-toggle="tooltip"
237237
data-bs-placement="top"
238-
title="Uncheck to disable tool"
238+
title="Uncheck to disable MCP"
239239
>
240240
<i class="bx bx-info-circle" />
241241
</div>
@@ -248,7 +248,7 @@
248248
disabled={tool.disabled}
249249
on:change={e => changeTool(e, uid)}
250250
>
251-
{#each [...toolOptions] as option}
251+
{#each [...mcpOptions] as option}
252252
<option value={option.id} selected={option.id == tool.server_id}>
253253
{option.displayName || option.name}
254254
</option>
@@ -335,12 +335,12 @@
335335
</div>
336336
{/each}
337337
338-
{#if innerTools.length < limit}
338+
{#if innerMcps.length < limit}
339339
<div class="add-utility">
340340
<Button color="primary" on:click={() => addTool()}>
341341
<span>
342342
<i class="bx bx-plus" />
343-
<span>Add Tool</span>
343+
<span>Add MCP</span>
344344
</span>
345345
</Button>
346346
</div>

0 commit comments

Comments
 (0)