Smart MCP Client icon

Smart MCP Client

Connects to and interacts with an MCP server, discovering capabilities for AI Agents.

Overview

The Smart MCP Client node connects to an MCP (Model Context Protocol) server using either a command line (STDIO) or Server-Sent Events (SSE) transport. It enables interaction with the MCP server to discover AI agent capabilities, list available prompts, tools, resources, and resource templates, execute tools, retrieve prompt templates, and read resources by URI. This node is useful for integrating AI agent capabilities and resources managed by an MCP server into n8n workflows, such as dynamically discovering tools or fetching prompt templates for AI-driven automation.

Properties

Name Meaning
Connection Type Selects the transport method to connect to the MCP server. Options are 'Command Line (STDIO)' for local command execution or 'Server-Sent Events (SSE)' for HTTP-based streaming connection.

Output

JSON

  • tools - When discovering capabilities, outputs an array of available tools with their names, descriptions, JSON schemas, and metadata.
  • resources - When listing resources, outputs the list of available resources from the MCP server.
  • prompts - When listing prompts, outputs the list of available prompt templates.
  • resourceTemplates - When listing resource templates, outputs the list of resource URI templates.
  • rawResult - When executing a tool or reading a resource, if the result is not a standard object, the raw response is returned here.
    - For executed tools, resources, or prompts, the output JSON contains the respective data or parsed JSON content returned from the MCP server.

Dependencies

  • Requires credentials for MCP server connection, either an API key credential for command line transport or SSE API credential for SSE transport.
  • Depends on '@modelcontextprotocol/sdk' packages for client and transport implementations.
  • Environment variables prefixed with 'MCP_' can be used to pass environment settings to the command line transport.

Troubleshooting

  • Connection errors may occur if the MCP server is unreachable or credentials are invalid. Verify credentials and server availability.
  • Parsing errors can happen if the MCP server returns unexpected or malformed JSON. Check server responses and tool parameters.
  • When using resource template tools, ensure the 'uri' parameter matches the expected URI template format to avoid warnings or errors.
  • If the node throws 'Failed to execute tool' or 'Failed reading resource' errors, inspect the detailed error description for underlying issues such as missing parameters or server errors.
  • Custom 'messagesPostEndpoint' in SSE transport may not be supported and could cause unexpected behavior.
  • Ensure that the 'toolParameters' input is a valid JSON object string or object; otherwise, execution may fail.

Discussion