Actions7
Overview
This node acts as an enhanced client for interacting with the MCP (Model Context Protocol) server, supporting multiple connection types and operations. It is designed to facilitate communication with MCP servers in various environments, including multi-tenant setups, by executing tools, retrieving prompts, listing resources, and more.
The "Execute Tool" operation allows users to run a specific tool on the MCP server by providing the tool's name and parameters. This is useful when you want to leverage specialized processing or functionality exposed by MCP tools, such as data transformation, AI model execution, or custom workflows.
Practical examples:
- Executing a text summarization tool by passing the input text as parameters.
- Running a data enrichment tool with specific configuration options.
- Triggering a machine learning inference tool with JSON-formatted input data.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose the transport type to connect to the MCP server. Options: Command Line (STDIO), Server-Sent Events (SSE - deprecated), HTTP Streamable (recommended for real-time). |
| Tool Name | The exact name of the tool to execute on the MCP server. |
| Tool Parameters | JSON object containing parameters to pass to the tool during execution. |
Output
The node outputs a JSON object under the json field with the following structure for the "Execute Tool" operation:
{
"result": <tool execution result>
}
- The
resultfield contains the output returned by the executed tool. This can be any JSON-serializable data depending on the tool's implementation. - The node does not explicitly output binary data for this operation.
Dependencies
- Requires connectivity to an MCP server via one of the supported transports:
- Command Line interface (STDIO)
- HTTP Streamable protocol (recommended)
- Server-Sent Events (SSE) protocol (deprecated)
- Requires appropriate credentials configured in n8n for the chosen connection type, including API URLs, commands, environment variables, or authentication headers.
- Uses the MCP SDK client libraries internally to manage connections and tool executions.
Troubleshooting
- Invalid JSON in Tool Parameters: If the provided tool parameters are not valid JSON or not a JSON object, the node will throw an error. Ensure parameters are correctly formatted JSON objects.
- Tool Not Found: If the specified tool name does not exist on the MCP server, the node will list available tools in the error message. Verify the tool name matches exactly.
- Connection Errors: Failure to connect to the MCP server due to misconfigured credentials, network issues, or invalid endpoints will cause errors. Check credentials and network accessibility.
- Transport Errors: Errors related to the chosen transport (e.g., command line command failure, HTTP timeout) will be reported. Review transport configuration and logs.
- Timeouts: The node uses configurable timeouts for HTTP and SSE transports; long-running tool executions may require adjusting these settings.
Links and References
- MCP Protocol Documentation (hypothetical link for reference)
- n8n Documentation on Custom Nodes
- JSON Schema Validation - relevant for understanding parameter validation and schemas