-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-client.js
More file actions
45 lines (36 loc) · 970 Bytes
/
test-client.js
File metadata and controls
45 lines (36 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "node",
args: ["index.js"]
});
const client = new Client(
{
name: "crypto-test-client",
version: "1.0.0"
}
);
await client.connect(transport);
// List available tools
console.log("Available tools:");
const tools = await client.listTools();
console.log(tools);
// Test the get_crypto_price tool
console.log("\nTesting crypto price tool with 'bitcoin':");
const result = await client.callTool({
name: "get_crypto_price",
arguments: {
symbol: "bitcoin"
}
});
console.log(result);
// Test with another cryptocurrency
console.log("\nTesting crypto price tool with 'ethereum':");
const result2 = await client.callTool({
name: "get_crypto_price",
arguments: {
symbol: "ethereum"
}
});
console.log(result2);
await client.close();