Skip to content

✨ [Feature]: 支持MCP工程返回结构化的数据 #315

@shenjunjian

Description

@shenjunjian

What problem does this feature solve

参考 MCP示例,编写一个工具返回结构化数据:

  server.registerTool(
    'add-one',
    {
      title: '计算小学数学加法',
      description: '计算小学数学加法时调用',
      inputSchema: { n: z.number() },
      outputSchema: {
        type: 'object',
        properties: {
          n: { type: 'number', description: '输入的数字' },
          add1: { type: 'number', description: '输入数字+1之后的值' }
        },
        required: ['n', 'add1']
      }
    },
    async ({ n }) => {
      const ret = {
        n: n,
        add1: n + 1
      }
      return {
        content: [{ type: 'text', text: JSON.stringify(ret) }],
        structuredContent: ret
      }
    }
  )

当 使用 AI-EXT插件访问时, 工具调用成功,但是ai-sdk的流消息中打印:

Image

当使用remoter 连接远程的网页时,工具调用失败:

Image

远程网页的网络面板中:

Image

综上, 本地调用 或 经过web-agent后台调用,都会有异常

What does the proposed API look like

期望 agent不报错

What is your project name

no

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