Skip to main content

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

InputTypeDescriptionDefault
URLTextThe URL of the MCP server to connect to.-
HeadersDictionaryHTTP headers to include in the connection request (e.g., authorization tokens).{}
NameTextThe name of the prompt to retrieve from the MCP server. This is required.-
ArgumentsDictionaryKey-value pairs to populate template variables in the prompt.{}
TimeoutNumberConnection timeout in milliseconds.60000
RunEventFires when the node starts running.-

Outputs

OutputTypeDescription
ResultDataContains the retrieved prompt data from the MCP server, or an error object if the request failed.
DoneEventFires when the node has finished executing and the connection has been closed.

Runtime Behavior and Defaults

When triggered by the Run event, the node:

  1. Establishes a connection to the specified MCP server URL with the provided headers
  2. Sends a getPrompt request with the specified prompt name and arguments
  3. Receives the prompt template (with arguments substituted if applicable)
  4. Closes the connection cleanly
  5. 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.