Skip to main content
Glama
README.md
# landlordlaw

What does the law ask of a landlord in England, at one address? landlordlaw is a small local forwarding client for the hosted Lettance MCP service: it serves the tool list from your own machine using the captured definitions, then sends each question upstream and hands the service's answer back exactly as it arrived.

Everything on the surface is read-only and works from published data. Given a postcode it reports whether a council property licence is needed and which schemes apply, when the landlord register window opens, and what the coming year of duties looks like as a dated plan. A cited catalogue of rules can be searched and read in full, two to four addresses can be set side by side, and typical local rents and sale prices come from dated ONS and HM Land Registry snapshots. landlordlaw stores nothing and computes nothing itself — it asks, and passes the answer through.

## The tools

- **`check_address`** — What applies to a rented home at one postcode: whether a council property licence is needed for the household type, the council's licensing schemes, the planned landlord register window, flood zone and conservation area, each with its source. `postcode` is required; `household` (`single`, `small_hmo` or `large_hmo`) is optional.
- **`search_rules`** — Search the catalogue of landlord rules, each cited to legislation.gov.uk or GOV.UK, by keyword. `query` is required. Returns matching rule ids with summaries.
- **`get_rule`** — One rule's full detail: the requirement, deadline, evidence to keep, penalty, legal basis and official guidance links. `id` is required, taken from a `search_rules` result.
- **`council_licensing`** — Every licensing scheme for one council, with its wards, dates, fees and council sources. `council` is required — a slug such as `southwark` or a name such as `Birmingham`.
- **`plan_rental`** — A twelve-month plan of duties for a rented home, computed from the postcode plus whatever the landlord knows about the tenancy: gas and electrical dates, the EPC rating, deposit handling, alarms and more. Only `postcode` is required; every other argument sharpens the plan. Nothing is stored and nothing is submitted.
- **`compare_addresses`** — Two to four postcodes compared side by side: licence need, landlord register window, flood zone, conservation areas, Article 4 directions, average local rent and median sale price. `postcodes` (2–4 entries) is required; `household` is optional.
- **`area_market`** — The ONS average monthly private rent for the local authority and the HM Land Registry median sale price for the postcode district, from a dated snapshot with its attribution. `postcode` is required. Area figures only, never a valuation of one home.

## Install and run

As an MCP server via npm:

```bash
npx -y @reneturcios/landlordlaw mcp
```

MCP client configuration:

```json
{
  "mcpServers": {
    "landlordlaw": {
      "command": "npx",
      "args": ["-y", "@reneturcios/landlordlaw", "mcp"]
    }
  }
}
```

As a container:

```bash
docker run -i ghcr.io/cloudcorprecords/landlordlaw
docker run --rm ghcr.io/cloudcorprecords/landlordlaw area_market '{"postcode":"SE15 5BA"}'
```

## CLI

A single binary covers both the command line and the MCP server. Every tool is a subcommand whose one argument is a JSON string of that tool's inputs:

```bash
landlordlaw check_address '{"postcode":"SE15 5BA"}'
landlordlaw search_rules '{"query":"gas safety certificate"}'
landlordlaw get_rule '{"id":"gas-safety-annual-check"}'
landlordlaw council_licensing '{"council":"southwark"}'
landlordlaw plan_rental '{"postcode":"SW9 7AA","has_gas":"yes"}'
landlordlaw compare_addresses '{"postcodes":["SE15 5BA","SW6 1HS"]}'
landlordlaw area_market '{"postcode":"SE15 5BA"}'
landlordlaw --version
```

Exit codes: `0` for a successful forwarded call, `1` when the result that comes back is an error, and `2` for usage mistakes like an unknown subcommand or a JSON argument that does not parse.

## Configuration

- `LETTANCE_MCP_URL` — Replaces the upstream endpoint. Defaults to the pinned hosted endpoint, `https://lettance.com/mcp`. (This override variable is a reconstruction introduced by this rebuild.)

The Lettance registry record lists no headers for its remote, so landlordlaw never attaches an authentication header — every question goes upstream keyless.

When the upstream cannot answer — it returns a JSON-RPC error, answers with a non-2xx status, sends a body that cannot be read, or the request itself fails — the caller receives an error result whose text begins with `landlordlaw error:`.

## How forwarding works

The first question of a process opens a session against the upstream: an `initialize` request (protocol version `2025-03-26`), a `notifications/initialized` notification, and then the `tools/call`. If the service issues an `Mcp-Session-Id` header during initialize, landlordlaw repeats it on subsequent requests and keeps reusing that one session until the process ends. Replies are understood in both plain JSON and server-sent-events framing. Successful results are passed through untouched, `isError` flag and any extra fields included.

## Development

```bash
npm install
npm run build   # tsc -> dist/ (dist/cli.js is the bin)
npm test        # tsx --test test/*.test.ts — stubbed upstream, no network
npm run dev     # run the CLI from source
```

The suite compares the served tool list against the captured surface tool for tool, walks the session handshake and its reuse, proves no `Authorization` header is sent under any environment, and confirms that arguments travel upstream unchanged and results return unchanged.

## License

MIT — see `LICENSE`. Copyright (c) 2026 Rene Turcios.