8000 fix(tools): add `omitempty` to properties (#116) · mark3labs/mcp-go@7335e3a · GitHub
[go: up one dir, main page]

Skip to content

Commit 7335e3a

Browse files
authored
fix(tools): add omitempty to properties (#116)
When there is no input to a tool, the `Properies` map is `nil` if the Tool is not created using `NewTool`. This causes the `property` field to be set to `null` and clients such as `claude-desktop` to skip the tools silently. Annotating the field as `omitempty` is inline with the behavior of the [typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk/blob/fbdeb06a4185ba2f7581603a768cd7171c64d6fc/src/types.ts#L749).
1 parent 342c14d commit 7335e3a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-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"`
108+
Properties map[string]interface{} `json:"properties,omitempty"`
109109
Required []string `json:"required,omitempty"`
110110
}
111111

0 commit comments

Comments
 (0)
0