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 exposed by the MCP server. It supports two connection types: Command Line (STDIO) and Server-Sent Events (SSE), providing flexibility in how it communicates with the MCP server.
Common scenarios where this node is beneficial include:
- Automating execution of specific tools available on the MCP server.
- Retrieving and listing available prompts, tools, or resources for dynamic workflows.
- Reading detailed information about a particular resource by its URI.
- Integrating MCP server capabilities into broader automation pipelines within n8n.
Practical examples:
- Executing a text generation tool with custom parameters to generate content dynamically.
- Listing all available prompt templates to select one for further processing.
- Reading metadata or content from a resource URI to enrich workflow data.
Properties
Name | Meaning |
---|---|
Connection Type | Choose the transport type to connect to MCP server. Options: "Command Line (STDIO)", "Server-Sent Events (SSE)" |
Note: Although the node supports multiple operations, only the "Connection Type" property is provided here as per user input.
Output
The output JSON structure depends on the selected operation but generally includes:
For listResources:
{ "resources": [ /* array of resource objects */ ] }
A list of available resources from the MCP server.
For readResource:
{ "resource": { /* resource object */ } }
Details of a specific resource identified by its URI.
For listTools:
{ "tools": [ { "name": "toolName", "description": "Tool description", "schema": [ "inputProperty1", "inputProperty2", ... ] }, ... ] }
A list of available tools with their names, descriptions, and input schema keys.
For executeTool:
{ "result": /* result returned by the executed tool */ }
The output or response from executing a specified tool with given parameters.
For listPrompts:
{ "prompts": [ /* array of prompt templates */ ] }
Available prompt templates from the MCP server.
For getPrompt:
{ "prompt": { /* prompt template object */ } }
Details of a specific prompt template by name.
The node does not output binary data; all outputs are JSON objects representing structured data from the MCP server.
Dependencies
Requires access to an MCP server endpoint, either via:
- Command Line interface using STDIO transport, configured with a command and arguments.
- Server-Sent Events (SSE) transport, configured with SSE URL and optional headers.
Requires appropriate credentials for the chosen connection type:
- An API key or authentication token for the MCP server when using SSE.
- Command and environment variables for the CLI connection.
Environment variables starting with
MCP_
can be used to pass additional environment settings to the CLI transport.Uses external libraries:
@modelcontextprotocol/sdk
for MCP client functionality.zod
for input schema validation.n8n-workflow
for error handling and node utilities.
Troubleshooting
Transport error:
If the node throws a "Transport error," verify that the connection details (command, SSE URL, headers) are correct and that the MCP server is reachable.Failed to connect to MCP server:
Check network connectivity and credentials. Ensure the MCP server is running and accessible.No tools found from MCP client:
Indicates the MCP server did not return any tools. Confirm the server has tools configured and the client has permission to list them.Tool does not exist:
When executing a tool, if the specified tool name is not found, verify the exact tool name and list available tools to confirm.Invalid tool parameters:
Tool parameters must be valid JSON objects. Errors parsing parameters usually mean malformed JSON or incorrect parameter types.Operation not supported:
Using an unsupported operation value will cause an error. Use only the documented operations.
Links and References
MCP SDK repository and documentation (for MCP client usage):
https://github.com/modelcontextprotocol/sdkZod schema validation library:
https://github.com/colinhacks/zodn8n Node Development Documentation:
https://docs.n8n.io/integrations/creating-nodes/