Know what US law actually says

Free API and MCP server for looking up real municipal, state, and federal legal codes. No signup. No API key. 37,000+ jurisdictions.

The problem

AI agents regularly make claims about the law. "You can't park there overnight." "Your landlord must give 60 days notice." These claims are often wrong, and users have no way to check. Open Legal Codes gives agents access to the actual text of the law, so they can cite real statutes with permalink URLs that users can verify themselves.

How it works

  1. User asks: "Can I have a dog in Mountain View?"
  2. Agent searches: search_code("ca-mountain-view", "dog")
  3. Agent reads the actual section with get_code_text
  4. Agent answers based on real law text, with a link to the statute
  5. User clicks the link to verify — no trust required

Get started

Install

# npm npm install -g open-legal-codes # Homebrew (macOS / Linux) brew install tidyapp/tap/open-legal-codes # No install needed — just use npx or curl npx open-legal-codes search --jurisdiction wa-seattle --query "landlord" curl 'https://openlegalcodes.org/api/v1/lookup?city=Seattle&state=WA'

MCP server (for AI agents)

Add to Claude Desktop, Claude Code, or any MCP client:

{ "mcpServers": { "legal-codes": { "url": "https://openlegalcodes.org/mcp" } } }

REST API

GET /api/v1/jurisdictions?state=CA # List jurisdictions GET /api/v1/jurisdictions/:id/toc # Table of contents GET /api/v1/jurisdictions/:id/code/:path # Section text + permalink GET /api/v1/jurisdictions/:id/search?q=dog # Keyword search GET /api/v1/jurisdictions/:id/caselaw/:path # Citing court opinions GET /api/v1/lookup?city=Miami&state=FL # Find by city name

Full API docs, CLI, and MCP tool reference →

Case law citations

For every statute, we show court opinions that have cited it — most recent first. This is powered by CourtListener, a free legal database from the Free Law Project. We link directly to their records — we do not host or reproduce case law.

Citations are matched automatically using standard citation formats and are likely imperfect. Some relevant opinions will be missed, and some results may be tangential. Currently supported for federal and state statutes. Nothing here constitutes legal advice.

Coverage

37,000+ jurisdictions across five publishers: Municode, American Legal, eCode360, eCFR (federal regulations), and California Leginfo. Content is fetched on first request and cached — subsequent lookups are instant. See the full directory or coverage map.

Roadmap

Two things matter most right now:

  1. Coverage. We're focused on making sure the law is actually available — more jurisdictions, more publishers, better reliability. This is the primary goal today.
  2. Change monitoring. If you're building compliance software (real estate, construction, permits), you need to know when local laws change — not just what they say today. We want to add automatic change detection so you can alert your users when a relevant ordinance is updated. This is important and on our list, but not yet built.

About

Legal codes are public domain — the Supreme Court confirmed this in Georgia v. Public.Resource.Org (2020). Publishers host them but don't make them easy for agents to access. Open Legal Codes is offered free of charge by TIDY, an AI property management company that needed this and decided to open it up.

We believe the law should be machine-readable for everyone. If an AI agent can answer a legal question, it should be able to show its work — and every person should be able to verify the actual text of the laws that govern them.