Overview
The MCP Client node connects to an MCP (Model Context Protocol) server using either a command line interface (STDIO) or Server-Sent Events (SSE) transport. It allows users to interact with the MCP server by performing various operations such as listing available prompts, tools, and resources, reading specific resources, retrieving prompt templates, and executing tools with parameters.
This node is useful in scenarios where you want to integrate advanced model context capabilities into your n8n workflows, for example:
- Fetching and displaying available AI prompt templates.
- Executing AI tools dynamically with custom parameters.
- Accessing and managing resources hosted on the MCP server.
Practical examples:
- Automatically retrieve a list of prompts to present options to end-users.
- Execute a named tool with JSON parameters to process data or generate content.
- Read a resource by its URI to incorporate external data into a workflow.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose the transport type to connect to MCP server: - Command Line (STDIO) - Server-Sent Events (SSE) |
Output
The node outputs JSON data depending on the selected operation:
- List Prompts: Outputs an object with a
promptsfield containing an array of available prompt templates from the MCP server.
Example output structure:
{
"prompts": [
{
"name": "prompt1",
"description": "Description of prompt1",
...
},
...
]
}
If other operations were used, the output would contain fields like resources, resource, tools, result, or prompt accordingly.
The node does not output binary data.
Dependencies
- Requires connection to an MCP server via either:
- A command line interface transport, configured with a command and optional arguments and environment variables.
- An SSE transport, configured with a URL and optional headers.
- Requires appropriate credentials for the chosen connection type (an API key or authentication token).
- Environment variables prefixed with
MCP_can be passed to the command line transport environment. - The node depends on the MCP SDK client libraries bundled within the node.
Troubleshooting
- Connection errors: If the node fails to connect to the MCP server, verify that the correct connection type is selected and that credentials are properly configured.
- Transport errors: Errors related to the transport layer (STDIO or SSE) will throw descriptive messages; ensure the command or SSE endpoint is reachable and correctly set up.
- Invalid tool parameters: When executing a tool, parameters must be valid JSON objects. Parsing errors will indicate malformed input.
- Tool not found: Attempting to execute a non-existent tool will result in an error listing available tools.
- No tools found: If no tools are returned from the MCP server, check the server configuration and permissions.
- Operation not supported: Selecting an unsupported operation will throw an error.
Links and References
- MCP Protocol and SDK documentation (refer to your MCP server provider's official docs)
- n8n documentation on creating and configuring custom nodes
- JSON schema validation library used internally: Zod