Skip to content

[BUG] MCP返回的文本处理报错 #166

@tinyfam

Description

@tinyfam

Bug Description

用python写了一个mcp,在kode中调用报错

报错如下:

> 西安现在的天气如何

  ERROR  Text string "{"result":"📍 地点:西安\n🌡️ 温度:22° celsius\n☁️ 状况:晴"}" must be rendered inside <Text> component

python代码如下:

#!/usr/bin/env python3
from mcp.server.fastmcp import FastMCP
import json

mcp = FastMCP("WeatherService")

@mcp.tool()
def get_current_weather(location: str = "自动定位", format: str = "celsius") -> str:
    """查询指定地点的当前天气情况。"""

    # 业务逻辑
    temp = 22
    condition = "晴"

    # 构造一个纯文本字符串
    # 重点:不要包装在任何 [ ] 或 { } 中
    response_text = f"📍 地点:{location}\n🌡️ 温度:{temp}° {format}\n☁️ 状况:{condition}"

    return response_text

if __name__ == "__main__":
    mcp.run()

App and Environment Info

Kode Version: 2.0.3
OS: Ubuntu 24.04.1 LTS

Models

baseURL: kimi kimi-k2-0711-preview (kimi)
name:
maxTokens:
reasoning effort:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions