MCPcopy Create free account
hub / github.com/alexankitty/Myrient-Search-Engine / executeToolCall

Function executeToolCall

lib/ai/tools.js:76–102  ·  view source on GitHub ↗
(toolCall)

Source from the content-addressed store, hash-verified

74 * Execute a tool call
75 */
76export async function executeToolCall(toolCall) {
77 const { name, arguments: argsString } = toolCall.function;
78
79 try {
80 // Parse arguments from JSON string
81 let args;
82 try {
83 args = typeof argsString === 'string' ? JSON.parse(argsString) : argsString;
84 } catch (parseError) {
85 throw new Error(`Invalid JSON arguments for ${name}: ${parseError.message}`);
86 }
87
88 switch (name) {
89 case 'search_games':
90 return await searchGames(args);
91 case 'get_search_suggestions':
92 return await getSearchSuggestions(args);
93 default:
94 throw new Error(`Unknown tool: ${name}`);
95 }
96 } catch (error) {
97 console.error(`Tool execution error for ${name}:`, error);
98 return {
99 error: `Failed to execute ${name}: ${error.message}`
100 };
101 }
102}
103
104/**
105 * Search for games using the existing search infrastructure

Callers 1

server.jsFile · 0.85

Calls 2

searchGamesFunction · 0.85
getSearchSuggestionsFunction · 0.85

Tested by

no test coverage detected