Skip to content

Should CallToolResult.structuredContent be a JsonArray? #221

@JoseAlcerreca

Description

@JoseAlcerreca

Given that CallToolResult.content is a List<PromptMessageContent>, I'd expect structuredContent to be a JsonArray, but it's a JsonObject.

I can wrap the results in an object with something like

           CallToolResult(
               content = jsonResult.toPromptMessageContent(), // Converts array to list of TextContent
               structuredContent = buildJsonObject { put("results", jsonResult) }
           )

However, when using the MCP Inspector, I get this warning:

⚠ No text block matches structured content

Which makes me think this implementation might be incompatible with some clients. A workaround can be:

            val wrapperResult = buildJsonObject { put("results", jsonResult) }
            CallToolResult(
                content = listOf(TextContent(wrapperResult.toString())),
                structuredContent = wrapperResult
            )

But passing a single item to content doesn't look optimal.

Is this the recommended approach or am I missing something? Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions