Skip to content

Commit 6a57878

Browse files
author
Jicheng Lu
committed
add mcp tool config
1 parent 80a4c74 commit 6a57878

File tree

16 files changed

+458
-44
lines changed

16 files changed

+458
-44
lines changed

src/lib/helpers/http.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ function skipLoader(config) {
110110
new RegExp('http(s*)://(.*?)/conversation/state/keys', 'g'),
111111
new RegExp('http(s*)://(.*?)/logger/instruction/log/keys', 'g'),
112112
new RegExp('http(s*)://(.*?)/logger/conversation/(.*?)/content-log', 'g'),
113-
new RegExp('http(s*)://(.*?)/logger/conversation/(.*?)/state-log', 'g')
113+
new RegExp('http(s*)://(.*?)/logger/conversation/(.*?)/state-log', 'g'),
114+
new RegExp('http(s*)://(.*?)/mcp/server-configs', 'g')
114115
];
115116

116117
if (config.method === 'post' && postRegexes.some(regex => regex.test(config.url || ''))) {

src/lib/helpers/types/agentTypes.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* @property {boolean} merge_utility - Merge utility
5858
* @property {number?} [max_message_count]
5959
* @property {AgentUtility[]} utilities - The agent utilities.
60+
* @property {any[]} mcp_tools - The agent mcp tools
6061
* @property {AgentKnowledgeBase[]} knowledge_bases - The agent knowledge bases.
6162
* @property {Date} created_datetime
6263
* @property {Date} updated_datetime
@@ -131,8 +132,16 @@
131132
* @typedef {Object} AgentUtility
132133
* @property {string} name
133134
* @property {boolean} disabled
134-
* @property {UtilityBase[]} functions
135-
* @property {UtilityBase[]} templates
135+
* @property {import('$commonTypes').NameBase[]} functions
136+
* @property {import('$commonTypes').NameBase[]} templates
137+
*/
138+
139+
/**
140+
* @typedef {Object} AgentMcpTool
141+
* @property {string} name
142+
* @property {string} server_id
143+
* @property {boolean} disabled
144+
* @property {import('$commonTypes').NameBase[]} functions
136145
*/
137146

138147
/**
@@ -152,12 +161,6 @@
152161
* @property {boolean} disabled
153162
*/
154163

155-
/**
156-
* @typedef {Object} UtilityBase
157-
* @property {string} name
158-
* @property {string?} [displayName]
159-
*/
160-
161164

162165
/**
163166
* @typedef {Object} AgentTaskSearchOption

src/lib/helpers/types/commonTypes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@
5858
* @property {any} payload
5959
*/
6060

61+
/**
62+
* @typedef {Object} NameBase
63+
* @property {string} name
64+
* @property {string?} [displayName]
65+
*/
66+
6167
export default {};

src/lib/helpers/types/mcpTypes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @typedef {Object} McpServerConfigModel
3+
* @property {string} id - The server id.
4+
* @property {string} name - The server name.
5+
* @property {string} transportType - The transport type.
6+
*/
7+
8+
export default {};

src/lib/services/api-endpoints.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export const endpoints = {
112112
dashConversationInstructionUrl: `${host}/dashboard/component/conversation`,
113113

114114
// Google geocode api
115-
addressUrl: `${host}/address/options`
115+
addressUrl: `${host}/address/options`,
116+
117+
mcpServerConfigsUrl: `${host}/mcp/server-configs`
116118
}
117119

src/lib/services/mcp-service.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { endpoints } from '$lib/services/api-endpoints.js';
2+
import axios from 'axios';
3+
4+
/**
5+
* Get mcp server configs
6+
* @returns {Promise<import('$mcpTypes').McpServerConfigModel[]>}
7+
*/
8+
export async function getServerConfigs() {
9+
const url = endpoints.mcpServerConfigsUrl;
10+
const response = await axios.get(url);
11+
return response.data;
12+
}

src/routes/page/agent/[agentId]/+page.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@
187187
return data ? {
188188
utilities: data.utilities || [],
189189
knowledge_bases: data.knwoledgebases || [],
190-
rules: data.rules || []
190+
rules: data.rules || [],
191+
mcp_tools: data.mcpTools || []
191192
} : null;
192193
}
193194
@@ -198,6 +199,7 @@
198199
agent.utilities = data.utilities || [];
199200
agent.knowledge_bases = data.knwoledgebases || [];
200201
agent.rules = data.rules || [];
202+
agent.mcp_tools = data.mcpTools || [];
201203
}
202204
}
203205

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
e.preventDefault();
9595
const value = e.target.value;
9696
selected_instruction.instruction = value || '';
97+
handleAgentChange();
9798
}
9899
99100
function addChannel() {
@@ -107,6 +108,7 @@
107108
];
108109
109110
selected_instruction = inner_instructions[inner_instructions.length-1];
111+
handleAgentChange();
110112
}
111113
112114
/** @param {string | undefined} uid */
@@ -115,6 +117,7 @@
115117
if (selected_instruction.uid === uid) {
116118
selected_instruction = inner_instructions[0];
117119
}
120+
handleAgentChange();
118121
}
119122
</script>
120123
@@ -161,7 +164,7 @@
161164
data-bs-placement="top"
162165
title="Add channel instruction"
163166
style="font-size: 16px;"
164-
on:click={() => { addChannel(); handleAgentChange(); }}
167+
on:click={() => addChannel()}
165168
>
166169
<i class="mdi mdi-plus-circle-outline" />
167170
</div>
@@ -187,7 +190,7 @@
187190
maxEditLength={20}
188191
editPlaceholder={'Type a channel here...'}
189192
onClick={() => selectChannel(inst.uid)}
190-
onDelete={() => { deleteChannel(inst.uid); handleAgentChange(); }}
193+
onDelete={() => deleteChannel(inst.uid)}
191194
onInput={handleAgentChange}
192195
/>
193196
{/each}
@@ -199,7 +202,7 @@
199202
style="scrollbar-width: thin; resize: none;"
200203
value={selected_instruction.instruction}
201204
rows={20}
202-
on:input={(e) => { changePrompt(e); handleAgentChange(); }}
205+
on:input={(e) => changePrompt(e)}
203206
placeholder="Enter your instruction"
204207
/>
205208
</FormGroup>

src/routes/page/agent/[agentId]/agent-components/agent-knowledge-base.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
const vals = e.target.value.split("#");
9797
found.name = vals[0];
9898
found.type = vals[1];
99-
handleAgentChange();
10099
innerRefresh(innerKnowledgeBases);
100+
handleAgentChange();
101101
}
102102
103103
/**
@@ -111,8 +111,8 @@
111111
const value = e.target.value;
112112
const confidence = validateConfidenceNumber(value);
113113
found.confidence = confidence;
114-
handleAgentChange();
115114
innerRefresh(innerKnowledgeBases);
115+
handleAgentChange();
116116
}
117117
118118
/** @param {any} e */
@@ -166,8 +166,8 @@
166166
if (!found) return;
167167
168168
found.disabled = !e.target.checked;
169-
handleAgentChange();
170169
innerRefresh(innerKnowledgeBases);
170+
handleAgentChange();
171171
}
172172
173173

0 commit comments

Comments
 (0)