Overview
This node acts as a client for the MCP (Model Context Protocol) server, enabling interaction with various MCP resources such as prompts, tools, and other resources. It supports two connection types: Command Line (STDIO) and Server-Sent Events (SSE). The node is useful in scenarios where you want to programmatically retrieve prompt templates, list available prompts, execute specific tools, or read resources from an MCP server within an n8n workflow.
For example, you can use this node to:
- Fetch a specific prompt template by name to dynamically generate content.
- List all available prompts or tools on the MCP server.
- Execute a tool with given parameters and use its output downstream.
- Read detailed information about a resource identified by a URI.
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 (required when operation is "Get Prompt") |
Output
The node outputs JSON data depending on the selected operation:
- For Get Prompt operation, the output JSON contains a
promptfield holding the retrieved prompt template object.
Example output structure:
{
"prompt": {
/* prompt template details */
}
}
- Other operations (not requested here) output fields like
resources,tools,result, orpromptsaccordingly.
The node does not output binary data.
Dependencies
- Requires access to an MCP server via either:
- A command line interface (STDIO) transport using a configured command and arguments.
- A Server-Sent Events (SSE) transport with URL and optional headers.
- Requires appropriate API credentials for the chosen connection type.
- Environment variables starting with
MCP_are injected into the command line environment if using STDIO transport. - Uses external libraries including the MCP SDK client and transport implementations.
Troubleshooting
- Connection errors: If the node fails to connect to the MCP server, verify that the correct connection type is selected and that the corresponding credentials (API key or command) are properly configured.
- Transport errors: Errors during communication with the MCP server will be reported as transport errors. Check network connectivity and server availability.
- Invalid prompt name: If the specified prompt name does not exist, the node may throw an error indicating failure to retrieve the prompt. Verify the prompt name spelling and existence on the MCP server.
- JSON parsing errors: When providing parameters (for other operations), ensure JSON strings are valid and well-formed.
- Missing parameters: Required properties like "Prompt Name" must be provided when performing the "Get Prompt" operation.
Links and References
- MCP SDK documentation (refer to MCP server and client usage guides)
- n8n documentation on creating and configuring custom nodes
- Relevant MCP server API references for prompts and tools