Spanish Total.js
English
Documentation For AI agents
Contents

Connect an AI to your flow

LessCode speaks MCP, the protocol that AI clients use to work with apps. Claude, Cursor or any MCP client can read your flow, change it, run its nodes and write components for you.

.md GitHub
On this page

The address and the token

Choose AI → Connect an AI… A window shows the address, the token and the configuration of each client, ready to copy.

WhatValue
MCP endpointhttp://127.0.0.1:7230/$mcp/
Code modehttp://127.0.0.1:7230/$mcp/client.js
AuthenticationAuthorization: Bearer <token>

The port is 7230, or the next one that is free up to 7239.

The token is made the first time, and is kept in the keychain of your system. Without it, the MCP endpoint answers 401. Show lets you see it, and Copy copies it whole.

LessCode must be open for the AI to reach it.

Claude Code

Press Copy the command and run it in your terminal:

claude mcp add --scope user --transport http lesscode 'http://127.0.0.1:7230/$mcp/' --header 'Authorization: Bearer <token>'

Keep the single quotes: without them, the terminal takes $mcp for a variable and drops it. --scope user makes it available in all your projects.

Cursor and other clients

For the clients that connect by an address, in their mcp.json:

{
  "mcpServers": {
    "lesscode": {
      "url": "http://127.0.0.1:7230/$mcp/",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}

Claude Desktop

Claude Desktop starts its servers with a command, so it reaches LessCode through mcp-remote, which needs Node.js on your computer. In claude_desktop_config.json:

{
  "mcpServers": {
    "lesscode": {
      "command": "npx",
      "args": ["-y", "mcp-remote@0.16.5", "http://127.0.0.1:7230/$mcp/", "--allow-http", "--header", "Authorization:${LESSCODE_TOKEN}"],
      "env": { "LESSCODE_TOKEN": "Bearer <token>" }
    }
  }
}

What the AI can do

ToolWhat it does
Flow_readGives the whole design: the nodes with their settings, connections and positions, the variables, the ids of the components, and whether the flow is paused
Flow_saveReplaces the design and runs it, as APPLY does. The nodes that are left out are removed
Flow_componentsDescribes the components: id, name, inputs, outputs and settings
Component_readGives the code of a component
Component_saveAdds a component, or replaces its code
Component_removeRemoves a component. The nodes that use it stop working
Flow_triggerRuns a node, as its Run button does
Flow_statusGives the counters of the flow, its last errors and how each node is doing
Flow_pausePauses the flow, or lets it go on
LessCode does not ask you before any of them runs. The components that the AI writes are code that runs on your computer, with your permissions. Connect only clients that you trust, let them ask you before they use a tool, and make a copy of your flow first.

Code mode

In place of calling the tools one by one, an agent can download a JavaScript client with a function for each tool, write a script with them, and give the model only the result. It takes fewer tokens.

curl -H 'Authorization: Bearer <token>' 'http://127.0.0.1:7230/$mcp/client.js' -o lesscode.js

This script, for Node.js 18 or later, moves all the nodes to the right:

const api = require('./lesscode.js')('<token>');

(async function() {
    const flow = await api.Flow_read({});
    for (const key in flow.design) {
        if (flow.design[key].component)
            flow.design[key].x += 40;
    }
    await api.Flow_save({ input: { design: flow.design } });
})();

Change the token

If the token reaches someone who should not have it, press Make a new token… in the same window. LessCode saves the flow and starts again, and you give the new token to each of your clients. The old one no longer works.

Made in Europe