lemma 0.9.4

A pure, declarative language for business rules.
---
nav_title: MCP
parent: Tools & SDKs
nav_order: 70
---

# MCP

Connect Claude, Gemini CLI, or Cursor to your Lemma specs over the [Model Context Protocol](https://modelcontextprotocol.io/). Ask an assistant to evaluate rules, explain results, inspect specs, and — when you allow it — draft or update specs in your workspace.

## Prerequisites

Install the Lemma CLI so `lemma` is on your `PATH`. See [Installation](../installation.md).

Point the server at a workspace directory (or a single `.lemma` file) with `--prefix`. That is the set of specs the assistant can see.

## Connect

All of these clients start Lemma as a local stdio MCP server. Replace `/path/to/workspace` with your project directory. Add `--admin` to the args only when the assistant should create, update, remove, or install registry dependencies (see [Read-only vs write](#read-only-vs-write)).

Shared shape:

```json
{
  "command": "lemma",
  "args": ["mcp", "--prefix", "/path/to/workspace"]
}
```

### Claude

**Claude Desktop** — Settings → Developer → Edit Config. Add a server under `mcpServers` in `claude_desktop_config.json`, then fully restart Claude Desktop:

```json
{
  "mcpServers": {
    "lemma": {
      "command": "lemma",
      "args": ["mcp", "--prefix", "/path/to/workspace"]
    }
  }
}
```

**Claude Code** — from a terminal:

```bash
claude mcp add --transport stdio lemma -- lemma mcp --prefix /path/to/workspace
```

### Gemini CLI

Add the same `mcpServers` entry to `~/.gemini/settings.json`, or to `.gemini/settings.json` in your project:

```json
{
  "mcpServers": {
    "lemma": {
      "command": "lemma",
      "args": ["mcp", "--prefix", "/path/to/workspace"]
    }
  }
}
```

Or:

```bash
gemini mcp add --transport stdio lemma lemma mcp --prefix /path/to/workspace
```

Restart Gemini CLI (or `/mcp reload`) and confirm the server is connected.

### Cursor

Cursor Settings → MCP, or a project `.cursor/mcp.json` / user MCP config. Add:

```json
{
  "mcpServers": {
    "lemma": {
      "command": "lemma",
      "args": ["mcp", "--prefix", "/path/to/workspace"]
    }
  }
}
```

Enable the server in Cursor’s MCP UI if it is listed but off.

## What you can do

Once connected, ask the assistant in natural language, for example:

- Evaluate a spec with given inputs and explain how a result was reached
- List specs in the workspace or show what data and rules a page defines
- Check whether draft Lemma source is valid before you keep it
- Install a registry dependency into the workspace (needs write access)

The server already ships authoring and evaluate guidance for the model. For learning the language yourself, see [Learn](../learn/readme.md) and [LLMs.txt](../llms.md).

## Read-only vs write

By default the server is read-only: evaluate and inspect, no changes to the engine or disk.

Pass `--admin` when you want the assistant to load or replace specs, remove them, clear the workspace load, or `install` (download into `lemma_deps/` and load). Only enable that for workspaces and agents you trust.

## How to work

1. Install the CLI and set `--prefix` to your specs directory.
2. Connect Claude, Gemini CLI, or Cursor as above (restart the client after config changes).
3. Ask questions against your specs; ask for explanations when you care how a rule fired.
4. For drafting new specs, enable `--admin` and ask the assistant to validate, then update the workspace when you are ready.

## See also

- [Lemma CLI]../reference/cli.md`lemma mcp` flags
- [Learn]../learn/readme.md — language guide
- [LLMs.txt]../llms.md — authoring Lemma from business logic
- [Installation]../installation.md