Use Lispex with an AI Assistant

Connect a local MCP server, run a Lispex rule, and read its result and diagnostics.

Connect the local server

Install the Native executable from Downloads. Check its version in a terminal.

SH
lispex --version

The output identifies the exact installed version. Match it to the version of the downloaded file.

The command exits with status 0. Use an assistant that supports local MCP servers. MCP is the protocol the application uses to list and call tools.

Add this entry to the application's MCP configuration. The application starts lispex mcp serve and exchanges messages through standard input and output, also called stdio.

JSON
{
  "mcpServers": {
    "lispex": {
      "command": "lispex",
      "args": ["mcp", "serve"]
    }
  }
}

If the application cannot find lispex, replace command with the installed executable's absolute path. On Windows, a JSON path can use forward slashes, such as D:/Tools/lispex.exe. Use the path where you installed the executable.

Reconnect the server in the application. These four tools become available.

ToolWhat you can do
lispex_referenceLook up forms, procedures, source syntax, resource profiles, and execution methods
lispex_evalRun reviewed source and read its values, output, and diagnostics
lispex_diagnosticLook up a diagnostic code and its cause
lispex_compare_routesCompare results from a named set of runtime implementations

Run an approval rule

Ask the assistant to use the connected tools.

Check the Lispex if form. Write a rule that returns approve for input of at least 10 and review otherwise. Run it with input 12 and show the tool result.

The following JSON blocks are tool arguments, not terminal commands. First, call lispex_reference.

JSON
{
  "topic": "forms",
  "name": "if"
}

In the response, structuredContent.result.known is true. The entry gives the shape (if test consequent alternate). Both branches are required. Only #f counts as false.

Next, call lispex_eval with the complete program and input.

JSON
{
  "source": "(if (>= input 10) 'approve 'review)",
  "input": "12"
}

The source string contains the whole program, so no source file is needed. The input string contains one Lispex data value. The server makes that value available under the name input.

These fields are excerpted from the response's structuredContent.

JSON
{
  "status": "ok",
  "values": ["approve"],
  "stdout": "approve\n",
  "diagnostics": [],
  "warnings": [],
  "exit_status": 0
}

The rule returned the symbol approve. The values array contains its printed representation. This tool also writes the top-level value to stdout; \n represents a newline. The evaluation succeeded with status 0, and the server stays connected for the next request. This call creates no output file.

Change the input argument to "9". The result becomes ["review"], with "review\n" in stdout and the same success status.

If a call returns diagnostics, look up its code with lispex_diagnostic. For example, {"code": "E302"} explains a wrong number of arguments. Correct the source and run it again. The MCP reference shows a full request and response excerpt.

Compare the built-in implementations

Call lispex_compare_routes with these arguments.

JSON
{
  "court": "tree-rust",
  "source": "(+ input 1)",
  "input": "41"
}

The court field selects the comparison. tree-rust runs the Lispex Interpreter and Lispex VM. The interpreter evaluates source forms; the virtual machine executes compiled instructions.

The response includes these fields in structuredContent.

JSON
{
  "court": "tree-rust",
  "status": "completed",
  "required_routes": ["tree", "rust-vm"],
  "agreement": true,
  "partial_comparison": false,
  "answer_selected": false
}

Both entries in observations contain ["42"] in semantic.values and "42\n" in semantic.stdout. agreement reports whether the compared results and resource observations match under the comparison rules.

The MCP reference explains the other court values in the tool schema.

Data, limits, and application permissions

Use these tools for source you have reviewed while writing a program. Each request accepts up to 65,536 bytes of source and 16,384 bytes of input. Evaluation allows 5 seconds and a 1 MiB result. The resource profile also defines comparison limits and explains failure results. Use the resource-controlled evaluator for application rules supplied by untrusted users.

The program computes from the supplied data using Lispex operations. The server returns the source hash, results, output, and diagnostics. It releases request data when the request ends. The assistant application applies its own data policy to text entered into it.

The calling application controls access to tools and any external action. For example, approve is the rule's answer; the application decides whether to act on it and which permissions that action needs. For a signed decision record, Lispex Vouch adds publisher authentication, request binding, and re-execution. The receiving application then applies its local acceptance rules.

When finished, disconnect the MCP server in the application. Closing its stdio connection ends the local process and releases request state.

MCP Tool Reference · Learning Path