Skip to content

Commit cc17cf0

Browse files
committed
[tool-meta] feedback
1 parent e58af76 commit cc17cf0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mcp/tools_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,3 +1426,24 @@ func TestToolMetaMarshaling(t *testing.T) {
14261426
assert.Contains(t, result, "_meta", "Tool with Meta should include _meta field")
14271427
assert.Equal(t, meta, result["_meta"], "_meta field should match expected value")
14281428
}
1429+
1430+
func TestToolMetaMarshalingOmitsWhenNil(t *testing.T) {
1431+
// Marshal a tool without Meta
1432+
data, err := json.Marshal(Tool{
1433+
Name: "test-tool-no-meta",
1434+
Description: "A test tool without meta data",
1435+
InputSchema: ToolInputSchema{
1436+
Type: "object",
1437+
Properties: map[string]any{},
1438+
},
1439+
})
1440+
assert.NoError(t, err)
1441+
1442+
// Unmarshal to map
1443+
var result map[string]any
1444+
err = json.Unmarshal(data, &result)
1445+
assert.NoError(t, err)
1446+
1447+
// Check that _meta field is not present
1448+
assert.NotContains(t, result, "_meta", "Tool without Meta should not include _meta field")
1449+
}

0 commit comments

Comments
 (0)