AI Coding Agents

Let Claude Code, Codex, Cursor and other AI coding agents check and restart the services Kovra runs and read their logs, through the kovra command line and MCP.

AI coding agents write the code. Kovra runs it. After a change, the agent needs to know whether the service came up, which port it listens on, and what errors it printed.

The kovra command line reads these facts from the running Kovra app and hands them to the agent. It sees what the window shows, and it never guesses. The same is available as an MCP server.

Installing

  • Windows: the installer adds kovra to your user PATH. Open a new terminal, or restart the AI tool, and kovra runs directly.
  • macOS: the command line is not packaged yet.

In Kovra, Settings → AI tools shows where the command line is installed, whether it is on PATH, and whether the local API is running.

kovra is only a client. The Kovra app has to be open for its commands to answer.

Commands

Command What it does
kovra status The services of the current environment: status, ports, URLs
kovra projects (or kovra ls) All projects with their environments and worktrees
kovra start [service] [--wait] Start the environment or one service. With --wait, wait until ready
kovra stop [service] Stop the environment or one service, and return once they are down
kovra restart [service] [--wait] Restart the environment or one service. With --wait, wait until ready
kovra wait [service] Wait until the services are ready. A crash or the timeout is an error
kovra logs [service] The service’s log of its current run
kovra env [service] The service’s command, directory, port, URL and variables
kovra mcp Run as an MCP server (stdin/stdout)

Without a service, a command acts on the whole environment. logs and env look at one service: you can leave it out when the environment has only one, and with several the error lists them.

A service is repo/service, the service name, or the repo name.

Options of logs:

  • --errors: error lines only;
  • -n, --lines <n>: how many of the last lines, 1 to 5000, default 200;
  • --all-runs: include earlier runs; by default only the current run.

--timeout <seconds> sets the timeout of wait and start/restart --wait: 1 to 600 seconds, default 60.

Every command also takes:

  • --json: print JSON, for programs;
  • -p, --project <id or name>: the project (its main environment unless -e is given);
  • -e, --env <id or name>: the environment;
  • --cwd <dir>: find the environment from this directory.

kovra --help and kovra help <command> have the details.

How the environment is found

Without -p and -e, kovra finds the environment from the current directory: the environment whose worktree contains it. With nested worktrees, the deepest one wins. Hidden environments are not matched.

So kovra status in a worktree’s folder shows that worktree’s environment. When the current directory is in no environment, kovra says so and lists the projects.

Exit codes

Code Meaning
0 Success
1 Failure: a service crashed, a start was refused, or it is not running
2 Usage error, or a project, environment or service was not found
3 Kovra is not running
4 The wait timed out

Connecting AI coding tools

kovra mcp gives AI coding tools the same commands over MCP. Run the command for the tool you use.

Claude Code

claude mcp add --scope user kovra -- kovra mcp

Codex

codex mcp add kovra -- kovra mcp

Cursor: write this to ~/.cursor/mcp.json.

{ "mcpServers": { "kovra": { "command": "kovra", "args": ["mcp"] } } }

The tool then sees kovra_status, kovra_projects, kovra_start, kovra_stop, kovra_restart, kovra_wait, kovra_logs and kovra_env.

Instructions for agents

Put this into the repository’s AGENTS.md or CLAUDE.md so agents know Kovra runs the services. Settings → AI tools can copy it too.

## Dev services (Kovra)

This repository's dev services are run by Kovra: one set per git worktree, each on its own ports.

- Don't start dev servers yourself (`npm run dev`, `python manage.py runserver`, …). Kovra already runs them, and a second copy would collide on the ports.
- `kovra status`: the services of this worktree, with status, ports and URLs.
- `kovra restart <service> --wait`: apply your changes and wait until the service is ready.
- `kovra logs <service> --errors`: the error output of the current run.
- `kovra env <service>`: the command, port and environment variables it runs with.

Add `--json` for machine-readable output. Exit codes: 0 ok, 1 failed or crashed, 2 usage or not found, 3 Kovra is not running, 4 timed out.

Kovra never changes your repository by itself. You add this text yourself.

Safety

  • The local API listens on 127.0.0.1 only. Other machines can’t reach it.
  • Every request carries a token. Kovra makes a new one on every start, writes it to agent-api.json in the data folder (see Data Directory), and deletes the file when it exits.
  • It never ends outside processes. When another program holds a port, the start is refused, and the error names the process.
  • It never writes to your repository. The command line can only look at and start or stop the services Kovra manages, the same as the window.

Edit this page on GitHub ↗