Resource Out
Returns the content of a resource to the MCP client. This node completes the resource retrieval flow by sending the requested resource data back to the requesting client.
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.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Caller ID - Unique identifier for the resource request. This is automatically provided by the system and matches the request to its response channel.
- Resource URI - The URI of the resource being returned. Should match the requested URI.
- Content Type - The MIME type of the resource content. Examples:
text/plain,application/json,text/markdown. - Resource Data - The actual content of the resource as a string. This is what the client receives.
How It Works
The Resource Out node completes the resource retrieval workflow:
- Request Tracking - Receives the Caller ID that identifies the specific client request
- Channel Lookup - Finds the response channel associated with this request
- Data Validation - Validates the Resource URI, Content Type, and Resource Data
- Content Type Handling - Uses provided Content Type or defaults to
text/plain - Response Creation - Creates an MCP-compliant resource result with the content
- Client Delivery - Sends the result back to the waiting client through the response channel
The node creates a structured resource response with:
- Resource URI (identifies what was requested)
- MIME type (describes content format)
- Text content (the actual resource data)
Requirements
- Must receive a valid Caller ID from the message context
- Resource URI should be provided (identifies the resource)
- Content Type is optional (defaults to
text/plain) - Resource Data must be a string
- Must be used after a Resource In node in the flow
Error Handling
The node returns errors in the following cases:
- Failed to get caller ID - Caller ID is missing from the message
- No result channel found - Response channel doesn't exist for the Caller ID
- Failed to get resource URI/data - Required inputs are missing
- Any errors are wrapped with descriptive messages for debugging
Usage Notes
Flow Structure
A typical resource flow structure:
- Listen node (with Resource In connected to resources port)
- Resource In node (receives request with URI and parameters)
- Data fetching/generation logic
- Resource Out node (sends response)
Content Format
- Resource Data must be a string
- If your data is an object, convert it to JSON string
- For binary data, encode as base64 string
- Ensure content matches the declared Content Type
Content Type Defaults
- If Content Type is not provided or empty, defaults to
text/plain - Always specify Content Type when returning structured data
- Match Content Type to actual data format
Examples
Example 1: Return Text File
Resource In receives: docs://readme
Processing:
- Read README.md file from disk
- Load content as string
Resource Out inputs:
- Caller ID: (from message)
- Resource URI:
docs://readme - Content Type:
text/markdown - Resource Data: (README file content)
Client receives: Markdown content of README
Example 2: Return JSON Data
Resource In receives: users://123/profile
Processing:
- Query database for user ID 123
- Format as JSON string
Resource Out inputs:
- Caller ID: (from message)
- Resource URI:
users://123/profile - Content Type:
application/json - Resource Data:
{"id": 123, "name": "Alice", "email": "alice@example.com"}
Client receives: JSON user profile
Example 3: Return Generated CSV
Resource In receives: reports://2024/03/sales
Processing:
- Query sales database
- Generate CSV format
- Convert to string
Resource Out inputs:
- Caller ID: (from message)
- Resource URI:
reports://2024/03/sales - Content Type:
text/csv - Resource Data:
Date,Product,Amount
2024-03-01,Widget A,1200
2024-03-02,Widget B,850
Client receives: CSV sales report
Example 4: Return HTML Page
Resource In receives: pages://help/getting-started
Processing:
- Load HTML template
- Insert dynamic content
- Return complete HTML
Resource Out inputs:
- Caller ID: (from message)
- Resource URI:
pages://help/getting-started - Content Type:
text/html - Resource Data: Complete HTML page as string
Example 5: Error Response
Resource In receives: users://999/profile
Processing:
- Query database
- User not found
- Generate error message
Resource Out inputs:
- Caller ID: (from message)
- Resource URI:
users://999/profile - Content Type:
application/json - Resource Data:
{"error": "User not found", "code": 404}
Note: Even error responses go through Resource Out to ensure client receives a response.
Best Practices
-
Always Respond:
- Every Resource In should have a corresponding Resource Out
- Always send a response, even for errors
- Don't leave clients waiting indefinitely
-
Accurate Content Types:
- Always specify the correct MIME type
- Match Content Type to actual data format
- Use standard MIME types
-
Data Validation:
- Validate Resource Data before sending
- Ensure data is properly formatted
- Check that data is a string
-
URI Consistency:
- Resource URI should match what was requested
- Include all path parameters
- Maintain URI structure
-
Error Handling:
- Return structured error messages
- Include helpful error details
- Use appropriate error formats (JSON for JSON resources)
-
Performance:
- Minimize processing time before Resource Out
- Use efficient data serialization
- Consider caching for frequently accessed resources
-
String Conversion:
- Convert objects to JSON strings:
JSON.stringify(obj) - Ensure proper encoding for special characters
- Handle null/undefined values
- Convert objects to JSON strings:
Common Errors and Solutions
Error: "Failed to get caller ID"
Cause: Caller ID is missing from the message context.
Solution:
- Ensure Resource Out is connected after Resource In
- Check message context is passed through the flow
- Verify no nodes clear the message context
Error: "No result channel found for caller ID"
Cause: Response channel no longer exists.
Solution:
- Client may have timed out
- Reduce processing time before Resource Out
- Check for excessive delays in the flow
Error: "Failed to get resource URI"
Cause: Resource URI input is missing.
Solution:
- Connect Resource URI input
- Ensure URI is provided from Resource In or processing logic
- Check for null/undefined values
Error: "Failed to get resource data"
Cause: Resource Data input is missing or empty.
Solution:
- Ensure data fetching logic completed successfully
- Check for errors in data processing nodes
- Verify Resource Data input is connected
Tips for Effective Use
- Caller ID Handling - Pass Caller ID through processing nodes unchanged
- String Conversion - Always convert data to string before Resource Out
- Content Type Accuracy - Match Content Type to actual data format
- Fast Response - Process and respond quickly to avoid timeouts
- Error Responses - Send structured error messages instead of failing
- Logging - Log responses for debugging and monitoring
- Testing - Test with various resource types and formats
Integration Patterns
Pattern 1: Simple File Return
Resource In → Read File → Resource Out
Direct file content return.
Pattern 2: Database Query
Resource In → Validate → Query DB → Format → Resource Out
Fetch and return database records.
Pattern 3: API Proxy
Resource In → Call External API → Transform → Resource Out
Proxy external API data.
Pattern 4: Generated Content
Resource In → Fetch Data → Generate Document → Resource Out
Dynamically generate resource content.
Pattern 5: Error Handling
Resource In → Try → Fetch Data → Resource Out
↓
Catch → Error Message → Resource Out
Handle errors with proper responses.
Pattern 6: Multi-Format Support
Resource In → Fetch Data → Format Switch → Resource Out
├─ JSON
├─ CSV
└─ XML
Return data in requested format based on parameters.
Data Format Examples
JSON Resource
// Convert object to JSON string
const data = { id: 123, name: "Alice" };
const resourceData = JSON.stringify(data);
// Content Type: "application/json"
CSV Resource
// Build CSV string
const rows = [
["Name", "Age", "City"],
["Alice", "30", "NYC"],
["Bob", "25", "LA"]
];
const resourceData = rows.map(row => row.join(",")).join("\n");
// Content Type: "text/csv"
Markdown Resource
// Build markdown string
const resourceData = `# Title\n\nContent here with **bold** text.`;
// Content Type: "text/markdown"
XML Resource
// Build XML string
const resourceData = `<?xml version="1.0"?><data><item>value</item></data>`;
// Content Type: "application/xml"