Skip to main content
Glama

RF Codes: Semantic Search

Search 24 codes of the Russian Federation using ordinary words. Ask "what happens if I don't pay child support" and get Article 115 of the Family Code, even though those exact words never appear in it. It works without the internet, entirely on your machine: neither queries nor texts go anywhere.

You can search in two ways: from the terminal with a single command, or by connecting the repository to Claude Code as an MCP server — then the search is available right in the conversation.

What's inside

data/       тексты 24 кодексов, разобранные по статьям (9 250 статей, каждая — отдельный JSON)
index/      векторный индекс: по нему и идёт поиск
src/        сам поиск — MCP-сервер, команда для терминала и общий код под ними

The codes were exported on August 24, 2026 — the editions are current as of that date. The source is the official portal pravo.gov.ru, consolidated texts from the "Reference Bank of Legal Information". The revision date of each code can be seen separately with the --codes-list command (see below): codes change at different times, and some have a latest revision noticeably older than the export date.

Related MCP server: Legal MCP

Setup (once)

You need Python 3.11 or newer. No video card needed — everything is computed on the CPU.

# создать виртуальное окружение
python -m venv .venv

The easiest way is to ask Claude Code: /x-prepare-system. The skill will install the libraries, download the models, and check that everything works.

The same thing with one command if you don't have Claude Code handy:

# Windows
.\setup.cmd --install

# Linux и macOS
./setup --install

A search model (~2.3 GB) and a reranker model (~0.5 GB) will be downloaded. This is the only step that requires the internet. The models aren't included in the repository — they are too large for git.

You can check readiness at any time: the same command without --install doesn't change anything, it only tells you what is ready and what is missing.

# Windows
.\setup.cmd

# Linux и macOS
./setup

Try it in the terminal

The package includes a small wrapper — it fills in paths and encoding by itself:

# Windows
.\laws.cmd "что грозит за неуплату алиментов"

# Linux и macOS
./laws "что грозит за неуплату алиментов"

Answer looks like this:

=== что грозит за неуплату алиментов ===
1. sk-rf ст. 115 — Ответственность за несвоевременную уплату алиментов  [0.0164]
   РАЗДЕЛ V. АЛИМЕНТНЫЕ ОБЯЗАТЕЛЬСТВА > ГЛАВА 17. ПОРЯДОК УПЛАТЫ И ВЗЫСКАНИЯ | действует
   1. При образовании задолженности по вине лица, обязанного уплачивать алименты...

What else the command can do (on Linux and macOS write ./laws instead of .\laws.cmd):

# несколько вопросов за один запуск: так быстрее, модель грузится один раз
.\laws.cmd "увольнение по собственному желанию" "продолжительность отпуска"

# статья целиком, по номеру
.\laws.cmd --article uk-rf:105

# искать только в одном кодексе
.\laws.cmd --code=koap-rf "превышение скорости"

# список кодексов с датами редакций
.\laws.cmd --codes-list

# точнее на расплывчатых вопросах, но на 4 секунды медленнее
.\laws.cmd --rerank "сосед залил квартиру кто возмещает ущерб"

# показать и статьи, утратившие силу: по умолчанию они скрыты
.\laws.cmd --repealed "запрос"

The first query takes about 6 seconds — that's the time it takes to load the model. After that, if there are several queries in one command, each next one is computed in 0.2 seconds.

A tip on phrasing: ask the question the way you'd ask a person, not with keywords. And remember that the same word lives in different codes — "probation period" finds both the Labor Code and the Criminal Code's probation. If you know where to look, add --code=tk-rf.

If the wrapper doesn't suit you for some reason, the same thing as a full command:

# Windows, PowerShell
$env:PYTHONPATH="src"; $env:PYTHONIOENCODING="utf-8"
.venv\Scripts\python.exe -m laws_mcp.cli "вопрос"
# Linux и macOS
PYTHONPATH=src .venv/bin/python -m laws_mcp.cli "вопрос"

Connecting to Claude Code (MCP server)

If you use the search often, it's more convenient to start the server: the model stays in memory and each request takes milliseconds instead of six seconds.

The easiest way is to ask Claude Code: /x-run-mcp — the skill connects it and confirms.

Manually — in one line:

# Windows, PowerShell
claude mcp add laws -e PYTHONPATH=C:\путь\к\репозиторию\src -e LAWS_ROOT=C:\путь\к\репозиторию -e PYTHONIOENCODING=utf-8 -- C:\путь\к\репозиторию\.venv\Scripts\python.exe -m laws_mcp.server
# Linux и macOS
claude mcp add laws -e PYTHONPATH=/путь/к/репозиторию/src -e LAWS_ROOT=/путь/к/репозиторию -- /путь/к/репозиторию/.venv/bin/python -m laws_mcp.server

Paths must be absolute: Claude Code starts the server from its own directory, so relative paths won't be found. After connecting, restart the session — the list of tools is read at startup.

The server gives three tools: find articles by semantic, show an article by number, and list the codes.

What this search can't do

It's worth knowing in advance, so you don't rely on it unnecessarily:

  • Codes only. Separate federal laws (consumer protection, LLCs, enforcement proceedings, etc.), by-law documents, and resolutions by the Plenum of the Supreme Court are not here and can't be found.

  • The answer is correct only as of the export date. The law changes; the date is shown by --codes-list.

  • This is a search, not legal advice. It shows what's written in the code; conclusions and decisions remain with you.

  • By default, only current articles are found. Repealed ones — with the --repealed flag.

Deploy on a /r server or customize

Claude Code will help here: the repository is structured so that the agent can figure it out itself — CLAUDE.md explains the internal layout, and there's a Dockerfile for building an image with the search inside.

Ask for it in words, for example:

  • "deploy this search on my server in docker"

  • "spin up the MCP server and connect it to my Claude Code"

  • "make a web interface for this search"

  • "check that everything is ready to go" — it will run the check and explain what's missing

Out of the box there is an image that includes both the data and the models, so the container has no internet connection:

# собрать образ и запустить сервер
docker build -t laws-mcp .
docker run -i --rm laws-mcp

The -i flag in docker run is mandatory: the MCP server communicates through standard input and output, and without it the container will immediately exit. Run the setup before building the image — models are copied to the image from the models/ directory.

A
license - permissive license
Not graded
quality - not tested
Not graded
maintenance - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    RAG-powered document search server that enables semantic search across large collections of legal and business documents (PDF, Word, Excel, PowerPoint) using local embeddings with no API costs.
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables local semantic code search across repositories using natural language, with AST-aware chunking and hybrid vector/FTS5 retrieval.

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Totopolis/laws'

If you have feedback or need assistance with the MCP directory API, please join our Discord server