modelcontextprotocol / modelcontextprotocol/kotlin-sdk

Should CallToolResult.structuredContent be a JsonArray?

Open
#221 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api enhancement P3 ready for work
Dominant language
Kotlin
Stars
1.5k
Forks
248
Avg merge
1d 20h
Merged PRs (30d)
23

Description

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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in kotlin-sdk-core/src/commonMain/kotlin/io/modelcontextprotocol/kotlin/sdk/types.kt at the CallToolResult definition around line 1210, then compare its structuredContent type with the MCP result schema and the MCP Inspector warning. Done means the expected representation and client compatibility are established, with the implementation or issue documentation aligned accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.