Guides/End-to-end agent workflow with MCP

End-to-end agent workflow with MCP

Create a form, share the URL, poll for submissions, build a dashboard. All via MCP tools.

Updated March 2026

This guide walks through a complete agent workflow using Sutrena's MCP tools or REST API. The agent creates a form to collect human input, shares the URL, waits for submissions, and then builds a dashboard from the results. This is the pattern for any agent that needs to collect structured data from humans and visualize it -- feedback surveys, approval workflows, data collection campaigns, research questionnaires. The examples show both MCP tool calls (for Claude Code, Cursor, or any MCP client) and equivalent SDK code.

1. Create a trial account (if needed)

If the agent doesn't have an API key, it creates a free trial account first. This returns a key instantly with no signup required. The key works for 24 hours before the account needs to be claimed via OAuth.

// MCP tool: (handled automatically by the MCP server)
// The agent authenticates with an existing key or gets a trial key.

// SDK equivalent:
import { Sutrena } from "@sutrena/sdk";

const trial = await Sutrena.createTrial();
console.log("API Key:", trial.key);
console.log("Subdomain:", trial.subdomainUrl);
console.log("Claim before:", trial.claimDeadline);

const s = new Sutrena(trial.key);

2. Create a form to collect data

The agent creates a form with the fields it needs. The MCP tool `sutrena_create_form` or `POST /api/forms` returns a hosted form URL and a submission endpoint.

// SDK
const { data: form } = await s.forms.create({
  name: "Customer Research Survey",
  fields: [
    { name: "name", label: "Your name", type: "text", required: true },
    { name: "email", label: "Email", type: "email", required: true },
    { name: "role", label: "Your role", type: "select",
      options: ["Developer", "Designer", "PM", "Founder", "Other"] },
    { name: "pain_point", label: "Biggest pain point", type: "textarea", required: true },
    { name: "would_pay", label: "Would you pay for a solution?", type: "select",
      options: ["Yes", "Maybe", "No"] },
  ],
  successMessage: "Thanks! Your response has been recorded.",
});

console.log("Share this URL:", form.hostedFormUrl);
console.log("Form ID:", form.formId);

3. Deploy a landing page with the embedded form

Optionally, the agent creates a landing page that embeds the form. This gives a more polished experience than the hosted form URL alone.

// SDK
const { data: page } = await s.pages.create({
  slug: "index",
  title: "Customer Research — Help Us Build Something Great",
  html: `<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head>
<body>
  <div class="container">
    <h1>Help us build something great</h1>
    <p>We're researching pain points in developer tooling. Your 2-minute response shapes what we build next.</p>
    <iframe src="https://sutrena.com/f/${form.formId}?embed=1"
            style="width:100%;min-height:600px;border:none;"></iframe>
  </div>
</body>
</html>`,
  css: `body { font-family: system-ui, sans-serif; margin: 0; padding: 2rem; background: #fafafa; }
.container { max-width: 640px; margin: 0 auto; }`,
});

console.log("Landing page:", page.subdomainUrl);

4. Wait for submissions and poll for results

The agent shares the form URL (or landing page URL) with humans. Then it polls for submissions on an interval or uses a webhook callback.

// SDK — poll for submissions
const { data } = await s.submissions.list(form.formId, {
  limit: 100,
});

console.log(`${data.submissions.length} responses so far`);

for (const sub of data.submissions) {
  console.log(`${sub.payload.name} (${sub.payload.role}): ${sub.payload.would_pay}`);
}

5. Build a dashboard from the results

Once enough submissions are in, the agent creates a dashboard to visualize the data. Seven widget types are available: metric cards, tables, pie/bar/line charts, text blocks, and action tables.

// SDK
const { data: dashboard } = await s.dashboards.create({
  title: "Customer Research Results",
  formId: form.formId,
  dsl: {
    version: 1,
    widgets: [
      { type: "metric_card", title: "Total Responses", value: "count(*)" },
      { type: "metric_card", title: "Would Pay", value: "count(would_pay)",
        status: undefined },
      { type: "pie_chart", title: "Roles", groupBy: "role" },
      { type: "bar_chart", title: "Would Pay?", groupBy: "would_pay" },
      { type: "line_chart", title: "Responses Over Time",
        groupBy: "$submitted_at:day" },
      { type: "data_table", title: "All Responses",
        columns: ["name", "email", "role", "would_pay"], limit: 50 },
    ],
  },
  isPublic: true,
});

console.log("Dashboard:", dashboard.dashboardUrl);

6. Share the results

The agent now has three live URLs to share: the landing page, the form, and the dashboard. The dashboard auto-refreshes every 30 seconds as new submissions come in.

console.log("=== Your Research Campaign ===");
console.log("Landing page:", page.subdomainUrl);
console.log("Direct form:", form.hostedFormUrl);
console.log("Dashboard:", dashboard.dashboardUrl);
console.log("");
console.log("Share the landing page URL with your audience.");
console.log("Watch results appear on the dashboard in real time.");

FAQ

Can I do all of this from Claude Code or Cursor?

Yes. Sutrena has 75 MCP tools. Claude Code and Cursor can call `sutrena_create_form`, `sutrena_create_page`, `sutrena_search_submissions`, and `sutrena_create_dashboard` in a single conversation. The agent handles the entire workflow without leaving the IDE.

How do I add the MCP server to my agent?

Add `{ "mcpServers": { "sutrena": { "command": "npx", "args": ["-y", "sutrena"], "env": { "SUTRENA_API_KEY": "st_live_xxx" } } } }` to your MCP client config. Works with Claude Code, Cursor, Windsurf, and any MCP-compatible client.

Can the agent react to each submission in real time?

Yes. Use the webhook callback pattern (see related guide) to receive HTTP POST notifications for each submission. Or use polling for agents that can't receive HTTP. Or set `autoEntryPageId` on the form to auto-add entries to a page as they come in.

What if I want the agent to moderate or process submissions?

Use an action_table widget in the dashboard. It adds inline editable dropdowns (e.g. status: open/reviewed/done) that update submissions via the API. Or use the webhook callback pattern so the agent processes each submission programmatically.

What is Sutrena?

Sutrena is the web runtime for AI agents. Forms, Pages, Dashboards, Analytics, Webhooks, Automations, Emails — all through 75 MCP tools and one REST API. Your agent creates web artifacts, humans interact with them, and your agent gets the data back. Use any one feature or all of them together.

Pages

Deploy HTML instantly

Forms

Collect structured data

Dashboards

Visualize with 7 widget types

Analytics

Privacy-first, no cookies

Webhooks

Slack, Discord, Telegram

Get started in two API calls

1. Get a trial key (no auth, no signup)

curl -X POST https://sutrena.com/api/trial

2. Create anything — a page, form, dashboard, or analytics site

# Create a form with a dashboard
curl -X POST https://sutrena.com/api/forms \
  -H "Authorization: Bearer st_trial_xxx" \
  -H "Content-Type: application/json" \
  -d '{"workflowId": "waitlist", "createDashboard": true}'

# Or deploy a page
curl -X POST https://sutrena.com/api/pages \
  -H "Authorization: Bearer st_trial_xxx" \
  -H "Content-Type: application/json" \
  -d '{"slug": "index", "title": "My Site", "html": "<h1>Live</h1>"}'

Ready to build?

Get a trial API key instantly with no signup, or create an account for the full experience.

End-to-end agent workflow with MCP — forms, submissions, dashboards | Sutrena | Sutrena