MCP Client icon

MCP Client

Use MCP client

Overview

This node acts as a client interface to an MCP (Model Context Protocol) server, enabling interaction with various MCP resources, tools, and prompts. It supports multiple connection types for communication, including command line (STDIO), HTTP streamable protocol, and deprecated Server-Sent Events (SSE).

Common scenarios where this node is beneficial include:

  • Listing available resources or resource templates from the MCP server.
  • Retrieving and reading specific resources by their URI.
  • Listing and executing tools provided by the MCP server with custom parameters.
  • Accessing prompt templates and retrieving specific prompts.

Practical examples:

  • Automating retrieval of AI model context resources for downstream processing.
  • Executing specialized tools on the MCP server to perform tasks like data transformation or analysis.
  • Fetching prompt templates dynamically to feed into language models or other AI components.

Properties

Name Meaning
Connection Type Choose the transport type to connect to MCP server. Options:
- Command Line (STDIO)
- Server-Sent Events (SSE) (Deprecated)
- HTTP Streamable (recommended for real-time communication)

Output

The output JSON structure depends on the selected operation:

  • listResources: Outputs { "resources": [...] } — an array of available resources from the MCP server.
  • listResourceTemplates: Outputs { "resourceTemplates": [...] } — an array of resource templates.
  • readResource: Outputs { "resource": {...} } — the content of a specific resource identified by its URI.
  • listTools: Outputs { "tools": [...] } — an array of tool descriptions, each containing name, description, and input schema in JSON Schema format.
  • executeTool: Outputs { "result": ... } — the result returned by executing a specified tool with given parameters.
  • listPrompts: Outputs { "prompts": [...] } — an array of available prompt templates.
  • getPrompt: Outputs { "prompt": {...} } — details of a specific prompt template by name.

The node does not output binary data; all outputs are JSON objects representing structured data from the MCP server.

Dependencies

  • Requires connectivity to an MCP server supporting one of the following transports:
    • Command Line interface via STDIO (requires a configured command and arguments).
    • HTTP Streamable protocol (recommended for real-time streaming).
    • Server-Sent Events (SSE) protocol (deprecated).
  • Requires appropriate credentials configured in n8n for the chosen connection type, including URLs, commands, environment variables, headers, and timeouts.
  • Uses the MCP SDK client libraries internally to communicate with the MCP server.

Troubleshooting

  • Connection errors: If the node fails to connect, verify that the correct connection type is selected and that credentials (command, URLs, headers, environment variables) are properly configured.
  • No tools found: When listing tools, if no tools are returned, ensure the MCP server has tools available and the user has permission to access them.
  • Invalid tool parameters: Tool parameters must be valid JSON objects. Errors parsing parameters will cause execution failure. Validate JSON syntax before running.
  • Tool not found: Executing a tool that does not exist on the MCP server will throw an error listing available tools.
  • Transport errors: Any transport-level errors (e.g., network issues, command failures) will be surfaced as node operation errors with descriptive messages.
  • Timeouts: The node uses configurable timeouts for HTTP and SSE connections; adjust these if operations take longer than expected.

Links and References

Discussion