Actions7
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 two connection types: Command Line (STDIO) and Server-Sent Events (SSE), enabling flexible communication methods depending on the environment.
Common scenarios where this node is beneficial include:
- Listing available AI tools or resources from an MCP server.
- Executing specific AI tools with custom parameters.
- Retrieving prompt templates for use in workflows.
- Reading detailed information about specific resources by URI.
Practical examples:
- Automating the execution of an AI tool that processes text or data within an n8n workflow.
- Fetching and using prompt templates dynamically to generate content.
- Monitoring available resources and tools on an MCP server to adapt workflow logic accordingly.
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 Resource Templates, List Resources, List Tools, Read Resource |
Resource URI | URI of the resource to read (required only when Operation is "Read Resource") |
Tool Name | Name of the tool to execute (required only when Operation is "Execute Tool") |
Tool Parameters | JSON object containing parameters to pass to the tool (required only when Operation is "Execute Tool") |
Prompt Name | Name of the prompt template to get (required only when Operation is "Get Prompt") |
Output
The output structure varies depending on the selected operation:
- List Resources: Outputs a JSON object with a
resources
array listing available resources. - List Resource Templates: Outputs a JSON object with a
resourceTemplates
array. - Read Resource: Outputs a JSON object with a
resource
field containing the resource details. - List Tools: Outputs a JSON object with a
tools
array, each including name, description, and input schema. - Execute Tool: Outputs a JSON object with a
result
field containing the execution result of the specified tool. - List Prompts: Outputs a JSON object with a
prompts
array listing available prompt templates. - Get Prompt: Outputs a JSON object with a
prompt
field containing the requested prompt template.
The node does not output binary data; all outputs are JSON structured.
Dependencies
- Requires access to an MCP server endpoint.
- Supports two connection methods:
- Command Line (STDIO): Requires a command-line executable and optional arguments configured via credentials.
- Server-Sent Events (SSE): Requires SSE URL and optionally a POST endpoint and headers configured via credentials.
- Requires appropriate API authentication tokens or credentials depending on the chosen connection type.
- Environment variables prefixed with
MCP_
can be used to set additional environment variables for the command line transport.
Troubleshooting
- Connection errors: If the node fails to connect to the MCP server, verify that the correct connection type is selected and that credentials (API keys, URLs, commands) are properly configured.
- Invalid tool parameters: When executing a tool, ensure that the
Tool Parameters
property contains valid JSON representing an object. Errors parsing JSON will cause failures. - Tool not found: If the specified tool name does not exist on the MCP server, the node will throw an error listing available tools.
- Unsupported operation: Selecting an operation not supported by the node will result in an error.
- Transport errors: Errors during communication with the MCP server (e.g., network issues, invalid headers) will cause the node to fail with descriptive messages.
- Environment variable issues: For command line transport, ensure that environment variables required by the MCP client command are correctly set, especially those starting with
MCP_
.
Links and References
- Model Context Protocol (MCP) SDK (for more details on MCP client and transports)
- n8n Documentation (for general guidance on creating and using custom nodes)