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 perform various operations such as reading resources, listing available resources, tools, prompts, and executing specific tools on the MCP server. It supports two connection types: Command Line (STDIO) and Server-Sent Events (SSE), providing flexibility depending on the environment or preference.

A common use case is integrating with an MCP server to dynamically fetch or manipulate AI model-related resources or tools within an n8n workflow. For example, you might read a resource by its URI to retrieve data or execute a tool with specific parameters to perform a task programmatically.

Specifically for the Read Resource operation, this node reads a resource from the MCP server identified by a given URI and outputs the resource data.

Properties

Name Meaning
Connection Type Choose the transport type to connect to the MCP server. Options: "Command Line (STDIO)", "Server-Sent Events (SSE)"
Resource URI The URI of the resource to read from the MCP server. This is required for the Read Resource operation.

Output

The output JSON contains a single field:

  • resource: An object representing the resource data retrieved from the MCP server corresponding to the specified URI.

No binary data output is produced by this operation.

Example output structure:

{
  "resource": {
    /* resource data fields as returned by MCP server */
  }
}

Dependencies

  • Requires access to an MCP server.
  • Depending on the selected connection type:
    • For Command Line (STDIO): Requires configuration of a command line client executable with optional arguments and environment variables.
    • For Server-Sent Events (SSE): Requires SSE endpoint URL and optionally custom headers and POST endpoint configuration.
  • Requires appropriate API credentials or authentication tokens configured in n8n for the chosen connection type.
  • Uses external libraries bundled with the node for communication and schema validation.

Troubleshooting

  • Connection errors: If the node fails to connect to the MCP server, verify that the connection type is correctly set and that the credentials (command, URLs, headers) are properly configured.
  • Invalid Resource URI: Ensure the Resource URI is correct and accessible on the MCP server; otherwise, the node will throw an error indicating failure to read the resource.
  • Transport errors: Errors related to the underlying transport (STDIO or SSE) will be surfaced as node operation errors. Check logs for detailed messages.
  • Missing or invalid credentials: The node requires valid credentials for the selected connection type. Missing or incorrect credentials will cause connection failures.
  • Unsupported operation: If the operation parameter is changed incorrectly, the node will throw an error stating the operation is not supported.

Links and References

Discussion