rust-sdk/crates/rmcp/tests/test_with_js/client.js
4t145 09474d4769
fix(test): skip serialize tool's annotation if empty (#160)
* fix(test): skip serialize tool's annotation if empty

1. skip serialize tool's annotation if empty
2. close js server and client when close

* fix(test): fix test with js, don't close too early
2025-05-07 15:22:24 +08:00

29 lines
No EOL
763 B
JavaScript

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
const transport = new SSEClientTransport(new URL(`http://127.0.0.1:8000/sse`));
const client = new Client(
{
name: "example-client",
version: "1.0.0"
},
{
capabilities: {
prompts: {},
resources: {},
tools: {}
}
}
);
await client.connect(transport);
const tools = await client.listTools();
console.log(tools);
const resources = await client.listResources();
console.log(resources);
const templates = await client.listResourceTemplates();
console.log(templates);
const prompts = await client.listPrompts();
console.log(prompts);
await client.close();
await transport.close();