mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
Jambonz support Model context protocol (MCP) (#1150)
* Jambonz support Model context protocol (MCP) * merged mcp tools with existing llmOptions.tools * support list of mcp servers * wip * wip * wip * fix voice agent * fix open-ai * fix review comment * fix deepgram voice agent * update verb specification version
This commit is contained in:
@@ -244,13 +244,36 @@ class TaskLlmElevenlabs_S2S extends Task {
|
||||
/* tool calls */
|
||||
else if (type === 'client_tool_call') {
|
||||
this.logger.debug({evt}, 'TaskLlmElevenlabs_S2S:_onServerEvent - function_call');
|
||||
if (!this.toolHook) {
|
||||
const {tool_name: name, tool_call_id: call_id, parameters: args} = evt.client_tool_call;
|
||||
|
||||
const mcpTools = this.parent.isMcpEnabled ? await this.parent.mcpService.getAvailableMcpTools() : [];
|
||||
if (mcpTools.some((tool) => tool.name === name)) {
|
||||
this.logger.debug({name, args}, 'TaskLlmElevenlabs_S2S:_onServerEvent - calling mcp tool');
|
||||
try {
|
||||
const res = await this.parent.mcpService.callMcpTool(name, args);
|
||||
this.logger.debug({res}, 'TaskLlmElevenlabs_S2S:_onServerEvent - function_call - mcp result');
|
||||
this.processToolOutput(ep, call_id, {
|
||||
data: {
|
||||
type: 'client_tool_result',
|
||||
tool_call_id: call_id,
|
||||
result: res.content?.length ? res.content[0] : res.content,
|
||||
is_error: false
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.info({err, evt}, 'TaskLlmElevenlabs_S2S - error calling mcp tool');
|
||||
this.results = {
|
||||
completionReason: 'client error calling mcp function',
|
||||
error: err
|
||||
};
|
||||
endConversation = true;
|
||||
}
|
||||
} else if (!this.toolHook) {
|
||||
this.logger.warn({evt}, 'TaskLlmElevenlabs_S2S:_onServerEvent - no toolHook defined!');
|
||||
}
|
||||
else {
|
||||
const {client_tool_call} = evt;
|
||||
const {tool_name: name, tool_call_id: call_id, parameters: args} = client_tool_call;
|
||||
|
||||
try {
|
||||
await this.parent.sendToolHook(call_id, {name, args});
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user