MCPcopy
hub / github.com/anomalyco/opencode / fetch

Function fetch

packages/opencode/src/cli/tui/worker.ts:31–49  ·  view source on GitHub ↗
(input: { url: string; method: string; headers: Record<string, string>; body?: string })

Source from the content-addressed store, hash-verified

29
30export const rpc = {
31 async fetch(input: { url: string; method: string; headers: Record<string, string>; body?: string }) {
32 const headers = { ...input.headers }
33 const auth = ServerAuth.header()
34 if (auth && !headers["authorization"] && !headers["Authorization"]) {
35 headers["Authorization"] = auth
36 }
37 const request = new Request(input.url, {
38 method: input.method,
39 headers,
40 body: input.body,
41 })
42 const response = await Server.Default().app.fetch(request)
43 const body = await response.text()
44 return {
45 status: response.status,
46 headers: Object.fromEntries(response.headers.entries()),
47 body,
48 }
49 },
50 snapshot() {
51 const result = writeHeapSnapshot("server.heapsnapshot")
52 return result

Callers 8

waitForHealthFunction · 0.50
mcp.tsFile · 0.50
tryFetchFunction · 0.50
getInstallationFunction · 0.50
getUserPromptFunction · 0.50
exchangeForAppTokenFunction · 0.50
revokeAppTokenFunction · 0.50
providers.tsFile · 0.50

Calls 2

fetchMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected