( http: HttpClient.HttpClient, url: string, tool: string, args: Schema.Struct<F>, value: Schema.Struct.Type<F>, timeout: Duration.Input, headers?: Record<string, string>, )
| 67 | }) |
| 68 | |
| 69 | export 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 | }) |
nothing calls this directly
no test coverage detected