Skip to content

Commit 82eaeff

Browse files
authored
bugfix: skip omitempty at tools[].inputSchema.properties (#86)
Signed-off-by: ajatprabha <ajat.prabha.leo@gmail.com>
1 parent b355006 commit 82eaeff

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

mcp/tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (t Tool) MarshalJSON() ([]byte, error) {
105105

106106
type ToolInputSchema struct {
107107
Type string `json:"type"`
108-
Properties map[string]interface{} `json:"properties,omitempty"`
108+
Properties map[string]interface{} `json:"properties"`
109109
Required []string `json:"required,omitempty"`
110110
}
111111

mcp/tools_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,24 @@ func TestUnmarshalToolWithoutRawSchema(t *testing.T) {
142142
assert.Empty(t, toolUnmarshalled.InputSchema.Required)
143143
assert.Empty(t, toolUnmarshalled.RawInputSchema)
144144
}
145+
146+
func TestMarshalToolWithoutInputSchemaProperties(t *testing.T) {
147+
tool := NewTool("empty-input-schema-tool",
148+
WithDescription("A tool with no input schema properties"),
149+
)
150+
151+
data, err := json.Marshal(tool)
152+
assert.Nil(t, err)
153+
154+
expected := json.RawMessage(`{
155+
"description": "A tool with no input schema properties",
156+
"inputSchema": {
157+
"type": "object",
158+
"properties": {}
159+
},
160+
"name": "empty-input-schema-tool"
161+
}
162+
`)
163+
164+
assert.JSONEq(t, string(expected), string(data))
165+
}

0 commit comments

Comments
 (0)