MCPcopy Index your code
hub / github.com/anomalyco/opencode / listTools

Function listTools

packages/opencode/src/mcp/catalog.ts:145–162  ·  view source on GitHub ↗
(client: Client, timeout: number)

Source from the content-addressed store, hash-verified

143}
144
145function 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
164function isOutputSchemaValidationError(error: Error) {
165 return /can't resolve reference|resolves to more than one schema|outputSchema|schema.*reference|reference.*schema/i.test(

Callers 1

defsFunction · 0.85

Calls 4

paginateFunction · 0.85
listToolsMethod · 0.45
requestMethod · 0.45

Tested by

no test coverage detected