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

Common scenarios where this node is beneficial include:

  • Automating interactions with an MCP server to retrieve or manipulate AI model resources.
  • Executing specialized tools hosted on the MCP server as part of a workflow.
  • Fetching and using prompt templates dynamically within automation pipelines.
  • Integrating MCP server capabilities into broader n8n workflows for enhanced AI-driven processing.

Practical examples:

  • Listing all available AI tools on the MCP server to decide which to invoke next.
  • Reading a resource by its URI to fetch configuration or data needed downstream.
  • Executing a tool with specific parameters to perform a task like text generation or data transformation.
  • Retrieving a prompt template to customize AI model input dynamically.

Properties

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

Output

The node outputs JSON objects whose structure depends on the selected operation:

  • listResources: Outputs { "resources": [...] } — an array of available resource identifiers or metadata.
  • readResource: Outputs { "resource": {...} } — the content or details of the specified resource.
  • listTools: Outputs { "tools": [...] } — an array of tool descriptors, each including name, description, and a list of input parameter keys (schema).
  • executeTool: Outputs { "result": ... } — the result returned by executing the specified tool; can be any JSON-serializable value.
  • listPrompts: Outputs { "prompts": [...] } — an array of available prompt templates.
  • getPrompt: Outputs { "prompt": {...} } — the details of a specific prompt template.

The node does not output binary data.

Dependencies

  • Requires access to an MCP server endpoint, either via command line invocation or SSE transport.
  • Needs appropriate credentials configured in n8n for authentication with the MCP server, depending on the chosen connection type.
  • Environment variables prefixed with MCP_ can be used to pass additional environment settings when using the command line connection.
  • The node internally uses several external libraries for schema validation and MCP client communication but these are bundled and managed by the node itself.

Troubleshooting

  • Connection errors: If the node fails to connect to the MCP server, verify that the server is reachable and that credentials are correctly configured.
  • Invalid tool parameters: When executing a tool, ensure the parameters are valid JSON objects. Errors parsing parameters will cause execution failure.
  • Tool not found: Attempting to execute a non-existent tool will throw an error listing available tools. Double-check the tool name spelling.
  • Empty tool list: If no tools are returned from the MCP server, confirm the server has tools registered and accessible.
  • Operation not supported: Selecting an unsupported operation will cause an error. Use only the documented operations.
  • Environment variable issues: For command line connections, ensure environment variables are properly formatted and do not conflict with system settings.

Links and References

Discussion