Using Actus with AI assistants

View source

Run actus mcp so that an assistant that speaks the Model Context Protocol can ask the compiler about your project, with four read-only tools.

An AI assistant that writes Actus code does better when it can ask the compiler instead of guessing. actus mcp lets it do that. It runs the compiler as a server for the Model Context Protocol (opens in a new tab), a standard way for a program to offer tools to an assistant. The answers come from the same analysis as actus check and the language server, so they match the compiler that builds your project.

The server is part of the actus program. You install nothing else.

What the tools do

The server has four tools. All of them are read-only.

ToolWhat it answers
checkthe errors of the project, with their codes and fixes. The same data as actus check --format json.
explainwhat an error code means. The same text as actus explain.
binding_statethe bindings in view at a line: role, type, and state.
signaturewhat a verb takes and gives back: the role and type of each parameter, the return type and its documentation.

binding_state is the one that matters most for ownership. For each binding at a line it says its role (erg, abs, ins or dat), its type, its ownership state (active, partially_moved, moved or dropped) and its access state (mutable, frozen or suspended). When a binding has changed state, it names the event that did it, for example a dat argument of a call. The state is the state at the place you ask about, not at the end of the verb. A binding that a call hands over with dat is active on the line before the call and moved on the line of the call.

signature finds a verb by its name, alone or with the end of its module path: area, geometry::area or std::io::read_line. It searches the project and the modules that the project imports, the standard library among them.

check can also take unsaved text. An assistant that has a new version of a file in memory sends it with the call, and the server checks that text in place of the file on disk. Nothing is written.

What the server never does

  • It never writes. No tool writes a file, creates Actus.lock or runs a program. A missing Actus.lock is reported as the error E1800, as in actus check, and not created.
  • It stays in the project. The server reads only below the folder it was started in. A path that leaves that folder, also through .. or a link, is refused with an error that names the path.
  • It answers on standard output only. Standard output carries nothing but the protocol messages, one per line. Standard error stays empty.

A fix in the result of check has an applicability. Apply a safe fix without asking. Show a review fix to a person first, because it changes what the program does. Fixing and explaining errors explains the difference.

Configure it

Register actus mcp as a server that runs over standard input and output. The working directory must be your project folder. This is the usual shape. The file that it goes in, and the name of the key, depend on the assistant that you use, so look in its documentation:

json
{
  "mcpServers": {
    "actus": {
      "type": "stdio",
      "command": "actus",
      "args": ["mcp"],
      "cwd": "/path/to/the/project"
    }
  }
}

If the assistant has no setting for the working directory, start it from the project folder. The server takes no options. It speaks the protocol versions 2025-06-18, 2025-03-26 and 2024-11-05. It tells the assistant which edition of the language applies.

Try it by hand

You can talk to the server yourself. It reads one JSON message per line. In the shapes project of Projects and modules, send the start of a session and then ask for the signature of geometry::area:

bash
actus mcp
text
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"demo","version":"1"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"signature","arguments":{"name":"geometry::area"}}}

The answer to the third message has the structuredContent:

json
{
  "matches": [
    {
      "name": "area",
      "package": "shapes",
      "module": "geometry",
      "visibility": "open",
      "parameters": [
        { "name": "width", "role": "abs", "type": "Int" },
        { "name": "height", "role": "abs", "type": "Int" }
      ],
      "returns": "Int",
      "documentation": null,
      "source_path": "/home/you/shapes/src/geometry/rect.act",
      "line": 1,
      "column": 6
    }
  ]
}

The assistant now knows that area reads both arguments, so it calls area(width: abs width, height: abs height). It does not have to guess the roles. The answer has a few more fields that are left out here, such as external, contract and generic_parameters.

A result of a tool carries its answer twice: as structuredContent and as the same JSON text. A tool that cannot do what was asked, for example because a path is outside the project or a code is unknown, returns a normal result with isError set to true and a text that says what is wrong.

How long a call takes

Each call analyzes the whole project again. Nothing is kept between calls yet. So a call takes about as long as actus check on the same project. On a large project, expect that time for every call.

What you learned

  • actus mcp is a server for the Model Context Protocol, part of the compiler. It has four read-only tools: check, explain, binding_state and signature.
  • Register it as a server that runs over standard input and output, with your project folder as its working directory.
  • It never writes a file, never runs a program, and never reads outside the project.
  • Apply only safe fixes without asking.

Back to Tools.