---
title: Remote access
project: Total.js V5
version: 0.0.20
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/total-js-v5/0-0-20/reference/remote-access/
updated: 2026-12-02T17:12:15.769Z
---

# Remote access

> require('total5/remote'): the client of the Code Editor, the MCP proxy and the tools App_* for AI agents.

The module `total5/remote` with the client of the Total.js Code Editor, the client and the server of the MCP proxy, and the tools `App_*`. The guide [Remote access](../../guides/remote-access/) explains how to connect a project and how to protect the proxy. The start options `edit` and `editmcp` are in [Application structure and modes](../../reference/application-structure/), the requests of the editor in [Command line](../../reference/command-line/).

## API

### require('total5/remote')

Type: `method`

The module of the remote access.

Returns: `Object` The module.

The module exports `edit()`, `mcp()`, `proxy()` and `tools()`. Loading it registers nothing.

Example: Require
```js
const Remote = require('total5/remote');
```

### Remote.edit(url, [directory])

Type: `method`

Connects a folder to the Total.js Code Editor.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | yes |  | The URL from the editor, for example `https://code.example.com/?id=project` (`http` is changed to `ws`). |
| `directory` | `String` | no | `F.directory` | The folder to edit. |

Opens a WebSocket to `url` in the current process and answers the requests of the editor (see Code Editor requests) on the files of `directory`. The client pings the editor every 30 seconds and connects again every 10 seconds when the connection is lost. `404 project not found` and `409 project is already open` are printed when the editor refuses the project. `F.remote(url, [directory])` is the same function. The start option `edit` calls it in the watcher process.

Example: Connect
```js
const Remote = require('total5/remote');
Remote.edit('https://code.example.com/?id=shop');
```

### F.remote(url, [directory])

Type: `method`

Connects the folder of the application to the Total.js Code Editor.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | yes |  | The URL from the editor, `wss://...?id=project`. |
| `directory` | `String` | no | `F.directory` | The folder to edit. |

Returns: `undefined`

The same as `Remote.edit()`: starts the remote editing client in the current process, a WebSocket connection to `url` that lets the editor browse and change the files in `directory`. It reconnects every 10 seconds when the connection is lost. The `edit` start option does the same in the watcher process.

Example: Connect
```js
F.remote('wss://code.example.com/?id=myproject');
```

### Remote.mcp(url)

Type: `method`

Connects the application to an MCP proxy.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `url` | `String` | yes |  | The WebSocket route of the proxy with the id of the project (`http` is changed to `ws`). |

Registers the tools `App_*` and opens a WebSocket to the proxy. The proxy sends the calls of the AI agent, and the tools run in the current process on the files of `F.directory`, as the user `{ id: 'ai', name: 'AI', sa: true }`. Only the tools `App_*` can be called through this connection, not the other actions. The client connects again every 10 seconds when the connection is lost. The start option `editmcp` calls it in the watcher process.

Example: Connect
```js
const Remote = require('total5/remote');
Remote.mcp('https://proxy.example.com/$mcp/?id=shop');
```

### Remote.proxy(socket)

Type: `method`

Turns a WebSocket route into an MCP proxy.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `socket` | `WebSocket` | yes |  | The `$` of the WebSocket route. |

Call it in the action of a `SOCKET` route. It registers the tools `App_*` as MCP tools and forwards each call to the connected project whose `?id=` is the same as the `?id=` of the MCP endpoint. Without such a project the tools answer `App is offline.`; the calls that wait when a project disconnects end with `Timeout`. The proxy needs `$mcp : true`. It does not check who connects: protect the endpoint with `Total.mcp.auth` and check a token of the projects in the event `open` of the socket. Each connected and disconnected project is printed to the console.

Example: The proxy
```js
// config: $mcp : true
const Remote = require('total5/remote');

ROUTE('SOCKET /$mcp/ 10MB', function($) {

	$.on('open', function(client) {
		if (client.query.token !== CONF.remote_token)
			client.close(4001);
	});

	Remote.proxy($);
});

Total.mcp.auth = function($) {
	if ($.token && $.token === CONF.mcp_token)
		$.success({ id: 'agent', name: 'Agent' });
	else
		$.invalid();
};
```

### Remote.tools()

Type: `method`

Registers the actions App_* only.

Registers the actions once, without a connection. They are normal actions without `mcp: true`, so they are not in the list of the MCP server until you set it.

Example: Two tools in your own MCP server
```js
require('total5/remote').tools();

F.actions.App_read.mcp = true;
F.actions.App_search.mcp = true;
Total.mcp.refresh();
```

### App_*

Type: `type`

The tools for AI agents.

| Tool | What it does |
| --- | --- |
| `App_info` | The name of the application, the versions and the platform |
| `App_tree` | The list of files and folders, without `.git`, `tmp`, the file storages and the start script |
| `App_read` | The content and the current revision of one or more files |
| `App_write` | Creates or replaces a file and saves its content as a new revision |
| `App_restore` | Returns the content of a saved revision; write it with `App_write` to use it |
| `App_move`, `App_delete` | Moves or deletes a file or a folder with its revisions (the root cannot be deleted) |
| `App_mkdir` | Creates a folder |
| `App_search` | Finds a text in the `.js`, `.html`, `.htm`, `.css`, `.md` and `.txt` files, at most about 100 matches |
| `App_logs` | The last 4 kB of `logs/debug.log` (see `$logger` in [Configuration](../../reference/configuration/)) |
| `App_shell` | Runs a shell command in the folder of the application |
| `App_restart` | Restarts the application |

The arguments go in `input`. Paths are relative to the root of the application, with or without the first slash. The tools report a problem with a file in the field `error` of their output.

| Tool | Input | Output |
| --- | --- | --- |
| `App_info` | | `name`, `version`, `hostname`, `framework`, `node`, `platform`, `documentation` |
| `App_tree` | | `items: [{ path, type, size, modified }]`, `type` is `file` or `directory` |
| `App_read` | `paths` | `items: [{ path, error, content, revision }]` |
| `App_write` | `path`, `content` | `path`, `revision`, `created` |
| `App_restore` | `path`, `revision` | `content`, `error` |
| `App_move` | `from`, `to` | `from`, `to`, `error`, `moved` |
| `App_delete` | `path` | `path`, `error`, `deleted` |
| `App_mkdir` | `path` | `path`, `error`, `created` |
| `App_search` | `search` | `items: [{ path, line, ch, text }]`, `truncated` |
| `App_logs` | | `output`, `truncated` |
| `App_shell` | `cmd` | `response`, `error` |
| `App_restart` | | `success` |

`App_write` saves each content as `revisions/<hash>_<number>.rev`; the numbers of the revisions are in `databases/memorize_revisions.json`.

Example: A call
```json
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "App_read", "arguments": { "input": { "paths": ["/controllers/api.js"] } } } }
```
