Overview
This node acts as a client interface to an MCP (Model Context Protocol) server, allowing users to interact with various resources, prompts, and tools exposed by the server. Specifically, the "Execute Tool" operation enables running a named tool on the MCP server with user-defined parameters in JSON format. This is useful for automating tasks that require invoking external tools or services managed by the MCP server.
Common scenarios include:
- Automating complex workflows by executing specialized tools remotely.
- Integrating AI or data processing tools available on the MCP server into n8n workflows.
- Dynamically passing parameters to tools for flexible execution.
Example: Executing a text summarization tool by specifying its name and providing the input text as parameters in JSON.
Properties
| Name | Meaning |
|---|---|
| Connection Type | Choose the transport type to connect to the MCP server. Options: Command Line (STDIO), Server-Sent Events (SSE) |
| 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 with a single field:
result: Contains the output returned by the executed tool. This can be any JSON-serializable value depending on the tool's response. If the tool returns an object, it is serialized as JSON; otherwise, it is converted to a string.
No binary data output is produced by this operation.
Example output JSON structure:
{
"result": { /* tool-specific output */ }
}
Dependencies
Requires connection to an MCP server via either:
- A command line interface using STDIO transport, configured with an API key credential that provides the command and arguments.
- A Server-Sent Events (SSE) transport, configured with an API key credential that provides SSE URL and optional headers.
Environment variables starting with
MCP_are injected into the command environment when using the command line transport.The node depends on the MCP SDK packages for client communication and tool invocation.
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 indicating parsing failure. 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 spelling and availability.
Connection Errors: Failure to connect to the MCP server (either via command line or SSE) will result in errors. Check credentials, server availability, and network connectivity.
Transport Errors: Errors emitted by the underlying transport layer will cause the node to fail. Review logs for detailed transport error messages.
Links and References
- MCP SDK GitHub Repository (for MCP client and transport details)
- n8n Documentation (for general node usage and credential setup)