Skip to content

fix CallToolResult json marshaling and unmarshaling: need structuredC… #523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 11, 2025
Merged
10 changes: 10 additions & 0 deletions mcp/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ func (r CallToolResult) MarshalJSON() ([]byte, error) {
}
m["content"] = content

// Marshal StructuredContent if present
if r.StructuredContent != nil {
m["structuredContent"] = r.StructuredContent
}

// Marshal IsError if true
if r.IsError {
m["isError"] = r.IsError
Expand Down Expand Up @@ -526,6 +531,11 @@ func (r *CallToolResult) UnmarshalJSON(data []byte) error {
}
}

// Unmarshal StructuredContent if present
if structured, ok := raw["structuredContent"]; ok {
r.StructuredContent = structured
}

// Unmarshal IsError
if isError, ok := raw["isError"]; ok {
if isErrorBool, ok := isError.(bool); ok {
Expand Down
Loading