Skip to main content

Get Prompt

Retrieves a prompt from an MCP server with optional parameters and returns the rendered prompt content. This node enables your automation to fetch dynamic prompt templates from MCP servers.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Client Id - The MCP client connection identifier from the Connect node.
  • Prompt Name - The name of the prompt to retrieve from the server.
  • Parameters - JSON object containing parameters to pass to the prompt template (optional). Parameters are substituted into template variables.

Options

  • Timeout - Timeout in seconds for the operation (default: 30).

Outputs

  • Prompt Content - The rendered prompt content as a string, with parameters substituted into the template.

How It Works

The Get Prompt node retrieves prompts from MCP servers:

  1. Client Lookup - Retrieves the MCP client using the provided Client ID
  2. Parameter Processing - Converts parameters to map[string]string format
  3. Request Creation - Creates an MCP GetPromptRequest with name and parameters
  4. Prompt Retrieval - Sends request to server and receives prompt response
  5. Content Extraction - Extracts text content from the prompt messages
  6. Output - Returns the rendered prompt content

Requirements

  • Valid Client ID from a Connect node
  • Non-empty Prompt Name
  • Active connection to the MCP server
  • Optional parameters matching the prompt's expected variables

Error Handling

The node returns specific errors:

  • ErrInvalidArg - Client ID or Prompt Name is empty
  • ErrMCPToolCall - Failed to retrieve the prompt from the server

Usage Notes

Parameters Format

Parameters can be provided in multiple formats:

  • JSON Object: {"name": "Alice", "company": "Acme Corp"}
  • JSON String: '{"name": "Alice"}'
  • Message Variable: msg.prompt_params

Parameter Conversion

  • All parameter values are converted to strings
  • Non-string values are JSON-serialized
  • Empty parameters are treated as empty object {}

Prompt Content

  • The output is the rendered prompt text
  • Template variables are replaced with parameter values
  • If multiple messages exist, the first message's text is returned

Examples

Example 1: Simple Greeting Prompt

Inputs:

  • Client Id: prompt-server
  • Prompt Name: greeting
  • Parameters:
{
"name": "John",
"company": "Tech Corp"
}

Prompt Content Output:

Welcome John to Tech Corp! We're excited to have you join our team.

Example 2: Code Review Prompt

Inputs:

  • Client Id: ai-prompts
  • Prompt Name: code_review
  • Parameters:
{
"language": "Python",
"focus": "security",
"severity": "critical"
}

Prompt Content Output:

Review the following Python code for:
- Best practices
- Security issues
- Performance optimization
- Code style consistency

Focus area: security
Severity level: critical

Example 3: Email Template

Inputs:

  • Client Id: template-server
  • Prompt Name: email_template
  • Parameters:
{
"recipient_name": "Alice",
"subject": "Project Update",
"sender_name": "Bob",
"sender_title": "Project Manager"
}

Prompt Content Output:

Subject: Project Update

Dear Alice,

[Body content would be here]

Best regards,
Bob
Project Manager

Example 4: Report Generation Prompt

Inputs:

  • Client Id: report-server
  • Prompt Name: sales_report
  • Parameters:
{
"period": "Q1 2024",
"region": "North America",
"metric": "revenue"
}

Prompt Content Output:

Generate a sales report for Q1 2024 focusing on North America.
Primary metric: revenue
Include trend analysis and comparison with previous period.

Example 5: No Parameters

Inputs:

  • Client Id: prompt-server
  • Prompt Name: daily_standup
  • Parameters: (empty)

Prompt Content Output:

Daily Standup Questions:
1. What did you accomplish yesterday?
2. What are you working on today?
3. Are there any blockers?

Best Practices

  1. Prompt Discovery:

    • Use List Prompts node first to discover available prompts
    • Verify prompt name spelling matches exactly
    • Check prompt descriptions for parameter requirements
  2. Parameter Management:

    • Provide all required parameters
    • Use consistent parameter naming
    • Document parameter purposes
    • Handle optional parameters appropriately
  3. Error Handling:

    • Check if prompt retrieval succeeded
    • Validate prompt content is not empty
    • Handle missing prompts gracefully
  4. Response Processing:

    • Parse the prompt content as needed
    • Use the content in subsequent AI operations
    • Store prompts for reuse if appropriate
  5. Timeout Configuration:

    • Use default timeout for simple prompts
    • Increase timeout for complex prompt generation
    • Handle timeout errors

Common Errors and Solutions

Error: "Client Id cannot be empty"

Cause: Client ID input is missing or empty.

Solution:

  • Connect Client Id from a Connect node
  • Verify Connect node executed successfully
  • Check Client Id is being passed correctly

Error: "Prompt name cannot be empty"

Cause: Prompt Name input is missing or empty.

Solution:

  • Provide a valid prompt name
  • Use List Prompts to discover available prompts
  • Check spelling matches exactly

Error: "MCP client not found"

Cause: No client exists with the provided Client ID.

Solution:

  • Ensure Connect node executed before Get Prompt
  • Verify Client ID is correct
  • Check connection didn't fail or close

Error: "Failed to get prompt"

Cause: Prompt retrieval failed on the server.

Solution:

  • Verify prompt exists on the server
  • Check parameters match prompt's expected variables
  • Ensure prompt name is correct
  • Check server logs for errors

Tips for Effective Use

  1. List First - Use List Prompts to discover available prompts
  2. Understand Parameters - Know which parameters each prompt expects
  3. Handle Errors - Implement error handling for failed retrievals
  4. Cache Prompts - Cache static prompts to reduce server calls
  5. Validate Output - Check prompt content is not empty
  6. Use with AI - Feed prompt content to AI models (Claude, GPT, etc.)
  7. Test Parameters - Test with various parameter combinations

Integration with AI Models

Pattern: Using Prompts with Claude

Get Prompt → Claude Generate Text

Flow:

  1. Get Prompt retrieves template
  2. Prompt content becomes User Prompt or System Prompt
  3. Claude generates response based on the prompt

Example:

Get Prompt (code_review) → Claude Generate Text
Input: code to review
System: [prompt content]

Pattern: Dynamic Prompt Selection

Determine Context → Get Prompt (dynamic name) → AI Model

Flow:

  1. Logic determines which prompt to use
  2. Get Prompt retrieves appropriate prompt
  3. AI model processes with the prompt

Usage Patterns

Pattern 1: Static Prompt Retrieval

Connect → Get Prompt → Use Prompt Content

Pattern 2: Parameterized Prompt

Prepare Parameters → Get Prompt → AI Processing

Pattern 3: Multi-Prompt Workflow

Connect → Get Prompt A → Process
→ Get Prompt B → Process
→ Combine Results

Pattern 4: Conditional Prompt Selection

Determine Scenario → Branch → Get Prompt X
→ Get Prompt Y

Pattern 5: Prompt with AI

Get Prompt → Claude/GPT → Process Response

Advanced Examples

Dynamic Parameter Building

// In a JavaScript node before Get Prompt
msg.prompt_params = {
user_name: msg.user.name,
user_role: msg.user.role,
context: msg.current_task,
date: new Date().toISOString().split('T')[0],
preferences: JSON.stringify(msg.user.preferences)
};

Multi-Step Prompt Composition

Get Prompt (intro) → Store
Get Prompt (body) → Store → Combine → AI Model
Get Prompt (conclusion) → Store

Localized Prompts

// Select prompt based on language
const language = msg.user.language;
const promptName = `greeting_${language}`; // greeting_en, greeting_es, etc.