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 provided by the MCP ecosystem. It supports multiple connection types for communication, including command line (STDIO), HTTP streamable protocol, and a deprecated Server-Sent Events (SSE) method.

The "List Tools" operation specifically retrieves the list of available tools from the MCP server. This is useful when you want to discover what automated tools or capabilities are accessible for execution within your workflow. For example, you might use this node to dynamically fetch tool options before executing one, or to audit available tools in your environment.

Practical scenarios include:

  • Integrating AI-powered tools into automation workflows.
  • Dynamically adapting workflow behavior based on available MCP tools.
  • Auditing or monitoring the set of tools exposed by the MCP server.

Properties

Name Meaning
Connection Type Choose the transport type to connect to the MCP server. Options:
- Command Line (STDIO): Use standard input/output command line communication.
- Server-Sent Events (SSE): Deprecated; previously used SSE protocol for streaming.
- HTTP Streamable: Use HTTP streamable protocol for real-time communication (recommended).

Output

The output JSON contains a field named tools which is an array of objects. Each object represents a tool available on the MCP server and includes:

  • name: The name of the tool.
  • description: A textual description of what the tool does.
  • schema: A structured schema describing the expected input parameters for the tool, represented as a validation object.

Example output structure:

{
  "tools": [
    {
      "name": "exampleTool",
      "description": "Executes example functionality",
      "schema": { /* JSON schema describing input parameters */ }
    },
    ...
  ]
}

No binary data output is produced by this operation.

Dependencies

  • Requires access to an MCP server endpoint.
  • Depending on the selected connection type, requires appropriate credentials configured in n8n:
    • For Command Line (STDIO): An API key credential that provides command and arguments to run the MCP client CLI.
    • For HTTP Streamable: Credentials containing HTTP URLs and optional headers for streaming.
    • For SSE (deprecated): Credentials with SSE URL and headers.
  • Environment variables starting with MCP_ can be passed as environment variables to the command line transport.
  • Uses external libraries such as @modelcontextprotocol/sdk for client communication and zod for schema validation.

Troubleshooting

  • Connection errors: If the node fails to connect to the MCP server, verify that the correct connection type is selected and that the corresponding credentials are properly configured.
  • No tools found: If the output shows no tools, ensure the MCP server actually exposes tools and that the user has permission to list them.
  • Transport error: Errors related to the transport layer (e.g., command not found, network issues) will throw descriptive errors. Check logs for details.
  • Timeouts: The node uses configurable timeouts depending on the connection type; if operations time out, consider increasing the timeout values in credentials.
  • Deprecated SSE usage: Avoid using the SSE connection type as it is deprecated; switch to HTTP Streamable for better support.

Links and References

Discussion