Skip to content

AI Blocks

AI blocks enable you to build Model Context Protocol (MCP) servers, allowing your flows to act as tools that AI agents and LLMs can invoke.

The MCP Tool block transforms your flow into an MCP server with custom tools for AI agents to use. Each MCP Tool block represents one tool in your MCP server.

When you create an MCP Tool block:

  1. Tool Registration: Block automatically registers as available tool in MCP server
  2. Agent Invocation: AI agents discover and invoke your tool with specific arguments
  3. Event Generation: Each invocation generates an event with the agent’s request
  4. Response Handling: Your flow processes the request and sends response back to block’s input

Once you have MCP Tool blocks in your flow, your flow becomes an MCP server that AI agents can connect to. When no blocks are selected on the canvas, the MCP server address is displayed in the right sidebar. Copy this address and use it to configure AI agents or MCP clients so they can discover and invoke the tools you’ve created.

The MCP server automatically includes all MCP Tool blocks from your flow as available tools.

Define the arguments your tool accepts. The schema specifies what parameters AI agents can pass to your tool when invoking it.

MCP Schema

Configure how your tool responds to invocations:

// Simple text response
`The weather in ${outputs.weatherApi.location} is ${outputs.weatherApi.temperature}°${outputs.weatherApi.units}`
// JSON response
{
location: outputs.weatherApi.location,
temperature: outputs.weatherApi.temperature,
conditions: outputs.weatherApi.conditions,
timestamp: new Date().toISOString()
}

When an AI agent invokes your MCP tool, the block generates an event:

{
"arguments": {
"incidentId": "Q2ZRSMVNLPVSKX",
"note": "note from claude"
},
"user": {
"email": "damiand@spacelift.io",
"role": "admin"
}
}

For tools that respond immediately:

  1. Create MCP Tool block
  2. Connect its output directly to its input
  3. Configure Response Body Expression to return desired response

For tools requiring data processing:

  1. Create MCP Tool block
  2. Connect output to processing blocks (HTTP Request, Transform, App blocks)
  3. Connect final processing block back to MCP Tool input
  4. Configure Response Body Expression based on processed data

MCP Example

MCP Tool Configuration:

  • Input Schema: Location (required), units (optional)
  • Response Body: outputs.formatResponse.weatherDescription

HTTP Request Configuration:

  • URL: https://api.weather.com/v1/current?location=${outputs.weatherLookup.arguments.location}
  • Data Retrieval Tools: Fetch information from internal systems
  • Action Execution Tools: Perform operations like creating tickets, sending messages
  • Workflow Triggers: Allow AI agents to initiate complex automation workflows