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 provided by the MCP ecosystem. It supports multiple operations such as listing available resources, reading specific resources, listing and executing tools, and managing prompt templates.
Common scenarios where this node is beneficial include:
- Automating retrieval of available resources or tools from an MCP server.
- Executing specific tools remotely with custom parameters.
- Fetching prompt templates for use in AI workflows.
- Integrating MCP server capabilities into broader n8n automation pipelines.
For example, a user might list all available tools on the MCP server, then execute a selected tool with JSON parameters, and process the results downstream in their workflow.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose the transport type to connect to MCP server. Options: - Command Line (STDIO) - Server-Sent Events (SSE) |
| Operation | The action to perform on the MCP server. Options include: - Execute Tool - Get Prompt - List Prompts - List Resources - List Tools - Read Resource |
| Resource URI | (Required only for "Read Resource" operation) The URI of the resource to read. |
| Tool Name | (Required only for "Execute Tool" operation) The name of the tool to execute. |
| Tool Parameters | (Required only for "Execute Tool" operation) JSON object specifying parameters for the tool. |
| Prompt Name | (Required only for "Get Prompt" operation) The name of the prompt template to retrieve. |
Output
The output structure varies depending on the selected operation:
List Resources: Outputs a JSON object with a
resourcesfield containing an array of available resources.{ "resources": [ /* array of resource objects */ ] }Read Resource: Outputs a JSON object with a
resourcefield containing the data of the specified resource.{ "resource": { /* resource data */ } }List Tools: Outputs a JSON object with a
toolsfield containing an array of tools. Each tool includes its name, description, and input schema in JSON Schema format.{ "tools": [ { "name": "toolName", "description": "Tool description", "schema": { /* JSON Schema of input parameters */ } }, ... ] }Execute Tool: Outputs a JSON object with a
resultfield containing the execution result of the tool. The result can be any JSON-serializable value returned by the tool.List Prompts: Outputs a JSON object with a
promptsfield containing an array of available prompt templates.Get Prompt: Outputs a JSON object with a
promptfield containing the requested prompt template.
The node does not output binary data.
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:
- An API key or authentication token for SSE connection.
- A command environment setup for the STDIO connection.
Uses environment variables prefixed with
MCP_to configure the command environment when using the STDIO transport.Depends on external libraries bundled with the node, including:
- MCP SDK client libraries for communication.
- Zod for JSON schema validation.
- n8n workflow utilities for error handling and logging.
Troubleshooting
Connection Errors:
- If the node fails to connect to the MCP server, verify that the correct connection type is selected and credentials are properly configured.
- For SSE connections, ensure the SSE URL and headers are valid and accessible.
- For STDIO connections, confirm the command and environment variables are correctly set and executable.
Invalid Tool Parameters:
- When executing a tool, parameters must be a valid JSON object. Invalid JSON or incorrect parameter types will cause errors.
- Error message example:
Failed to parse tool parameters: ... Make sure the parameters are valid JSON.
Tool Not Found:
- Attempting to execute a non-existent tool will throw an error listing available tools.
- Error message example:
Tool 'xyz' does not exist. Available tools: tool1, tool2, ...
Operation Not Supported:
- Selecting an unsupported operation will result in an error indicating the operation is not supported.
Transport Errors:
- Any transport-level errors during communication with the MCP server will be surfaced as node operation errors.
Links and References
- MCP SDK documentation (refer to your MCP server provider's official docs)
- n8n documentation on creating custom nodes and using credentials
- Zod library for JSON schema validation: https://github.com/colinhacks/zod