Overview
This node acts as a client interface to an MCP (Model Context Protocol) server, allowing users to perform various operations such as executing tools, listing available resources, prompts, and tools, or reading specific resources. The "Execute Tool" operation enables running a named tool on the MCP server with user-defined parameters.
Common scenarios include:
- Automating execution of specialized tools hosted on an MCP server.
- Integrating external model-based tools into n8n workflows.
- Dynamically invoking tools with JSON-configured parameters for flexible automation.
For example, you might use this node to run a text summarization tool by specifying its name and passing the text to summarize as parameters in JSON format.
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 | Name of the tool to execute on the MCP server. |
| Tool Parameters | Parameters to pass to the tool in JSON format. Must be a valid JSON object. |
Output
The output JSON structure for the "Execute Tool" operation contains:
result: The result returned by the executed tool. This can be any JSON-serializable data depending on the tool's response.
Other operations produce outputs like:
resources: List of available resources.resource: Details of a specific resource.tools: List of available tools with their names, descriptions, and input schemas.prompts: List of available prompt templates.prompt: Details of a specific prompt template.
The node does not output binary data.
Dependencies
Requires connection to an MCP server via either:
- A command line interface using STDIO transport, configured with a command and optional arguments.
- Server-Sent Events (SSE) transport, configured with a URL and optional headers.
Requires appropriate credentials for the chosen connection type, including API URLs or commands and environment variables.
Uses environment variables prefixed with
MCP_to configure the command line environment if applicable.Depends on external libraries bundled within the node for communication and schema validation.
Troubleshooting
Invalid JSON in Tool Parameters: If the 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, an error lists available tools. Verify the tool name is correct.
Connection Errors: Failure to connect to the MCP server may occur due to incorrect credentials, network issues, or misconfiguration of the transport method. Check credentials and server availability.
Transport Errors: Errors during communication with the MCP server (e.g., SSE connection errors or command execution failures) will cause the node to fail. Review logs for detailed error messages.
Unsupported Operation: Using an unsupported operation value will result in an error indicating the operation is not supported.
Links and References
- MCP Protocol Documentation (example placeholder, replace with actual MCP docs if available)
- n8n Node Development Guide
- JSON Schema Validation
- Server-Sent Events (SSE) Specification