MCP Client icon

MCP Client

Use MCP client

Overview

This node acts as a client interface to an MCP (Model Context Protocol) server, allowing users to interact with various resources, prompts, and tools exposed by the MCP server. It supports multiple operations such as listing available tools, executing a specific tool with parameters, retrieving prompt templates, and reading resources by URI.

A common use case is automating workflows that require invoking external AI or model-related tools dynamically, fetching prompt templates for language models, or managing resources hosted on an MCP server. For example, you could list all available AI tools on the server and execute one with custom parameters to generate content or analyze data within an n8n workflow.

The node supports two connection types to communicate with the MCP server:

  • Command Line (STDIO): Uses a local command-line process.
  • Server-Sent Events (SSE): Uses SSE over HTTP for event-driven communication.

Properties

Name Meaning
Connection Type Choose the transport type to connect to MCP server. Options: "Command Line (STDIO)", "Server-Sent Events (SSE)"

Note: The operation property is fixed to "List Tools" for this summary, so only the "Connection Type" input property is relevant here.

Output

The output JSON structure for the List Tools operation contains a tools array. Each element in this array represents a tool available on the MCP server and includes:

  • name: The name of the tool.
  • description: A short description of what the tool does.
  • schema: An array of strings representing the names of input parameters the tool accepts.

Example output JSON snippet:

{
  "tools": [
    {
      "name": "exampleTool",
      "description": "Execute the exampleTool tool",
      "schema": ["param1", "param2"]
    },
    {
      "name": "anotherTool",
      "description": "Execute the anotherTool tool",
      "schema": ["inputText", "flag"]
    }
  ]
}

The node does not output binary data.

Dependencies

  • Requires access to an MCP server endpoint, either via a command line executable or SSE URL.
  • If using the command line connection, the specified command and environment variables must be correctly configured.
  • If using SSE, the SSE URL and optional POST endpoint and headers must be provided.
  • Requires appropriate API credentials or authentication tokens depending on the connection type.
  • Relies on the MCP SDK client libraries bundled with the node for communication.

Troubleshooting

  • No tools found from MCP client: This error occurs if the MCP server returns no tools. Verify the server is running and has tools registered.
  • Failed to connect to MCP server: Indicates connection issues. Check command line availability or SSE URL correctness and network connectivity.
  • Failed to execute tool: Usually caused by invalid tool name or malformed parameters. Ensure the tool exists and parameters are valid JSON objects.
  • Invalid parameter type: Tool parameters must be a JSON object; passing other types will cause errors.
  • Missing or incorrect credentials: Ensure the required API keys or tokens are set up properly in n8n credentials.

Links and References

Discussion