MCP Client icon

MCP Client

Use MCP client

Overview

This node acts as a client for the MCP (Model Context Protocol) server, enabling interaction with various MCP resources and tools. Specifically, the "Execute Tool" operation allows users to run a named tool on the MCP server by passing JSON-formatted parameters. This is useful in scenarios where you want to leverage external AI or processing tools exposed via MCP, such as running language models, data processors, or custom utilities remotely.

Practical examples include:

  • Executing an AI model inference tool by specifying its name and input parameters.
  • Running a data transformation tool that requires structured JSON input.
  • Integrating real-time or batch processing tools into an n8n workflow without managing the tool's internal logic.

Properties

Name Meaning
Connection Type Choose the transport type to connect to the MCP server. Options: Command Line (STDIO), Server-Sent Events (SSE - deprecated), HTTP Streamable (recommended for real-time communication).
Tool Name The exact name of the tool to execute on the MCP server.
Tool Parameters JSON object containing parameters to pass to the tool. Must be valid JSON representing the tool's expected input schema.

Output

The output JSON contains a single field:

  • result: The result returned by the executed tool. This can be any JSON-serializable value depending on the tool's response. It typically represents the output or outcome of the tool execution.

The node does not output binary data.

Example output JSON structure:

{
  "result": {
    // tool-specific output here
  }
}

Dependencies

  • Requires connection credentials to the MCP server, which vary based on the selected connection type:
    • For Command Line (STDIO): A command line executable and environment variables configured.
    • For HTTP Streamable: An HTTP endpoint URL with optional headers and timeout settings.
    • For Server-Sent Events (SSE): An SSE endpoint URL with optional headers (deprecated).
  • The node dynamically imports MCP SDK client libraries for communication.
  • Environment variables starting with MCP_ can be used to pass additional environment configuration when using the command line transport.

Troubleshooting

  • Invalid JSON in Tool Parameters: If the tool parameters are not valid JSON or not an object, the node will throw an error. Ensure the parameters are correctly formatted JSON objects.
  • Tool Not Found: If the specified tool name does not exist on the MCP server, the node will list available tools in the error message. Verify the tool name spelling and availability.
  • Connection Errors: Failure to connect to the MCP server due to incorrect credentials, URLs, or network issues will cause errors. Check your credential configuration and network access.
  • Transport Errors: Errors related to the chosen transport (e.g., command line failure, HTTP timeout) will be reported. Review logs and ensure the transport setup is correct.
  • Deprecated SSE Transport: SSE transport is deprecated; prefer using HTTP Streamable for better support and stability.

Links and References

Discussion