Actions7
Overview
This node acts as a client for the MCP (Model Context Protocol) server, enabling interaction with various MCP resources and tools. Specifically, the Execute Tool operation allows users to run a named tool on the MCP server by passing JSON-formatted parameters. This is useful in scenarios where you want to integrate external AI or automation tools exposed via MCP into your n8n workflows.
Practical examples include:
- Executing an AI model inference tool by providing input parameters.
- Running data transformation or enrichment tools hosted on the MCP server.
- Automating calls to custom tools registered in MCP without manual intervention.
The node supports multiple connection types to communicate with the MCP server: command line (STDIO), HTTP streaming, and deprecated SSE.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose the transport type to connect to MCP server. Options: - Command Line (STDIO) - Server-Sent Events (SSE) (deprecated) - HTTP Streamable (recommended for real-time communication) |
| 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 output JSON structure contains a single field:
result: The result returned by the executed tool. It can be any JSON-serializable value depending on the tool's response.
No binary data output is produced by this operation.
Example output JSON:
{
"result": {
"someKey": "someValue",
"anotherKey": 123
}
}
Dependencies
- Requires access to an MCP server endpoint.
- Depending on the selected connection type, appropriate credentials must be configured in n8n:
- For Command Line (STDIO): Credentials must provide the command and arguments to launch the MCP client CLI.
- For HTTP Streamable: Credentials must include the HTTP stream URL and optionally message POST endpoint and headers.
- For Server-Sent Events (SSE): Credentials must include SSE URL and optional POST endpoint and headers (deprecated).
- Environment variables starting with
MCP_are merged into the environment for the command line transport. - The node uses internal MCP SDK clients and transports but requires no additional user setup beyond credentials.
Troubleshooting
Failed to parse tool parameters:
Occurs if theTool Parametersinput is not valid JSON or not an object. Ensure the parameters are a valid JSON object string or JSON input.Tool does not exist:
If the specified tool name is not found among available tools, the node throws an error listing all available tool names. Verify the tool name spelling and availability on the MCP server.Transport error:
Indicates issues connecting to the MCP server via the chosen transport. Check credentials, URLs, commands, and network connectivity.Failed to connect to MCP server:
Could be caused by invalid credentials, unreachable endpoints, or misconfigured environment variables.Operation not supported:
Happens if an unsupported operation is requested. Confirm that the operation is set to "Execute Tool" for this use case.
Links and References
- Model Context Protocol (MCP) Documentation (hypothetical link, replace with actual if available)
- n8n Documentation on Creating Custom Nodes
- JSON Schema Validation with Zod
If you need details on other operations or resources, feel free to ask!