MCPcopy
hub / github.com/continuedev/continue / callTool

Function callTool

core/tools/callTool.ts:235–280  ·  view source on GitHub ↗
(
  tool: Tool,
  toolCall: ToolCall,
  extras: ToolExtras,
)

Source from the content-addressed store, hash-verified

233// Returns an error context item if the tool call fails
234// Note: Edit tool is handled on client
235export async function callTool(
236 tool: Tool,
237 toolCall: ToolCall,
238 extras: ToolExtras,
239): Promise<{
240 contextItems: ContextItem[];
241 errorMessage: string | undefined;
242 errorReason?: ContinueErrorReason;
243 mcpUiState?: McpUiState;
244}> {
245 try {
246 const args = safeParseToolCallArgs(toolCall);
247 const { contextItems, mcpUiState } = tool.uri
248 ? await callToolFromUri(tool.uri, args, extras)
249 : {
250 contextItems: await callBuiltInTool(tool.function.name, args, extras),
251 };
252 if (tool.faviconUrl) {
253 contextItems.forEach((item) => {
254 item.icon = tool.faviconUrl;
255 });
256 }
257
258 return {
259 contextItems,
260 errorMessage: undefined,
261 mcpUiState,
262 };
263 } catch (e) {
264 let errorMessage = `${e}`;
265 let errorReason: ContinueErrorReason | undefined;
266
267 if (e instanceof ContinueError) {
268 errorMessage = e.message;
269 errorReason = e.reason;
270 } else if (e instanceof Error) {
271 errorMessage = e.message;
272 }
273
274 return {
275 contextItems: [],
276 errorMessage,
277 errorReason,
278 };
279 }
280}

Callers 1

handleToolCallMethod · 0.90

Calls 3

safeParseToolCallArgsFunction · 0.90
callToolFromUriFunction · 0.85
callBuiltInToolFunction · 0.85

Tested by

no test coverage detected