Skip to content

MCP responses are double wrapped/encoded #2704

Description

@jftkcs

Describe the bug

agenticChatController.ts wraps the mcpTool.ts json-stringified tool result from mcpManager.ts

Produces an extremely cursed token monster when it receives any kind of structured result, even if the MCP server offers the "text" kind for clients not aware of structured responses....

To reproduce
Worst case: Call an mcp server that returns a structured result (or basically anything JSON)
Normal case: Call an mcp server, this still double-encodes the MCP sdk result.

Expected behavior
If structured content, return output kind: OutputKind.Json...
If not (or can't be bothered implementing) return kind text and just pass through the mcpmanager's text result.

Screenshots

{
  "json": {
    "output": {
      "kind": "text",
      "content": "{\"content\":[{\"type\":\"text\":\"{\\\\"tooldata\\\\":\\\\"toolstuff\\\\"........"
    }
  }
}

Your Environment

  • OS:

Additional context

Activity

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

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