MCP Get Prompt
Controlled node
Overview
The MCP Get Prompt node connects to a Model Context Protocol (MCP) server to retrieve a specific prompt template by name, optionally passing arguments to populate template variables. This node enables workflows to fetch pre-defined prompts from MCP-compatible servers, which can then be used with AI generation nodes or other text processing workflows.
The node establishes a temporary connection to the MCP server, retrieves the requested prompt with the provided arguments, and then closes the connection. If the prompt retrieval fails or the server returns an error, the result output will contain an error object with details.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| URL | Text | The URL of the MCP server to connect to. | - |
| Headers | Dictionary | HTTP headers to include in the connection request (e.g., authorization tokens). | {} |
| Name | Text | The name of the prompt to retrieve from the MCP server. This is required. | - |
| Arguments | Dictionary | Key-value pairs to populate template variables in the prompt. | {} |
| Timeout | Number | Connection timeout in milliseconds. | 60000 |
| Run | Event | Fires when the node starts running. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Result | Data | Contains the retrieved prompt data from the MCP server, or an error object if the request failed. |
| Done | Event | Fires when the node has finished executing and the connection has been closed. |
Runtime Behavior and Defaults
When triggered by the Run event, the node:
- Establishes a connection to the specified MCP server URL with the provided headers
- Sends a
getPromptrequest with the specified prompt name and arguments - Receives the prompt template (with arguments substituted if applicable)
- Closes the connection cleanly
- Outputs the result and fires the Done event
Default Values:
- Timeout: 60000ms (60 seconds)
- Headers: Empty dictionary
- Arguments: Empty dictionary
Error Handling:
If the MCP server returns an error or the connection fails, the Result output will contain an object with an error property describing the failure. The node will still fire the Done event even if an error occurs.
Connection Management: The node automatically manages the MCP client lifecycle, ensuring connections are properly closed after the operation completes, regardless of success or failure.
Example Usage
Basic Prompt Retrieval:
Connect the Run event from a Start node or button to trigger the MCP Get Prompt node. Provide the MCP server URL and the prompt name (e.g., "analyze-code"). The retrieved prompt will be available in the Result output for use with an AI Write node.
Passing Arguments:
If the MCP prompt accepts variables (e.g., {{language}} and {{code}}), provide these in the Arguments input as a dictionary:
{
"language": "javascript",
"code": "function hello() { return 'world'; }"
}
Error Checking: Connect the Done event to an Assert node to check if the result contains an error before proceeding with AI generation.