Skip to content

MCP: structuredContent in tool result overrides content[].text sent to model #290063

Open
MikeyVK/phase-gate-mcp
#309

Description

Problem

When an MCP tool returns both content[].text and structuredContent, VS Code ignores the content array and only sends JSON.stringify(structuredContent) to the language model.

Evidence from source

In mcpLanguageModelToolContribution.ts:

Lines 307-323 — text content is skipped when structuredContent exists:

if (isForModel && !callResult.structuredContent) {
    result.content.push({ kind: 'text', audience, value: item.text });
}

Lines 366-378 — only stringified structuredContent is sent:

if (callResult.structuredContent) {
    result.content.push({ kind: 'text', value: JSON.stringify(callResult.structuredContent), audience: [LanguageModelPartAudience.Assistant] });
}

Expected behavior (per MCP spec)

Per the MCP specification, CallToolResult has:

  • content — human-readable result (text, images, etc.) for the model/user
  • structuredContent — machine-readable structured data conforming to outputSchema

Both should be available. The spec doesn't indicate structuredContent should replace content.

Actual behavior

When structuredContent is present:

  1. Text items in content are skipped (if (!callResult.structuredContent))
  2. Only JSON.stringify(structuredContent) is sent to the model

Impact

Tools cannot provide both:

  • A human-readable markdown analysis for the model to understand context
  • Structured data for programmatic use / UI rendering (e.g., MCP Apps)

Example: A flame graph profiler tool wants to return:

  • content[].text: Markdown analysis with findings and recommendations
  • structuredContent: Profile data object for an interactive UI

Currently, the model only sees raw JSON of the profile data, losing the analysis.

Suggested fix

Either:

  1. Send both content[].text AND the stringified structuredContent to the model
  2. Add a tool annotation to control behavior (e.g., structuredContentOnly: true)
  3. Clarify if this is intentional and update MCP spec accordingly

Reproduction

  1. Create an MCP tool that returns both content and structuredContent
  2. Invoke it in VS Code Copilot
  3. Observe that the model only receives the stringified structured content

Example repo: https://github.com/digitarald/mcp-apps-playground (flame_graph tool)

Version

VS Code Insiders, January 2026

Activity

  1. added
    bug
    and removed on Jan 24, 2026
  2. connor4312 commented on Jan 29, 2026

    @connor4312
    Member

    It turns out structuredContent actually should not be presented to the model, its use case is PTC. Discussion here: modelcontextprotocol/modelcontextprotocol#1624

  3. harrykitewing commented on Apr 21, 2026

    @harrykitewing

    Any update or ETA on this? VSCode not adhering to the spec tripped us up in prod @ Kitewing.

  4. pamelafox commented on Jul 30, 2026

    @pamelafox
    Member

    I encountered this with a Fabric Data Agent MCP tool in VS Code. The tool returned the full human-readable answer in content[].text, while structuredContent contained only:

    {
      "deepLinkUrl": "...",
      "artifactName": "ContosoDIYDataAgent"
    }
    

    VS Code displayed the full answer in the tool-call UI, but the subsequent model input contained only the stringified structuredContent. Copilot therefore knew a result existed but could not access the actual answer, so it kept trying to do calls to get a real answer (unsuccessfully).

  5. dcasati commented on Sep 23, 2026

    @dcasati

    I reproduced this with Microsoft Fabric IQ on:

    • VS Code 1.139.0
    • VS Code Insiders 1.140.0-insider
    • macOS 26.6.2

    The MCP CallToolResult contained both:

    {
      "content": [
        {
          "type": "text",
          "text": "{\"executionResult\":[/* complete query rows */]}"
        }
      ],
      "structuredContent": {
        "contentReference": "/* citation metadata only */"
      }
    }

    The same MCP request through Copilot CLI returned the complete rows to the model.

    I locally changed:

    if (isForModel && !callResult.structuredContent) {

    to:

    if (isForModel) {

    in mcpLanguageModelToolContribution.ts. After rebuilding/patching VS Code, the
    same Fabric IQ query returned the complete rows to the model successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-host-mitigatedbugchat-mcp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions