# Agent Setup & Agentic Tutorial (MCP)

> Connect your AI agent to Glow over MCP and build a validated Draft automation on your live multiplayer canvas in two minutes.

Connect your AI assistant or IDE to Glow over the Model Context Protocol (MCP). Your agent assembles, wires, and validates Steps directly on your **live multiplayer canvas**.

Communication between your AI agent and the canvas works **both ways**:

- **Agent to canvas:** Your agent places Steps, wires branches, and writes Markdown sticky notes on your open canvas in real time.
- **Canvas to agent:** Your agent reads the sticky notes you sketch on the canvas. It also sees which Step you have open, so you can click a Step and say _"fix this step"_.

**At a glance**

- **Use it to:** Connect your AI assistant or IDE to Glow over MCP for two-way live canvas building, sticky-note collaboration, and spatial awareness
- **Cost:** Uses your workspace allowances when running tests or live runs (see Settings → Billing & Usage)
- **Limits:** Up to 25 active MCP connections per user · Up to 50 canvas operations per update_workflow call
- **Find it:** Your account → MCP · Team settings → MCP
- **Output:** A validated Draft automation synced live to your canvas with canvasMarkdownLink, sticky notes, and open-Step selection awareness
- **Applies to:** All workspaces (Free & Paid)
- **Owner:** Glow Docs & Engineering
- **Last verified:** Nov 4, 2026

## [Agentic Tutorial: Build Your First Automation in 2 Minutes](https://docs.getglow.ai/getting-started/agent-setup#agentic-tutorial)

[1. Connect MCP (30s)](https://docs.getglow.ai/getting-started/agent-setup#step-1-connect-your-ai-client)

### [1. Connect your AI client (30 seconds)](https://docs.getglow.ai/getting-started/agent-setup#step-1-connect-your-ai-client)

Point your AI client at Glow's hosted Streamable HTTP MCP server:

- **MCP Server URL:** `https://api.getglow.ai/mcp`.
- **Authentication:** Sign in with OAuth 2.0 when prompted, or create a scoped token in **Your account → MCP** using the **Build drafts (Recommended)** preset.
- **Client config snippets:** Open [Connecting AI Apps & Editors](https://docs.getglow.ai/developers/mcp/client-setup) for ready-to-copy setups for Claude, ChatGPT, Cursor, VS Code, and other MCP clients.

### [2. Paste this starter prompt (30 seconds)](https://docs.getglow.ai/getting-started/agent-setup#step-2-paste-this-starter-prompt)

Copy either prompt below into your connected AI client:

**Starter Prompt A: Morning Focus Note (no external app accounts needed)**

```text
Read https://docs.getglow.ai/getting-started/agent-setup.md first. Using Glow MCP (list_workspaces, search_components, get_step_context, update_workflow, and validate_workflow), create a new Draft workflow named "Morning Focus Note" in my workspace:
1. Step 1: Scheduler trigger (schedule) set to every weekday at 09:00.
2. Step 2: AI Prompt (glowAi) connected from Step 1 that writes a one-sentence focus note for the day.
Leave the workflow in Draft, run validate_workflow to confirm valid: true, and return the canvasMarkdownLink without running it.
```

**Starter Prompt B: Webhook Lead Triage with Conditions (branching)**

```text
Read https://docs.getglow.ai/getting-started/agent-setup.md first. Using Glow MCP (search_components, get_step_context, update_workflow, and validate_workflow), create a new Draft workflow named "Inbound Lead Triage" in my workspace:
1. Step 1: Webhook trigger (http/new-requests) with sample testing data {"email": "ada@acme.io", "company": "Acme", "notes": "Looking for enterprise rollout for 120 seats"}.
2. Step 2: AI Prompt (glowAi) with JSON output returning {"score": 85, "summary": "..."} based on {{ 1.body.notes }}.
3. Step 3: Conditions (condition) with a "Hot Lead" route checking {{ 2.result.score }} greater than or equal to 70 and an Else route.
Leave it in Draft, run validate_workflow, and return the canvasMarkdownLink without running a live test.
```

### [3. Open your live canvas and work both ways (1 minute)](https://docs.getglow.ai/getting-started/agent-setup#step-3-open-your-live-canvas-and-preview)

Your agent replies with an **Open in Glow** link (`canvasMarkdownLink`) and a validation check (`valid: true`, `errorCount: 0`):

1. Click **`canvasMarkdownLink`** in your chat to open the Draft on the Glow multiplayer canvas.
2. Click any Step on the canvas to open its settings drawer. Tell your agent _"update the Step I have open"_, and it detects your selection (`viewerSelection`) and edits it in place.
3. Press `N` on the canvas to add a sticky note. Write what you want to change next and ask your agent to apply it.
4. Click **Run** on the canvas (or ask your agent to run `run_workflow_test` with `writeMode: "preview"`) to inspect each Step's output.

## [Two-Way Canvas Sync, Sticky Notes & Spatial Awareness](https://docs.getglow.ai/getting-started/agent-setup#two-way-canvas-sync)

Glow's MCP server keeps your AI client and your open browser canvas connected in both directions:

| Capability                                                      | What you and your AI agent can do                                                                                                                                              |
| :-------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Live canvas updates (`update_workflow`)**                     | Every Step addition (`addStep`), field edit (`setStepParameters`), branch connection (`addConnection`), or layout pass (`tidyCanvas`) appears immediately on your open canvas. |
| **Spatial & selection awareness (`viewerSelection`)**           | When you click a Step on the canvas, `get_workflow` reports that Step in `viewerSelection`. Say _"fix this step"_ or _"map the email into this step"_ without Step numbers.    |
| **Two-way sticky notes (`addStickyNote` / `updateStickyNote`)** | Sketch ideas on canvas sticky notes (`N`) and ask your agent to build them. Your agent can also place color-coded Markdown sticky notes above the graph to leave checklists.   |
| **Multiplayer collaboration**                                   | Teammates and connected AI agents work on the same automation together, backed by version checkpoints (`save_workflow_version`) and change history (`get_workflow_history`).   |

## [The 4-Step Deterministic Agent Build Loop](https://docs.getglow.ai/getting-started/agent-setup#the-4-step-agent-build-loop)

When an AI agent reads `https://docs.getglow.ai/getting-started/agent-setup.md`, it should follow this four-step sequence against `https://api.getglow.ai/mcp`:

### 1. Confirm the workspace and balance

Call `list_workspaces` and `list_workflows` first. Confirm the target `teamId`, check the workspace balance, and verify whether to create a new Draft or update an existing one.

### 2. Inspect schemas and connected accounts

Call `search_components` to locate the exact `componentKey` (`<app_slug>/<action>` or a built-in key like `glowAi`). Next, call `get_step_context` to read live parameter schemas, connected `accountId` values, and remote picker choices before setting parameters.

### 3. Build in Draft with `update_workflow`

Call `update_workflow` to apply up to 50 canvas operations in one transaction. Omit `workflowId` and pass `name` plus a fresh `idempotencyKey` to create and wire a new Draft workflow in one call. Check `viewerSelection` from `get_workflow` whenever the user refers to _"this step"_.

### 4. Validate the graph with `validate_workflow`

Call `validate_workflow` after saving edits. Verify `valid: true` (`errorCount: 0`), connected edges, and valid output references before reporting the automation ready.

## [Core Modeling Rules for Agents](https://docs.getglow.ai/getting-started/agent-setup#core-modeling-rules-for-agents)

AI agents building or editing Glow automations should follow five rules:

- **Use built-in AI Steps by default:** Choose Glow's built-in AI Steps (`glowAi`, `aiAgent`, `aiTransform`) unless the user explicitly asks for a third-party provider BYOK Step.
- **Loop with `runForEachItem`:** Set `settings.runForEachItem: true` and `settings.itemsSource` on the action Step instead of looking for a legacy Split Out Step. Use `repeater` for multi-step loops.
- **Compare lists with `Combine`:** Use `Combine` (`combine`) in `match` mode when comparing, joining, or diffing two lists.
- **Keep secrets out of unsafe sinks (`SECRET_IN_UNSAFE_SINK`):** Never place `$secret` or `$key` references inside AI prompts, Data Store steps, Convert to File, or Respond to Webhook. Validation and runtime execution reject secrets in those Steps.
- **Share setup links and confirm live actions:** Return `canvasMarkdownLink` and any `connectMarkdownLink` entries to the user. Ask for confirmation before calling `run_workflow_test` with `writeMode: "execute"` or `set_workflow_status` (`live`).

**Verify it works**

- **Run:** Connect your MCP client to https://api.getglow.ai/mcp, call search_components and get_step_context, then create a Draft workflow with update_workflow and run validate_workflow.
- **You should see:** validate_workflow returns valid: true with errorCount: 0, and canvasMarkdownLink opens the Draft automation on the live canvas.

## What's Next?

- 👉 **[Connecting AI Apps & Editors →](https://docs.getglow.ai/developers/mcp/client-setup)**: copy MCP setup configs for your AI chat app or coding editor.
- **[MCP Tool Reference](https://docs.getglow.ai/developers/mcp/tool-reference)**: inspect parameters, effect classifications, and return shapes for every MCP tool.
- **[Testing Automations with MCP](https://docs.getglow.ai/developers/mcp/testing)**: preview write Steps with `writeMode: "preview"` and inspect step traces.
- **[MCP Administration](https://docs.getglow.ai/manage/workspace-settings/mcp)**: configure workspace permission ceilings and connection expiry.
