# legato mcp

## Run the server

```bash
/Applications/Legato.app/Contents/Helpers/legato mcp
```

This runs Legato's MCP server over stdio for an agent. It reads protocol requests on stdin and writes its responses on stdout, one JSON message to a line, until stdin closes. Then it exits with status 0. See [Connect an agent](https://legatobar.com/docs/connect-agent.md) to set up a client, and [MCP tools](https://legatobar.com/docs/mcp-tools.md) for the tools and their errors.

## Protocol example

A client normally starts this process and talks to it. To check from a shell that the server answers, send it one ping:

```bash
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"ping"}' | /Applications/Legato.app/Contents/Helpers/legato mcp
```

The server prints one line of JSON with `"jsonrpc":"2.0"`, `"id":1` and an empty `result`. The order of the three can vary. It then exits with status 0, because stdin has closed.

A protocol error is a JSON-RPC error response. The server keeps running after one, and still exits with status 0. A line that isn't JSON gets the error code `-32700`.
