# tw-legal-rag [Health: Active]

**Category:** ⚖️ Legal  
**Repository:** https://github.com/aa0101181514/tw-legal-rag  
**GitHub Stars:** 359  
**Views:** 1  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/tw-legal-rag

## Description
Citation-guarded retrieval over 22M Taiwan court judgments and administrative interpretations

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "tw-legal-rag": {
    "command": "uvx",
    "args": ["twlegalrag"]
  }
}
```

## Documentation

## What tw-legal-rag does

tw-legal-rag provides MCP access to Dr.Legal's Taiwan legal retrieval backend and also ships as the `twlegalrag` command-line client. The service covers 22,846,886 Taiwan court judgments, administrative interpretations, constitutional court decisions, labor-board rulings, legal provisions, and supporting case-history data, with statistics dated 2026-11-21.

Its six MCP tools cover judgment search, judgment full text and appellate relationships, citation-guarded bundles, current article lookup, administrative-interpretation number lookup, and semantic administrative-interpretation search. Judgment retrieval supports natural-language semantic search, lexical matching, exact case-number lookup, court filters, case-type filters, and date ranges. Queries can also name a court such as the Supreme Court or Supreme Administrative Court.

## How it works

The hosted endpoint is available at `https://tlr.dr-legal.com.tw/mcp` using Streamable HTTP and OAuth authorization. On first connection, users sign in to a Dr.Legal account with Google or email; an API key is not required.

The CLI calls the public TLR retrieval endpoint rather than embedding a local judgment database, model, vector index, or retrieval pipeline. `search` returns structured results and can include readable material. `pack` creates a bundle containing query data, citation identifiers, URLs, document identifiers, excerpts, case history, an `allowed_citations` list, and instructions for a downstream AI system. The bundle is designed for use with an AI tool selected by the user; the CLI itself neither calls an LLM nor generates legal advice.

Case-history data can show related appellate decisions and flags indicating whether a judgment was vacated or dismissed. Administrative interpretations remain separate from court judgments and include effect-status information such as verified validity, repeal, suspension, or replacement. Current statutory articles are retrieved by law name and article number, with common abbreviations resolved to official names.

The CLI's `check` command performs a bundle-level, best-effort string check. It can identify cited case numbers outside the bundle and check whether a quoted sentence appears somewhere in the bundled text. A passing result confirms only that the citation or text matches the bundle; it does not establish that the quotation belongs to the cited judgment, that a court's reasoning was understood correctly, or that a paraphrase is accurate.

## Setup and configuration

Install the CLI with:

```bash
pip install twlegalrag
```

Its listed dependencies are `httpx`, `typer`, and `rich`; no LLM package or LLM key is needed. Configure the TLR connection key before using the CLI. For MCP clients, add the hosted endpoint as a custom connector or remote MCP server and complete the Dr.Legal login flow.

Typical CLI commands include:

```bash
twlegalrag search "勞資 加班費" -n 5 --read
twlegalrag pack "車禍對方全責,我可以求償什麼?" -o bundle.json
twlegalrag check bundle.json answer.txt
twlegalrag law 民法 184
twlegalrag ref-search "扣繳義務人未依限申報之處罰" -n 5
twlegalrag health
```

## Tools and capabilities

- Search court judgments with semantic, lexical, or exact-number retrieval.
- Retrieve judgment text, citation links, and appellate-chain metadata.
- Build bundles with citation allowlists and downstream verification instructions.
- Look up current statutory text by law name and article number.
- Find administrative interpretations by reference number or semantic query.
- Check AI answers against the contents of a retrieved bundle.

## Limitations and notes

Judgments are synchronized incrementally from public Judicial Yuan data, so very recent decisions may lag the official website. Current-law lookup provides present consolidated provisions; historical wording from before an amendment requires an official legislative-history source.

Citation checking operates only on the saved bundle, not the complete Dr.Legal database. It cannot determine whether a passage expresses the court's holding, was merely a party's argument, or was assigned to the correct judgment. The retrieval service and its private indexes remain server-side, and the tool does not provide legal advice or validate downstream model conclusions.

_Full upstream README: https://allmcps.com/mcp/tw-legal-rag/readme_

