sutram
Open source Commands, not clicks

Make your web app ready for AI agents.

Describe what your app can do as commands, in a few lines of JavaScript. People type them in a console; agents call them as WebMCP tools or from JavaScript, in the user's own session. Every part of the app hooks in the same way. No screenshots, no new API.

Get started
Halfthe task tokens to build a Drupal Canvas page: 228k instead of 453k
21–25%fewer model calls on the same task: 21 instead of 28, 11 instead of 14
~10 linesof JavaScript for each thing your app can do

Claude Code driving Chromium on the Drupal demo, two tasks, one run with Sutram and one without on the same set-up: a direction, not a benchmark. Task tokens leave out the harness's own share of each call. How we measured

The problem

Today, agents guess their way through your app

An agent that can't see your app's actions has to read the page, guess what to click, and read it again to find out whether it worked. Sutram gives it the actions directly, and answers it can act on.

Without Sutram

  1. Read the whole page, or take a screenshot
  2. Guess which element is the field or the button
  3. Click, type, then read the page again
  4. No error message: work out what went wrong
  5. Start over when the layout changes

With Sutram

› form set request topic billing
topic set. The form now also asks for: invoice, amount.
› form set request invoice 2024-17
form set: "2024-17" is not a valid invoice number.
Use INV- and at least four digits, such as INV-20417.
› form set request invoice INV-20417
invoice set.

Every answer says what happened and what to do next. Try the forms example

How it works

Write a few lines per action. Every agent can use it.

Give each action a name, a JSON Schema for its input, and a function. Sutram does the rest: the tools, the console, the help pages and the input checks.

You writeapp.js
Sutram.register({ name: "cart add", provider: "cart", description: "Add a product to the cart", input: { // JSON Schema type: "object", properties: { sku: { type: "string" }, qty: { type: "integer", default: 1 } }, required: ["sku"], }, annotations: {}, // readOnly, consequential… run: ({ sku, qty }) => cart.add(sku, qty), });
Agents and people getsame checks, same function
WebMCPcart_add({ "sku": "V60-02", "qty": 2 })
ScriptSutram.call("cart_add", { sku: "V60-02", qty: 2 })
Console› cart add --sku=V60-02 --qty=2

Also generated from the same definition

  • Input checks, with errors that name the field and the fix
  • Help, manual pages and Tab completion in the console
  • A question to the person before consequential actions
  • One status of the whole page for agents
Read the quick start
Live demo

Try it on a tiny coffee shop

This page registers a handful of commands. Click one, or press ` and type. The shop's buttons, the console and agents all run the same commands.

Brew & Co. a demo shop

What an agent sees

    Who ran what live

    • Click a button or a command above.

    Hand it to your agent needs a browser it can drive

    See the prompt

    Paste it into an agent with a browser it can drive: Claude Code or Codex with Playwright MCP, Claude Desktop, Claude in Chrome. It lists this page's commands. The agent opens the page and uses its tools, Sutram.exec() or the console, and you watch every command it runs in the console. How it works

    What you get

    Works with today's agents. Ready for WebMCP.

    You don't wait for browsers to catch up. However an agent reaches the page, it gets the same commands, the same checks and the same function behind them.

    Browser agents and tests

    Playwright, Puppeteer and browser agents call Sutram.call() in the page and get data back, instead of clicking through it.

    Sutram.call()

    Claude, Codex and other agents

    Hand any agent with a browser one prompt, with the page's commands in it, or ship your own. It opens the page and uses its tools or the console, and you watch every command it runs.

    agentPrompt()

    WebMCP tools

    In browsers with WebMCP, every command is a native tool with its schema and hints, and the list follows the page.

    WebMCP

    A console for people

    A terminal in the page, with help, manual pages and Tab completion, all generated from your definitions.

    help · man · --json

    Asks before it matters

    Mark an action consequential, and the person is asked before an agent runs it. The page decides, not the agent.

    readOnly · consequential

    The user's session, nothing more

    Commands run in the browser and call your own code, so an agent can do exactly what the user could, and nothing else.

    no new API
    FAQ

    Questions you might have

    Something missing? Ask on GitHub.

    Why not just use WebMCP directly?

    WebMCP is how a page hands tools to an agent. It doesn't say which tools a page has, how they are named, or how many parts of an app share one page. Sutram is that layer: every part of the app (a form, the navigation, a module) registers its commands in one registry, people can type the same commands the agent calls, one command such as form set covers every form instead of one tool per form, and agents get help, errors that name the fix and events to poll. For one app with a few fixed actions, plain WebMCP is enough.

    Does Sutram read or change my page's HTML?

    No. Your app's JavaScript registers the commands and renders its own markup; Sutram never reads, searches or changes the page. In WebMCP browsers it registers tools through WebMCP's own registerTool().

    Why not build an API or an MCP server instead?

    For server-to-server work, do. Sutram is for the app the user already has open: commands run in the browser, in the user's logged-in session, and call your own code and endpoints. There is no new backend, no new login and no token to hand out.

    Is it safe to let agents act in my app?

    An agent can do exactly what the user could already do, and nothing more: access checks stay on your server. Mark an action consequential, and the person is asked before an agent runs it.

    How is this different from Playwright or browser-use?

    Those drive a browser. Sutram gives them something better to drive: instead of reading the page and clicking, they call Sutram.call("cart_add", …), get data back, and get errors that say what to fix.

    Do browsers support WebMCP yet?

    Support is still arriving, which is why Sutram doesn't depend on it. Browser agents and tests use your commands today, and browsers with WebMCP get them as native tools. Nothing changes in your code when support arrives.

    What does it cost to add?

    One script with no dependencies, about 37 kB gzipped when minified, and about ten lines for each action. It works with any framework, or none.

    Is it ready for production?

    Sutram is at version 0.8: open source, tested, and published on npm and drupal.org. The command contract may still change before 1.0, and until then breaking changes bump the minor version. See the changelog.

    I build on Drupal. Is there a module?

    Yes: composer require drupal/sutram. It ships the package build, and its demo modules expose menus, pages and node forms as commands. See the Drupal demo.

    Get started

    Make your app agent‑ready in a minute

    Paste this into an HTML file, open it, and press `. In a browser with WebMCP, agents already have a hello_world tool.

    • npm i @d34dman/sutram
    • composer require drupal/sutram
    <script type="module">
      import Sutram from
        "https://cdn.jsdelivr.net/npm/@d34dman/sutram@0.8/dist/sutram.js";
    
      Sutram.register({
        name: "hello world",
        provider: "hello",
        description: "Say hello",
        input: {
          type: "object",
          properties: { who: { type: "string", default: "you" } },
        },
        positional: ["who"],
        annotations: { readOnly: true },
        run: ({ who }) => ({ text: `Hello, ${who}.` }),
      });
      Sutram.mountConsole();
    </script>