| 11 | } |
| 12 | |
| 13 | async function call(name: string, args: any) { |
| 14 | const client = new Client({ name: 'quick-test', version: '1.0.0' }) |
| 15 | const transport = new StreamableHTTPClientTransport(new URL(url), { fetch: fetchWithAuth }) |
| 16 | await client.connect(transport) |
| 17 | try { |
| 18 | const result = await client.callTool({ name, arguments: args }) |
| 19 | console.log(`\n=== ${name} ===`) |
| 20 | console.log(JSON.stringify(result, null, 2)) |
| 21 | } finally { |
| 22 | await client.close().catch(() => {}) |
| 23 | await transport.close().catch(() => {}) |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | async function main() { |
| 28 | await call('list_sites', {}) |