MCPcopy Create free account
hub / github.com/arctic-cli/interface / execute

Function execute

packages/arctic/src/tool/websearch.ts:61–149  ·  view source on GitHub ↗
(params, ctx)

Source from the content-addressed store, hash-verified

59 .describe("Maximum characters for context string optimized for LLMs (default: 10000)"),
60 }),
61 async execute(params, ctx) {
62 const cfg = await Config.get()
63 if (cfg.permission?.webfetch === "ask")
64 await Permission.ask({
65 type: "websearch",
66 sessionID: ctx.sessionID,
67 messageID: ctx.messageID,
68 callID: ctx.callID,
69 title: "Search web for: " + params.query,
70 metadata: {
71 query: params.query,
72 numResults: params.numResults,
73 livecrawl: params.livecrawl,
74 type: params.type,
75 contextMaxCharacters: params.contextMaxCharacters,
76 },
77 })
78
79 const searchRequest: McpSearchRequest = {
80 jsonrpc: "2.0",
81 id: 1,
82 method: "tools/call",
83 params: {
84 name: "web_search_exa",
85 arguments: {
86 query: params.query,
87 type: params.type || "auto",
88 numResults: params.numResults || API_CONFIG.DEFAULT_NUM_RESULTS,
89 livecrawl: params.livecrawl || "fallback",
90 contextMaxCharacters: params.contextMaxCharacters,
91 },
92 },
93 }
94
95 const controller = new AbortController()
96 const timeoutId = setTimeout(() => controller.abort(), 25000)
97
98 try {
99 const headers: Record<string, string> = {
100 accept: "application/json, text/event-stream",
101 "content-type": "application/json",
102 }
103
104 const response = await fetch(`${API_CONFIG.BASE_URL}${API_CONFIG.ENDPOINTS.SEARCH}`, {
105 method: "POST",
106 headers,
107 body: JSON.stringify(searchRequest),
108 signal: AbortSignal.any([controller.signal, ctx.abort]),
109 })
110
111 clearTimeout(timeoutId)
112
113 if (!response.ok) {
114 const errorText = await response.text()
115 throw new Error(`Search error (${response.status}): ${errorText}`)
116 }
117
118 const responseText = await response.text()

Callers

nothing calls this directly

Calls 4

textMethod · 0.65
fetchFunction · 0.50
getMethod · 0.45
abortMethod · 0.45

Tested by

no test coverage detected