Agent Gateway

Workflow Tools

Expose Tray workflows as Composite Tools through your MCP server for AI agents to execute complex multi-step business logic.

Workflow Tools expose complete Tray workflows as single tools that AI agents can execute. Each tool packages multi-step business logic, data transformations, validation, and error handling into one callable function.

What are Workflow Tools?

Workflow Tools (also called Composite Tools) are Tray workflows exposed through your MCP server. When an AI agent calls a Workflow Tool, it executes the entire workflow with provided inputs and returns structured results.

Key benefits:

  • Reduced context usage - One tool instead of multiple separate operations
  • Built-in logic - Validation, error handling, and business rules embedded
  • Lower hallucination risk - Controlled execution flow reduces AI decision points
  • Governance - Human-in-the-loop approvals, audit logging, security controls

Why Use Workflow Tools?

Example: Sending a Slack Message

Without Workflow Tools, AI needs two separate operations:

  1. Lookup user by name (returns multiple "Tom" results)
  2. Send message with user ID (AI must choose correct Tom)

This requires two LLM calls, uses more context, and risks sending to wrong person.

With a Workflow Tool, AI calls one Send Slack Message tool:

  • Accepts user name and message as inputs
  • Workflow handles user lookup internally
  • Workflow prompts for clarification if multiple matches
  • Workflow sends to confirmed user
  • Returns success confirmation

One LLM call, less context, correct execution guaranteed.

Adding Workflow Tools

Prerequisites:

  • Workflow published and enabled
  • Clear input schema defined
  • Structured output returned
  • Workflow in same workspace as MCP server

Steps:

  1. Navigate to Workspace SettingsAgent GatewayMCP Server
  2. Click Workflow tools tab
  3. Select workflows to expose
  4. Each becomes a tool with name, description, input schema, and output schema from the workflow

Workflow Tools

Designing Effective Tools

Input Design

Define clear parameters with validation in the workflow:

Create Salesforce Lead inputs:
- Lead name (required)
- Company (required)
- Phone (optional)
- Email (optional)

Output Design

Return structured, actionable data:

{
  "success": true,
  "lead_id": "00Q5e00000ABC123",
  "lead_url": "https://company.salesforce.com/00Q5e00000ABC123",
  "message": "Lead created successfully for John Doe at Acme Corp"
}

Tool Descriptions

Write clear descriptions explaining what, when, and how:

Good: "Sends Slack message to specified channel, user, or group. Uses channel ID if available, otherwise looks up by name. Prompts for clarification if multiple matches found."

Avoid: "Sends messages to Slack."

Common Patterns

Data Lookup with Validation

  • Search records by criteria
  • Validate results (single/multiple/no match)
  • Handle edge cases (expired records, permissions)
  • Use case: Customer lookup before creating support ticket

Multi-System Orchestration

  • Retrieve data from System A
  • Transform per business rules
  • Update System B
  • Notify via System C
  • Use case: Invoice processing across ERP and accounting

Human-in-the-Loop Approval

  • Receive AI request
  • Validate parameters
  • Request approval
  • Execute if approved
  • Use case: High-value purchase orders

Read-Only Aggregation

  • Query multiple systems
  • Aggregate and calculate
  • Return formatted summary
  • Use case: Customer 360 view

Best Practices

Keep tools focused:

  • One business function per tool
  • Avoid generic "do everything" tools
  • ✅ Good: "Create Salesforce Lead", "Update Salesforce Lead"
  • ❌ Avoid: "Manage Salesforce"

Build robust error handling:

  • Catch API errors gracefully
  • Return clear error messages
  • Log for debugging
  • Implement retry logic where appropriate

Test thoroughly:

  • Expected inputs
  • Invalid/missing inputs
  • Error conditions
  • Edge cases
  • Verify AI can interpret outputs

Document clearly:

  • Workflow documentation becomes tool description
  • Document parameters and formats
  • Include example use cases
  • Note limitations and prerequisites

Managing Tools

Enabling/Disabling:

  • View all exposed workflows in Workflow tools tab
  • Toggle individual tools on/off
  • Status indicator shows enabled/disabled state

Updating:

  • Workflow changes reflect immediately
  • No MCP server reconfiguration needed
  • AI agents see updated schemas automatically

Removing:

  • Click options menu (•••) next to tool
  • Select remove/disable
  • Tools become immediately unavailable

Troubleshooting

Tool not found:

  • Verify workflow is published and enabled
  • Check MCP server is enabled
  • Ensure tool is enabled in Workflow tools tab
  • Restart AI client

Execution fails:

  • Check workflow logs
  • Verify input format matches schema
  • Ensure workflow has necessary permissions
  • Test manual execution

AI uses incorrectly:

  • Improve tool description clarity
  • Add input validation in workflow
  • Consider splitting into more focused tools

Next Steps

Was this page helpful?