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 retrieving prompt templates, listing available prompts, tools, resources, and executing specific tools on the MCP server. The "Get Prompt" operation specifically fetches a named prompt template from the MCP server.

Common scenarios for this node include:

  • Integrating with an MCP server to dynamically retrieve prompt templates for use in AI or automation workflows.
  • Fetching prompt templates by name to customize or reuse them in subsequent processing steps.
  • Accessing MCP server capabilities without manual API calls, simplifying workflow design.

Practical example:

  • A user wants to retrieve a prompt template called "customerSupportResponse" to feed it into a language model node for generating customer support replies. This node fetches that prompt template by name, making it available downstream.

Properties

Name Meaning
Connection Type Choose the transport type to connect to the MCP server. Options: "Command Line (STDIO)", "Server-Sent Events (SSE)"
Prompt Name Name of the prompt template to get. This is required when using the "Get Prompt" operation

Output

The output JSON contains a single field:

  • prompt: An object representing the retrieved prompt template fetched from the MCP server by its name.

Example output structure:

{
  "prompt": {
    /* prompt template details */
  }
}

No binary data output is produced by this operation.

Dependencies

  • Requires connection to an MCP server via either:

    • Command Line interface using STDIO transport, configured with a command and optional arguments.
    • Server-Sent Events (SSE) transport, configured with a URL and optional headers.
  • Requires appropriate credentials for the chosen connection type, including:

    • For STDIO: command line executable and environment variables.
    • For SSE: SSE URL and optional HTTP headers.
  • Uses the MCP SDK client libraries internally to communicate with the MCP server.

  • Environment variables starting with MCP_ can be used to pass additional environment settings to the STDIO transport.

Troubleshooting

  • Connection errors: If the node fails to connect to the MCP server, verify that the credentials are correctly configured and that the MCP server is reachable via the selected transport.

  • Prompt not found: If the specified prompt name does not exist on the MCP server, the node may return an error or empty result. Double-check the prompt name spelling and availability.

  • Invalid parameters: Ensure that the "Prompt Name" property is provided and non-empty when using the "Get Prompt" operation.

  • Transport errors: Errors related to the underlying transport (e.g., command execution failure or SSE connection issues) will be surfaced as node operation errors. Check logs for detailed messages.

  • Unsupported operation: Using an operation other than those supported by the node will cause an error.

Links and References

  • MCP Protocol and SDK documentation (refer to your MCP server provider's official docs)
  • n8n documentation on creating custom nodes and using credentials
  • General info on Server-Sent Events (SSE): https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events
  • Node.js child process and environment variable management (for STDIO transport)

Discussion