Skip to content

[enhancement] add struct support for NewToolResponse #128

@DURUII

Description

@DURUII
func(args WeatherArgs) (*mcp.ToolResponse, error) {
	return mcp.NewToolResponse(mcp.NewTextContent(
		fmt.Sprintf("%v", WeatherData{
			Temperature: 75.5,
			Conditions:  "sunny",
			Location:    args.Location,
		}),
	)), nil
})

this might not be that elegant, why should I use a fmt.Sprintf to build a response, while in python, it goes like:

@mcp.tool()
def get_weather(location: str) -> dict:
    """Gets current weather for a location."""
    # This would normally call a weather API
    # Simplified for demonstration
    return {
        "temperature": 72.5,
        "conditions": "Sunny",
        "location": location
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions