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 MCP resources, tools, and prompts. It supports multiple operations such as listing available prompts, tools, resources, reading specific resources, executing tools, and retrieving prompt templates.

The "List Prompts" operation specifically fetches and returns the list of available prompt templates from the MCP server. This is useful in scenarios where you want to dynamically discover which prompt templates are available for use or further processing within your workflow.

Practical examples:

  • Automatically retrieve all prompt templates to display them in a UI or select one for subsequent operations.
  • Use the list of prompts to validate user input or to programmatically choose a prompt template for generating text or other AI-driven tasks.

Properties

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

Output

The output JSON contains a single field:

  • prompts: An array of prompt templates available on the MCP server. Each element represents a prompt template object as returned by the MCP client SDK.

Example output structure:

{
  "prompts": [
    {
      "name": "examplePrompt",
      "description": "Description of the prompt",
      "parameters": { /* prompt parameters schema or details */ }
    },
    ...
  ]
}

No binary data output is produced by this operation.

Dependencies

  • Requires connection to an MCP server via either:

    • A 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:

    • For STDIO: credentials providing the command and environment variables.
    • For SSE: credentials providing the SSE URL and optional headers.
  • The node depends on the MCP client SDK packages and n8n's credential management system.

  • 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 at the specified endpoint or command.

  • No prompts returned: If the prompts array is empty, ensure that the MCP server actually has prompt templates available and that the user account or API key has permission to access them.

  • Transport errors: Errors related to the transport layer (e.g., SSE or STDIO) will be surfaced as node operation errors. Check network connectivity, command availability, and environment variable correctness.

  • Invalid credentials: Make sure the credentials provided match the selected connection type and contain all required fields.

Links and References

Discussion