( catalog: readonly Tool[], schemaReads: string[] = [], lists: string[] = [], )
| 57 | |
| 58 | /** Exercise the existing list/schema seam and record which schemas were requested. */ |
| 59 | const toolPort = ( |
| 60 | catalog: readonly Tool[], |
| 61 | schemaReads: string[] = [], |
| 62 | lists: string[] = [], |
| 63 | ): McpToolsPort => ({ |
| 64 | list: (filter) => |
| 65 | Effect.sync(() => { |
| 66 | lists.push("list"); |
| 67 | return catalog.filter( |
| 68 | (tool) => |
| 69 | (filter?.integration === undefined || tool.integration === filter.integration) && |
| 70 | (filter?.owner === undefined || tool.owner === filter.owner) && |
| 71 | (filter?.connection === undefined || tool.connection === filter.connection), |
| 72 | ); |
| 73 | }), |
| 74 | schema: (address) => |
| 75 | Effect.sync(() => { |
| 76 | schemaReads.push(String(address)); |
| 77 | const tool = catalog.find((item) => item.address === address); |
| 78 | if (!tool) return null; |
| 79 | return { |
| 80 | address, |
| 81 | name: tool.name, |
| 82 | description: tool.description, |
| 83 | inputSchema: tool.inputSchema, |
| 84 | annotations: tool.annotations, |
| 85 | } satisfies ToolSchemaView; |
| 86 | }), |
| 87 | }); |
| 88 | |
| 89 | /** A stub engine that records every executed code string and answers with a |
| 90 | * fixed value, so a test can prove a passthrough call became the expected |
no test coverage detected