dify-plugin-mcp_compat_dify_tools icon indicating copy to clipboard operation
dify-plugin-mcp_compat_dify_tools copied to clipboard

Failed to use in LobeChat (streamable HTTP)

Open CXwudi opened this issue 7 months ago • 7 comments

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

Dify version Dify版本

1.3.1

Plugin version 插件版本

0.1.1

HTTP with SSE or Streamable HTTP

Streamable HTTP

Problem description 问题描述

我想把自己的Dify上配置的Tavily插件以MCP的形式分享给别的客户端用(Cline, LobeChat 等等)

但是遇见了Internal Server Error: 400 Bad Request: Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)错误

Image

Image

尝试curl -v -X POST http://my-ip:8080/e/pa8uujinbkks3em5/messages/ -H "Content-Type:application/json"

得到:

400 Bad Request Curl Log

❯ curl -v -X POST http://192.168.1.39:3901/e/pa8uujinbkks3em5/messages/ -H "Content-Type:application/json"
*   Trying 192.168.1.39:3901...
* Connected to 192.168.1.39 (192.168.1.39) port 3901 (#0)
> POST /e/pa8uujinbkks3em5/messages/ HTTP/1.1
> Host: 192.168.1.39:3901
> User-Agent: curl/7.88.1
> Accept: */*
> Content-Type:application/json
>
< HTTP/1.1 500 Internal Server Error
< Server: nginx/1.27.5
< Date: Fri, 09 May 2025 01:58:29 GMT
< Content-Type: text/plain; charset=utf-8
< Content-Length: 111
< Connection: keep-alive
<
* Connection #0 to host 192.168.1.39 left intact
Internal Server Error: 400 Bad Request: Failed to decode JSON object: Expecting value: line 1 column 1 (char 0)%

CXwudi avatar May 09 '25 02:05 CXwudi

接口不是这么用的,你要测试也需要使用支持MCP SSE或MCP Streamable HTTP的客户端去测试。

junjiem avatar May 09 '25 02:05 junjiem

好吧,一开始我是用LobeChat连不上,才使用curl测试的,现在LobeChat又连上了

CXwudi avatar May 09 '25 02:05 CXwudi

good

junjiem avatar May 09 '25 02:05 junjiem

但是现在才发现lobechat虽然对接streamable MCP成功了,但调用还是有问题

Image

Image

CXwudi avatar May 13 '25 14:05 CXwudi

查看后台是否有具体的错误日志

junjiem avatar May 14 '25 01:05 junjiem

dify plugin deamon logs

2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '=' looking for beginning of value status:  original response: ===============tools==============
2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '\'' looking for beginning of object key string status:  original response: [{'enabled': True, 'extra': {'description': 'Extract web page content from one or more specified URLs using Tavily Extract.'}, 'parameters': {'extract_depth': {'auto': 1, 'value': None}, 'urls': {'auto': 1, 'value': None}}, 'provider_name': 'langgenius/tavily/tavily', 'schemas': [{'auto_generate': None, 'default': None, 'form': 'llm', 'human_description': {'en_US': 'One or more URLs to extract content from (comma-separated if multiple).', 'ja_JP': 'One or more URLs to extract content from (comma-separated if multiple).', 'pt_BR': 'One or more URLs to extract content from (comma-separated if multiple).', 'zh_Hans': '要从中提取内容的一个或多个 URL(如果有多个,请用逗号分隔)。'}, 'label': {'en_US': 'URLs', 'ja_JP': 'URLs', 'pt_BR': 'URLs', 'zh_Hans': 'URLs'}, 'llm_description': 'One or more URLs to extract content from (comma-separated if multiple).', 'max': None, 'min': None, 'name': 'urls', 'options': [], 'placeholder': None, 'precision': None, 'required': True, 'scope': None, 'tem...
[GIN] 2025/05/14 - 02:34:22 | 200 |    8.761808ms |    0.0.0.0 | POST     "/e/pa8uujinbkks3em5/mcp"
2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '=' looking for beginning of value status:  original response: ===============tools==============
2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '\'' looking for beginning of object key string status:  original response: [{'enabled': True, 'extra': {'description': 'Extract web page content from one or more specified URLs using Tavily Extract.'}, 'parameters': {'extract_depth': {'auto': 1, 'value': None}, 'urls': {'auto': 1, 'value': None}}, 'provider_name': 'langgenius/tavily/tavily', 'schemas': [{'auto_generate': None, 'default': None, 'form': 'llm', 'human_description': {'en_US': 'One or more URLs to extract content from (comma-separated if multiple).', 'ja_JP': 'One or more URLs to extract content from (comma-separated if multiple).', 'pt_BR': 'One or more URLs to extract content from (comma-separated if multiple).', 'zh_Hans': '要从中提取内容的一个或多个 URL(如果有多个,请用逗号分隔)。'}, 'label': {'en_US': 'URLs', 'ja_JP': 'URLs', 'pt_BR': 'URLs', 'zh_Hans': 'URLs'}, 'llm_description': 'One or more URLs to extract content from (comma-separated if multiple).', 'max': None, 'min': None, 'name': 'urls', 'options': [], 'placeholder': None, 'precision': None, 'required': True, 'scope': None, 'tem...
[GIN] 2025/05/14 - 02:34:22 | 202 |    6.360078ms |     0.0.0.0 | POST     "/e/pa8uujinbkks3em5/mcp"
2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '=' looking for beginning of value status:  original response: ===============tools==============
2025/05/14 02:34:22 stdio.go:157: [ERROR]plugin junjiem/mcp_compat_dify_tools:0.1.1: invalid character '\'' looking for beginning of object key string status:  original response: [{'enabled': True, 'extra': {'description': 'Extract web page content from one or more specified URLs using Tavily Extract.'}, 'parameters': {'extract_depth': {'auto': 1, 'value': None}, 'urls': {'auto': 1, 'value': None}}, 'provider_name': 'langgenius/tavily/tavily', 'schemas': [{'auto_generate': None, 'default': None, 'form': 'llm', 'human_description': {'en_US': 'One or more URLs to extract content from (comma-separated if multiple).', 'ja_JP': 'One or more URLs to extract content from (comma-separated if multiple).', 'pt_BR': 'One or more URLs to extract content from (comma-separated if multiple).', 'zh_Hans': '要从中提取内容的一个或多个 URL(如果有多个,请用逗号分隔)。'}, 'label': {'en_US': 'URLs', 'ja_JP': 'URLs', 'pt_BR': 'URLs', 'zh_Hans': 'URLs'}, 'llm_description': 'One or more URLs to extract content from (comma-separated if multiple).', 'max': None, 'min': None, 'name': 'urls', 'options': [], 'placeholder': None, 'precision': None, 'required': True, 'scope': None, 'tem...
[GIN] 2025/05/14 - 02:34:22 | 200 |    6.820617ms |     0.0.0.0 | POST     "/e/pa8uujinbkks3em5/mcp"
[GIN] 2025/05/14 - 02:34:22 | 405 |    5.764415ms |     0.0.0.0 | GET      "/e/pa8uujinbkks3em5/mcp"

不知道上面这个log是否有用, LobeChat那边的log反而调不出来, LobeChat我最多可以找到这个Manifest JSON:

Manifest JSON

{
  "api": [
    {
      "description": "Extract web page content from one or more specified URLs using Tavily Extract.",
      "name": "tavily_extract",
      "parameters": {
        "type": "object",
        "properties": {
          "urls": {
            "type": "string",
            "description": "One or more URLs to extract content from (comma-separated if multiple)."
          },
          "extract_depth": {
            "type": "select",
            "description": "Extraction depth - 'basic' (default, faster) or 'advanced' (more data, higher cost).",
            "enum": [
              "basic",
              "advanced"
            ]
          }
        },
        "required": [
          "urls"
        ]
      }
    },
    {
      "description": "A search engine tool built specifically for AI agents (LLMs), delivering real-time, accurate, and factual results at speed.",
      "name": "tavily_search",
      "parameters": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string",
            "description": "The search query."
          },
          "search_depth": {
            "type": "select",
            "description": "The depth of the search. 'basic' for standard search, 'advanced' for more comprehensive results.",
            "enum": [
              "basic",
              "advanced"
            ]
          },
          "topic": {
            "type": "select",
            "description": "The category of the search. Options include 'general', 'news', or 'finance'.",
            "enum": [
              "general",
              "news",
              "finance"
            ]
          },
          "days": {
            "type": "number",
            "description": "The number of days back from the current date to include in the search results. Only applicable when \"topic\" is \"news\"."
          },
          "time_range": {
            "type": "select",
            "description": "The time range back from the current date to filter results. Options include 'not_specified', 'day', 'week', 'month', or 'year'.",
            "enum": [
              "not_specified",
              "day",
              "week",
              "month",
              "year"
            ]
          }
        },
        "required": [
          "query"
        ]
      }
    }
  ],
  "meta": {
    "title": "Tavily-from-dify",
    "avatar": "MCP_AVATAR",
    "description": "Tavily-from-dify MCP server has 2 tools, like \"tavily_extract\""
  },
  "type": "mcp",
  "identifier": "Tavily-from-dify"
}

CXwudi avatar May 14 '25 02:05 CXwudi

这个日志只能看出来已经获取了工具列表信息,你上面问题是调用工具时的问题,你需要找到调用工具返回的信息才能确定问题点。

junjiem avatar May 14 '25 04:05 junjiem