---
title: Connect an AI to your flow
project: LessCode app
version: Latest
section: guides
language: en
license: 
url: https://totaljs.es/docs/lesscode-app/latest/guides/connect-an-ai/
updated: 2026-12-02T15:40:00.797Z
---

# Connect an AI to your flow

> LessCode speaks [MCP](https://modelcontextprotocol.io), 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.

## 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.

| What | Value |
| --- | --- |
| MCP endpoint | `http://127.0.0.1:7230/$mcp/` |
| Code mode | `http://127.0.0.1:7230/$mcp/client.js` |
| Authentication | `Authorization: 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:

```bash
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`:

```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`:

```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

| Tool | What it does |
| --- | --- |
| `Flow_read` | Gives 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_save` | Replaces the design and runs it, as **APPLY** does. The nodes that are left out are removed |
| `Flow_components` | Describes the components: id, name, inputs, outputs and settings |
| `Component_read` | Gives the code of a component |
| `Component_save` | Adds a component, or replaces its code |
| `Component_remove` | Removes a component. The nodes that use it stop working |
| `Flow_trigger` | Runs a node, as its **Run** button does |
| `Flow_status` | Gives the counters of the flow, its last errors and how each node is doing |
| `Flow_pause` | Pauses 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](/lesscode-app/latest/guides/your-flows/) 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.

```bash
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:

```js
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.
