MCPcopy Create free account
hub / github.com/anomalyco/opencode / call

Function call

packages/opencode/src/tool/mcp-websearch.ts:69–96  ·  view source on GitHub ↗
(
  http: HttpClient.HttpClient,
  url: string,
  tool: string,
  args: Schema.Struct<F>,
  value: Schema.Struct.Type<F>,
  timeout: Duration.Input,
  headers?: Record<string, string>,
)

Source from the content-addressed store, hash-verified

67 })
68
69export const call = <F extends Schema.Struct.Fields>(
70 http: HttpClient.HttpClient,
71 url: string,
72 tool: string,
73 args: Schema.Struct<F>,
74 value: Schema.Struct.Type<F>,
75 timeout: Duration.Input,
76 headers?: Record<string, string>,
77) =>
78 Effect.gen(function* () {
79 const request = yield* HttpClientRequest.post(url).pipe(
80 HttpClientRequest.accept("application/json, text/event-stream"),
81 HttpClientRequest.setHeaders(headers ?? {}),
82 HttpClientRequest.schemaBodyJson(McpRequest(args))({
83 jsonrpc: "2.0" as const,
84 id: 1 as const,
85 method: "tools/call" as const,
86 params: { name: tool, arguments: value },
87 }),
88 )
89 const response = yield* HttpClient.filterStatusOk(http)
90 .execute(request)
91 .pipe(
92 Effect.timeoutOrElse({ duration: timeout, orElse: () => Effect.die(new Error(`${tool} request timed out`)) }),
93 )
94 const body = yield* response.text
95 return yield* parseResponse(body)
96 })

Callers

nothing calls this directly

Calls 2

McpRequestFunction · 0.70
executeMethod · 0.65

Tested by

no test coverage detected