dify-plugin-tools-mcp_sse icon indicating copy to clipboard operation
dify-plugin-tools-mcp_sse copied to clipboard

0.1.8 插件支持托管MCP server报错

Open chenly15 opened this issue 7 months ago • 4 comments

Please confirm before submission 在提交之前,请确认

Dify version Dify版本

dify cloud,具体版本不明

Plugin version 插件版本

0.1.8

HTTP with SSE or Streamable HTTP

Streamable HTTP

Problem description 问题描述

测试了 0.1.8,MCP.so的server通了,但是Zapier托管的MCP server仍然不行。

旧版的配置长这样

{
        "Zapier-MCP": {
            "transport": "sse",
            "url": "https://actions.zapier.com/mcp/sk-****/sse"
      }
}

报错信息为

Image

新版的配置长这样

{
        "Zapier-MCP": {
            "transport": "streamable_http",
            "url": "https://mcp.zapier.com/api/mcp/s/ODkwMDgxxxx/mcp"
        }
}

报错信息仍是

Image

想请教下这个问题出在哪。

我看Zapier-MCP python 给出的client例子也是基于fastmcp的,这个插件能不能改成fastmcp实现,可能能少很多问题?

chenly15 avatar May 27 '25 02:05 chenly15

插件中无法使用fastmcp作为客户端,fastmcp里面使用的是python mcp sdk,它的客户端实现使用的是async,在dify中并发运行时会出现无法并发执行多个异步任务的错误。

junjiem avatar May 27 '25 03:05 junjiem

Zapier streamable_http 报错是因为它返回的响应中没有content-type,没有content-type就无法确定响应内容是text/event-stream还是application/json,就无法对其返回内容进行针对性的解析。

junjiem avatar May 27 '25 03:05 junjiem

Zapier see 报错应该是它没有严格遵循JSON-RPC 2.0导致的,我后台看到的日志是:Error parsing request: 1 validation error for JsonRpcRequest\nid\n Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='e22c9cfd83d84f18af8720fe51eff7c9', input_type=str]\n For further information visit https://errors.pydantic.dev/2.7/v/int_parsing

Image

在 JSON-RPC 2.0 规范中,id 字段的类型可以是String或Number 。

Image

junjiem avatar May 27 '25 03:05 junjiem

插件中无法使用fastmcp作为客户端,fastmcp里面使用的是python mcp sdk,它的客户端实现使用的是async,在dify中并发运行时会出现无法并发执行多个异步任务的错误。

使用fastmcp应该能减少处理底层协议的问题,在client与server连接上似乎更容易点。关于在dify中并发执行async异步任务的问题,我可能不是特别理解,能不能通过asyncio来执行。

chenly15 avatar May 30 '25 03:05 chenly15