test.js•703 B
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
(async () => {
const transport = new StdioClientTransport({
command: 'node',
args: ['build/index.js']
});
const client = new Client({ name: 'test-client', version: '1.0.0' });
await client.connect(transport);
const res1 = await client.callTool({
name: 'sum',
arguments: { a: 20.12, b: 123456 }
});
console.log(JSON.stringify(res1, null, 2));
const res2 = await client.callTool({
name: 'subtraction',
arguments: { a: 12345, b: 2345 }
});
console.log(JSON.stringify(res2, null, 2));
process.exit(0);
})();