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 leverage external AI or processing tools exposed via MCP, such as running language models, data processors, or custom utilities remotely.
Practical examples include:
- Executing an AI model inference tool by specifying its name and input parameters.
- Running a data transformation tool that requires structured JSON input.
- Automating workflows that depend on external MCP tools without manual intervention.
Properties
Name | Meaning |
---|---|
Connection Type | Choose how to connect to the MCP server: - 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. Must be valid JSON format. |
Output
The node outputs a single item with a json
property containing:
result
: The output returned by the executed tool. This can be any JSON-serializable value depending on the tool's response. For example, it might be a string, number, object, or array representing the tool's result.
The node does not explicitly handle binary data output for this operation.
Dependencies
Requires connection to an MCP server, which can be accessed either via:
- A command line interface using STDIO transport, configured with a command and arguments.
- A Server-Sent Events (SSE) transport, configured with a URL and optional headers.
Requires appropriate credentials for the chosen connection type:
- An API key or authentication token for the command line connection.
- An SSE URL and optional headers for the SSE connection.
Environment variables starting with
MCP_
can be used to pass additional environment settings to the command line transport.The node depends on the MCP SDK client libraries bundled internally.
Troubleshooting
Invalid JSON in Tool Parameters: If the "Tool Parameters" input is not valid JSON, the node will throw an error indicating failure to parse parameters. Ensure the JSON is well-formed.
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 (either via command line or SSE) will cause errors. Check credentials, URLs, commands, and network connectivity.
Transport Errors: Errors during communication with the MCP server are surfaced with messages prefixed by "Transport error". Review transport configuration and logs.
Unexpected Operation: Using an unsupported operation value will cause an error stating the operation is not supported.
Links and References
- MCP Protocol Documentation (hypothetical link for reference)
- n8n Custom Node Development
- JSON Schema Validation (relevant for understanding input parameter validation)