Actions Developer Guide

Triggers and Integrations

Understand how to trigger actions via API, UI, or AI Agents via MCP.

Intelligent MCP Integration (The AI DevOps Agent)

Because each action block strictly defines an input schema and a description, the Rescile MCP Server automatically parses all loaded actions and exposes them as MCP Tools to Large Language Models (LLMs)

The AI Workflow:

  1. An LLM uses listResources and identifies a database failing compliance.
  2. The LLM queries the MCP server for available tools.
  3. The MCP Server dynamically presents available actions (e.g., terraform_apply) along with their required JSON schema.
  4. The LLM constructs a JSON payload (e.g., { "application_name": "db-main" }) and calls the tool.
  5. Rescile securely bundles the instruction, executes the action via rescile-runner, and streams the aggregated execution logs back to the LLM.

Automated API & UI Triggering

When Rescile loads a module, it dynamically generates REST endpoints for each action:

POST /api/actions/:module_name/:action_name

The Rescile core automatically validates incoming JSON payloads against the defined input_schema.

Frontend Integration: The Managed Services Portal UI (or any custom app) can trigger actions simply by making a POST request to the endpoint with the necessary context JSON. Execution streams stdout and stderr directly to a dedicated Server-Sent Events (SSE) endpoint (/api/actions/stream/:execution_id), enabling real-time observability in the browser.


Background & Automated Triggers

You can also instruct Rescile to execute actions autonomously without user or API intervention.

Cron Schedules

If an action should run periodically (like a backup or sync job), you can define a standard cron expression via the schedule parameter.

name = "nightly_backup"
description = "Creates a database snapshot every night at 2 AM"
schedule = "0 2 * * *" # standard cron format

[runtime]
engine = "nix"
flake = "./flake.nix"
exec = ["python3", "backup.py"]

Graph-Driven Auto Execution

For Dynamic Actions that expand based on graph state (see Action Expansion), you can instruct Rescile to automatically queue the action the moment the node matches the criteria.

name = "remediate_exposed_port"
description = "Closes security groups if port 22 is exposed to the internet"
origin_resource = "security_group"
match_on = [
  { property = "has_exposed_ssh", value = "true" }
]
auto_execute = true # Trigger immediately upon graph node matching

[runtime]
engine = "http"
[[runtime.steps]]
method = "DELETE"
url = "https://api.cloud.internal/v1/sg/{{ origin_resource.id }}/rules/22"

With auto_execute = true, the moment the graph ingests data indicating a security group has an exposed SSH port, Rescile will instantly bundle and dispatch this remediation action.