The official MCP TypeScript client library (@modelcontextprotocol/client 2.4.0)
- 01Install it:
npm install @modelcontextprotocol/client@2.4.0(Node.js 22 or later). - 02Connect, list the tools and call one:
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
const client = new Client({ name: 'my-app', version: '1.0.0' });
await client.connect(new StreamableHTTPClientTransport(new URL('https://camerarisk.com/mcp')));
const { tools } = await client.listTools();
console.log(tools.map((t) => t.name).join(', '));
const result = await client.callTool({ name: 'search_camera_models', arguments: { query: 'rlc-410w' } });
console.log(result.content[0].text);
await client.close();