|
13 | 13 | export let handleAgentChange = () => {}; |
14 | 14 |
|
15 | 15 | export const fetchMcpTools = () => { |
16 | | - const candidates = innerTools?.filter(x => !!x.name)?.map(x => { |
| 16 | + const candidates = innerMcps?.filter(x => !!x.name)?.map(x => { |
17 | 17 | /** @type {import('$commonTypes').NameBase[]} */ |
18 | 18 | const functions = []; |
19 | 19 |
|
|
50 | 50 | } |
51 | 51 |
|
52 | 52 | export const fetchOriginalMcpTools = () => { |
53 | | - return innerTools; |
| 53 | + return innerMcps; |
54 | 54 | } |
55 | 55 |
|
56 | 56 | export const refresh = () => init(); |
57 | 57 |
|
58 | 58 | /** @type {any[]} */ |
59 | | - let toolOptions = []; |
| 59 | + let mcpOptions = []; |
60 | 60 |
|
61 | 61 | /** @type {import('$agentTypes').AgentMcpTool[]} */ |
62 | | - let innerTools = []; |
| 62 | + let innerMcps = []; |
63 | 63 |
|
64 | 64 |
|
65 | 65 | onMount(async () => { |
|
70 | 70 | name: x.name |
71 | 71 | }; |
72 | 72 | }) || []; |
73 | | - toolOptions = [ |
| 73 | + mcpOptions = [ |
74 | 74 | { |
75 | 75 | id: '', |
76 | 76 | name: '' |
77 | 77 | }, |
78 | 78 | ...list |
79 | 79 | ]; |
80 | 80 | }).catch(() => { |
81 | | - toolOptions = []; |
| 81 | + mcpOptions = []; |
82 | 82 | }); |
83 | 83 | init(); |
84 | 84 | }); |
|
95 | 95 |
|
96 | 96 | /** @param {import('$agentTypes').AgentMcpTool[]} list */ |
97 | 97 | function innerRefresh(list) { |
98 | | - innerTools = list?.map(x => { |
| 98 | + innerMcps = list?.map(x => { |
99 | 99 | return { |
100 | 100 | name: x.name, |
101 | 101 | server_id: x.server_id, |
|
110 | 110 | * @param {number} idx |
111 | 111 | */ |
112 | 112 | function changeTool(e, idx) { |
113 | | - const found = innerTools.find((_, index) => index === idx); |
| 113 | + const found = innerMcps.find((_, index) => index === idx); |
114 | 114 | if (!found) return; |
115 | 115 | |
116 | 116 | 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 || ''; |
118 | 118 |
|
119 | 119 | found.name = name; |
120 | 120 | found.server_id = val; |
121 | | - innerRefresh(innerTools); |
| 121 | + innerRefresh(innerMcps); |
122 | 122 | handleAgentChange(); |
123 | 123 | } |
124 | 124 |
|
125 | 125 | function addTool() { |
126 | | - innerTools = [ |
127 | | - ...innerTools, |
| 126 | + innerMcps = [ |
| 127 | + ...innerMcps, |
128 | 128 | { |
129 | 129 | name: '', |
130 | 130 | server_id: '', |
|
137 | 137 |
|
138 | 138 | /** @param {number} idx */ |
139 | 139 | function deleteTool(idx) { |
140 | | - innerTools = innerTools.filter((_, index) => index !== idx); |
| 140 | + innerMcps = innerMcps.filter((_, index) => index !== idx); |
141 | 141 | handleAgentChange(); |
142 | 142 | } |
143 | 143 |
|
|
146 | 146 | * @param {number} uid |
147 | 147 | */ |
148 | 148 | function toggleTool(e, uid) { |
149 | | - const found = innerTools.find((_, index) => index === uid); |
| 149 | + const found = innerMcps.find((_, index) => index === uid); |
150 | 150 | if (!found) return; |
151 | 151 |
|
152 | 152 | found.disabled = !e.target.checked; |
153 | | - innerRefresh(innerTools); |
| 153 | + innerRefresh(innerMcps); |
154 | 154 | handleAgentChange(); |
155 | 155 | } |
156 | 156 |
|
|
161 | 161 | * @param {string} type |
162 | 162 | */ |
163 | 163 | function changeContent(e, tid, id, type) { |
164 | | - const found = innerTools.find((_, index) => index === tid); |
| 164 | + const found = innerMcps.find((_, index) => index === tid); |
165 | 165 | if (!found) return; |
166 | 166 |
|
167 | 167 | const val = e.target.value; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 |
|
175 | | - innerRefresh(innerTools); |
| 175 | + innerRefresh(innerMcps); |
176 | 176 | handleAgentChange(); |
177 | 177 | } |
178 | 178 |
|
|
181 | 181 | * @param {string} type |
182 | 182 | */ |
183 | 183 | function addToolContent(id, type) { |
184 | | - const found = innerTools.find((_, index) => index === id); |
| 184 | + const found = innerMcps.find((_, index) => index === id); |
185 | 185 | if (!found || found.disabled) return; |
186 | 186 |
|
187 | 187 | if (type === 'function') { |
188 | 188 | found.functions.push({ name: '' }); |
189 | 189 | } |
190 | 190 |
|
191 | | - innerRefresh(innerTools); |
| 191 | + innerRefresh(innerMcps); |
192 | 192 | handleAgentChange(); |
193 | 193 | } |
194 | 194 |
|
|
198 | 198 | * @param {string} type |
199 | 199 | */ |
200 | 200 | function deleteToolContent(uid, id, type) { |
201 | | - const found = innerTools.find((_, index) => index === uid); |
| 201 | + const found = innerMcps.find((_, index) => index === uid); |
202 | 202 | if (!found || found.disabled) return; |
203 | 203 |
|
204 | 204 | if (type === 'function') { |
205 | 205 | const fns = found.functions?.filter((_, index) => index !== id) || []; |
206 | 206 | found.functions = fns; |
207 | 207 | } |
208 | 208 | |
209 | | - innerRefresh(innerTools); |
| 209 | + innerRefresh(innerMcps); |
210 | 210 | handleAgentChange(); |
211 | 211 | } |
212 | 212 | </script> |
213 | 213 |
|
214 | 214 | <Card> |
215 | 215 | <CardBody> |
216 | 216 | <div class="text-center"> |
217 | | - <h5 class="mt-1 mb-3">MCP Tools</h5> |
| 217 | + <h5 class="mt-1 mb-3">MCP</h5> |
218 | 218 | </div> |
219 | 219 |
|
220 | 220 | <div class="agent-utility-container"> |
221 | | - {#each innerTools as tool, uid (uid)} |
| 221 | + {#each innerMcps as tool, uid (uid)} |
222 | 222 | <div class="utility-wrapper"> |
223 | 223 | <div class="utility-row utility-row-primary"> |
224 | 224 | <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> |
226 | 226 | <div class="utility-tooltip"> |
227 | 227 | <div class="line-align-center"> |
228 | 228 | <Input |
|
235 | 235 | class="line-align-center" |
236 | 236 | data-bs-toggle="tooltip" |
237 | 237 | data-bs-placement="top" |
238 | | - title="Uncheck to disable tool" |
| 238 | + title="Uncheck to disable MCP" |
239 | 239 | > |
240 | 240 | <i class="bx bx-info-circle" /> |
241 | 241 | </div> |
|
248 | 248 | disabled={tool.disabled} |
249 | 249 | on:change={e => changeTool(e, uid)} |
250 | 250 | > |
251 | | - {#each [...toolOptions] as option} |
| 251 | + {#each [...mcpOptions] as option} |
252 | 252 | <option value={option.id} selected={option.id == tool.server_id}> |
253 | 253 | {option.displayName || option.name} |
254 | 254 | </option> |
|
335 | 335 | </div> |
336 | 336 | {/each} |
337 | 337 |
|
338 | | - {#if innerTools.length < limit} |
| 338 | + {#if innerMcps.length < limit} |
339 | 339 | <div class="add-utility"> |
340 | 340 | <Button color="primary" on:click={() => addTool()}> |
341 | 341 | <span> |
342 | 342 | <i class="bx bx-plus" /> |
343 | | - <span>Add Tool</span> |
| 343 | + <span>Add MCP</span> |
344 | 344 | </span> |
345 | 345 | </Button> |
346 | 346 | </div> |
|
0 commit comments