(client: Client, timeout: number)
| 143 | } |
| 144 | |
| 145 | function listTools(client: Client, timeout: number) { |
| 146 | return Effect.tryPromise({ |
| 147 | try: () => |
| 148 | paginate( |
| 149 | async (cursor) => { |
| 150 | const params = cursor === undefined ? undefined : { cursor } |
| 151 | try { |
| 152 | return await client.listTools(params, { timeout }) |
| 153 | } catch (error) { |
| 154 | if (!(error instanceof Error) || !isOutputSchemaValidationError(error)) throw error |
| 155 | return client.request({ method: "tools/list", params }, TolerantListToolsResultSchema, { timeout }) |
| 156 | } |
| 157 | }, |
| 158 | (result) => result.tools, |
| 159 | ), |
| 160 | catch: (error) => (error instanceof Error ? error : new Error(String(error))), |
| 161 | }) |
| 162 | } |
| 163 | |
| 164 | function isOutputSchemaValidationError(error: Error) { |
| 165 | return /can't resolve reference|resolves to more than one schema|outputSchema|schema.*reference|reference.*schema/i.test( |
no test coverage detected