Skip to content

Commit 09474d4

Browse files
authored
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
1 parent afb8a90 commit 09474d4

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

crates/rmcp/src/model/tool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub struct Tool {
1818
pub description: Option<Cow<'static, str>>,
1919
/// A JSON Schema object defining the expected parameters for the tool
2020
pub input_schema: Arc<JsonObject>,
21+
#[serde(skip_serializing_if = "Option::is_none")]
2122
/// Optional additional tool information.
2223
pub annotations: Option<ToolAnnotations>,
2324
}

crates/rmcp/tests/test_with_js/client.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
22
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
33

4-
const transport = new SSEClientTransport( new URL(`http://127.0.0.1:8000/sse`));
4+
const transport = new SSEClientTransport(new URL(`http://127.0.0.1:8000/sse`));
55

66
const client = new Client(
77
{
@@ -26,3 +26,4 @@ console.log(templates);
2626
const prompts = await client.listPrompts();
2727
console.log(prompts);
2828
await client.close();
29+
await transport.close();

crates/rmcp/tests/test_with_js/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ server.tool(
3232
);
3333

3434
const transport = new StdioServerTransport();
35-
await server.connect(transport);
35+
await server.connect(transport);

0 commit comments

Comments
 (0)