mcp-go icon indicating copy to clipboard operation
mcp-go copied to clipboard

When can CallToolResult support returning JSON formatted content

Open Dqiucheng opened this issue 8 months ago • 1 comments

When can CallToolResult support returning JSON formatted content

Dqiucheng avatar Apr 24 '25 07:04 Dqiucheng

When can CallToolResult support returning JSON formatted content

The MCP protocol itself does not care about the format of the text content; It just passes it as a string. If structured data needs to be returned, it can be serialized as a JSON string.

	jsonData := `{"id": "123", "name": "John Doe"}`
	callToolResult := &mcp.CallToolResult{
		Content: []mcp.Content{
			mcp.TextContent{
				Type: "text",
				Text: jsonData,
			},
		},
	}

cocovs avatar Apr 26 '25 04:04 cocovs

how to add CallToolResult field descriptions?

mengmengpengpeng avatar May 22 '25 06:05 mengmengpengpeng

@mengmengpengpeng Not sure I understand your question. Could you please clarify?

Currently the SDK supports sending results as described by the MCP spec: https://modelcontextprotocol.io/specification/2025-03-26/server/tools#tool-result

pottekkat avatar May 23 '25 01:05 pottekkat

ok

Dqiucheng avatar May 29 '25 01:05 Dqiucheng