MCP ExplorerExplorer

Dify Plugin Tools Mcp Config During Use V2

@YoFoonon 10 months ago
2 MIT
FreeCommunity
AI Systems
A Dify plugin for configuring MCP connections and tools during use via HTTP.

Overview

What is Dify Plugin Tools Mcp Config During Use V2

dify-plugin-tools-mcp_config_during_use_v2 is a Dify plugin that facilitates the configuration of Model Context Protocol (MCP) connections during runtime, allowing users to discover and call tools via MCP protocol using HTTP with SSE or Streamable HTTP transport.

Use cases

Use cases include dynamically configuring connections to different MCP servers, retrieving a list of tools available on an MCP server, and invoking specific tools for processing data or executing commands in real-time.

How to use

To use dify-plugin-tools-mcp_config_during_use_v2, you can utilize the provided tools: ‘mcp_list_tools’ to list available tools on an MCP server and ‘mcp_call_tool’ to call a specific tool. You need to provide parameters such as server URL, transport method, HTTP headers, and timeout settings.

Key features

Key features include the ability to configure MCP server connection information for each call, list available tools, call specific tools, configure HTTP headers for authorization, set different timeout parameters, and support both SSE and Streamable HTTP transport methods.

Where to use

dify-plugin-tools-mcp_config_during_use_v2 can be used in various fields where MCP connections are required, such as cloud services, data processing applications, and real-time communication systems.

Content

MCP Config During Use

A Dify plugin that allows configuring MCP (Model Context Protocol) connections during use. It enables discovering and calling tools via MCP protocol through HTTP with SSE transport or Streamable HTTP transport, with configuration done at runtime.

This project is based on arrenxxxxx/dify-plugin-tools-mcp_config_during_use with enhancements to support streamable_http transport.

English | 中文简体

Features

  • Configure MCP server connection information for each call separately
  • List available tools on MCP servers
  • Call specific tools on MCP servers
  • Support HTTP headers configuration for authorization and other features
  • Configure different timeout parameters
  • Support both SSE and Streamable HTTP transport methods

Tool List

The plugin provides two main tools:

  1. List MCP Tools (mcp_list_tools)

    • Used to list all available tools on an MCP server
  2. Call MCP Tool (mcp_call_tool)

    • Used to call a specific tool on an MCP server

Usage

List MCP Tools

Use the mcp_list_tools tool to list all available tools on a specified MCP server.

Parameters:

  • server_url (required): The endpoint URL of the MCP Server
  • transport (optional): Transport protocol to use, either “sse” (default) or “streamable_http”
  • headers (optional): HTTP headers in JSON format
  • timeout (optional): HTTP request timeout in seconds
  • sse_read_timeout (optional): SSE read timeout in seconds (only used with “sse” transport)

Example with SSE transport:

{
  "server_url": "http://127.0.0.1:8000/sse",
  "transport": "sse",
  "headers": "{\"Authorization\":\"Bearer your_token\"}",
  "timeout": 60,
  "sse_read_timeout": 300
}

Example with Streamable HTTP transport:

{
  "server_url": "http://127.0.0.1:8000/mcp",
  "transport": "streamable_http",
  "headers": "{\"Authorization\":\"Bearer your_token\"}",
  "timeout": 60
}

Call MCP Tool

Use the mcp_call_tool tool to call a specific tool on an MCP server.

Parameters:

  • server_url (required): The endpoint URL of the MCP Server
  • transport (optional): Transport protocol to use, either “sse” (default) or “streamable_http”
  • headers (optional): HTTP headers in JSON format
  • timeout (optional): HTTP request timeout in seconds
  • sse_read_timeout (optional): SSE read timeout in seconds (only used with “sse” transport)
  • tool_name (required): Name of the tool to execute
  • arguments (required): Tool arguments in JSON format

Example with SSE transport:

{
  "server_url": "http://127.0.0.1:8000/sse",
  "transport": "sse",
  "headers": "{\"Authorization\":\"Bearer your_token\"}",
  "timeout": 60,
  "sse_read_timeout": 300,
  "tool_name": "example_tool",
  "arguments": "{\"param1\":\"value1\",\"param2\":123}"
}

Example with Streamable HTTP transport:

{
  "server_url": "http://127.0.0.1:8000/mcp",
  "transport": "streamable_http",
  "headers": "{\"Authorization\":\"Bearer your_token\"}",
  "timeout": 60,
  "tool_name": "example_tool",
  "arguments": "{\"param1\":\"value1\",\"param2\":123}"
}

Differences from Pre-authorized MCP Tools

Compared to pre-authorized MCP tools, the main differences of this plugin are:

  1. Configuration Method: This plugin allows configuring connection information at call time, while pre-authorized MCP tools require configuration at the provider level
  2. Flexibility: Different tool calls can connect to different MCP servers
  3. Isolation: Each application can use its own MCP server configuration without affecting others
  4. Permission Management: No need for global authorization at the provider level, providing more flexible permission control

Requirements

  • Python 3.12 or higher
  • Dependencies:
    • httpx >= 0.27.0
    • httpx-sse >= 0.4.0
    • dify_plugin = 0.0.1b76

Notes

  • Ensure the provided MCP server URL is valid and supports the selected transport protocol
  • For SSE transport, the URL typically ends with “/sse”
  • For Streamable HTTP transport, the URL typically ends with “/mcp”
  • In the headers and arguments parameters, JSON objects need to be converted to strings with properly escaped double quotes
  • Adjust timeout parameters as needed, especially for long-running tool calls

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers