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 various resources, tools, and prompts managed by the MCP server. Specifically, for the Get Prompt operation, it retrieves a named prompt template from the MCP server.

Common scenarios where this node is beneficial include:

  • Fetching predefined prompt templates to use in AI or language model workflows.
  • Dynamically loading prompt configurations stored on an MCP server to customize downstream processing.
  • Integrating prompt management into automated pipelines without manual intervention.

Practical example:

  • A user wants to retrieve a specific prompt template called "welcomeMessage" from the MCP server to feed it into a language model node for generating personalized greetings.

Properties

Name Meaning
Connection Type Choose the transport type to connect to MCP server. Options:
- Command Line (STDIO)
- Server-Sent Events (SSE)
Prompt Name Name of the prompt template to get. This is a required string input specifying which prompt to retrieve from the MCP server.

Output

The output JSON contains a single field:

  • prompt: The retrieved prompt template object corresponding to the specified prompt name. This typically includes the prompt's content and metadata as defined on the MCP server.

No binary data output is produced by this operation.

Example output structure:

{
  "prompt": {
    "name": "welcomeMessage",
    "content": "...",
    "description": "A welcome message prompt template"
    // other prompt-specific fields
  }
}

Dependencies

  • Requires connection to an MCP server via either:
    • Command Line interface using STDIO transport, or
    • Server-Sent Events (SSE) transport over HTTP.
  • May require appropriate API credentials or authentication tokens configured in n8n for the chosen connection type.
  • Environment variables prefixed with MCP_ can be used to configure the command line environment when using the STDIO transport.

Troubleshooting

  • Failed to get prompt: [error message]
    Indicates that the prompt with the specified name could not be retrieved. Possible causes:

    • The prompt name does not exist on the MCP server.
    • Network or connection issues with the MCP server.
    • Authentication failure due to missing or invalid credentials.

    Resolution: Verify the prompt name is correct and exists on the MCP server. Check connectivity and ensure valid credentials are provided.

  • Failed to execute operation: [error message]
    General failure during operation execution. Could be caused by misconfiguration, network errors, or internal MCP server errors.

    Resolution: Review node configuration, connection settings, and logs for detailed error messages.

  • Connection errors
    If the node cannot establish a connection to the MCP server, verify:

    • Correct connection type selected.
    • Proper credentials are set up.
    • For command line transport, ensure the command and environment variables are correctly configured.
    • For SSE transport, confirm URLs and headers are accurate.

Links and References

  • MCP (Model Context Protocol) official documentation (if available)
  • n8n documentation on creating and configuring custom nodes
  • Relevant SDK or client libraries for MCP server interaction (e.g., @modelcontextprotocol/sdk)

Note: Specific external links were not found in the source code; please consult your MCP server provider or documentation for more details.

Discussion