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

Function callHttpTool

core/tools/callTool.ts:28–50  ·  view source on GitHub ↗
(
  url: string,
  args: any,
  extras: ToolExtras,
)

Source from the content-addressed store, hash-verified

26import { coerceArgsToSchema, safeParseToolCallArgs } from "./parseArgs";
27
28async function callHttpTool(
29 url: string,
30 args: any,
31 extras: ToolExtras,
32): Promise<ContextItem[]> {
33 const response = await extras.fetch(url, {
34 method: "POST",
35 headers: {
36 "Content-Type": "application/json",
37 },
38 body: JSON.stringify({
39 arguments: args,
40 }),
41 });
42
43 const data = await response.json();
44
45 if (!response.ok) {
46 throw new Error(`Failed to call tool at ${url}:\n${JSON.stringify(data)}`);
47 }
48
49 return data.output;
50}
51
52export function encodeMCPToolUri(mcpId: string, toolName: string): string {
53 return `mcp://${encodeURIComponent(mcpId)}/${encodeURIComponent(toolName)}`;

Callers 1

callToolFromUriFunction · 0.85

Calls 1

fetchMethod · 0.65

Tested by

no test coverage detected