Taiwan Legal RAG: an MCP retrieval server for 22.58 million Taiwan court judgments
台灣法律 MCP 伺服器 + CLI(免費、免註冊、免 API key):2,250 萬筆裁判書、行政函釋、憲法法庭裁判,附引用查核。Free Taiwan legal MCP server for Claude/ChatGPT/Codex — bring your own LLM, retrieval-only.
At a glance
- What is it?
- The project ships a hosted MCP endpoint plus a pip-installable CLI that retrieves Taiwan judgments, statute text and administrative interpretations, then hands them to your own model. Its citation check is a bundle-level string test, not a correctness check.
- Who is it for?
- Adopt it if you already run an LLM client that speaks MCP and your question is Taiwan case law retrieval, not legal advice. Skip it if you need pre-amendment statute text or a guarantee that a quoted passage comes from the judgment it is attributed to; the check cannot see that.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 3 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The gap this fills: retrieval and citation discipline for Taiwan judgments
Taiwan judgments are public, but they are published as text on court sites with keyword search. A lawyer asking a model about overtime pay under the Labor Standards Act gets an answer that reads fluently and cites a case number that looks real. The failure mode the README names is specific: the case number exists, the holding is invented. Taiwan Legal RAG attacks that by separating retrieval from generation. The CLI calls a hosted retrieval service, packages the results into a JSON bundle with a whitelist of citations it actually read, and leaves generation to whatever model you already use. It does not call an LLM, does not produce legal opinions, and does not endorse model output. The intended users are practitioners and researchers who already have a model in the loop and want the retrieval half to be inspectable. The hosted MCP endpoint at https://tlr.dr-legal.com.tw/mcp is aimed at people who want the same retrieval inside Claude, ChatGPT, Gemini CLI, Microsoft 365 Copilot, Codex or Cursor without installing anything.
What sits behind the endpoint: 22,578,975 judgments and the shape of the corpus
The README gives corpus counts dated 2026-09-08, taken from the production database rather than estimated. The judgment total is 22,578,975, broken down by court level: 16,686,132 from district courts, 3,268,493 from district court summary divisions, 1,328,658 from high courts and their branches, 399,288 from the Supreme Court, 200,600 from high administrative courts, 122,964 from the Supreme Administrative Court, 78,891 from local administrative litigation divisions, 23,678 from the Intellectual Property and Commercial Court, 22,113 from the Kaohsiung Juvenile and Family Court, 32,250 from other specialized courts and committees, and 415,908 records that carry no court code field and are counted in the total without a level. By case category the split is 14,232,700 civil, 7,332,300 criminal, 573,417 administrative and 24,650 other. Around the judgments sit 4,540,466 appeal-chain links, 69,483 interpretation-validity records tracking repeal, suspension or supersession, 870 constitutional interpretations and constitutional court judgments, 1,017 statutes with 44,372 articles, 7,249 regulatory commands with 128,675 articles, 88,392 administrative rules from 90 agencies, and 3,523 repealed statutes. The interesting part is not the size. It is that administrative rules and judgments are kept in separate retrieval paths and the documentation states they must not be mixed or cited as court holdings.
How retrieval, packaging and the citation check actually work
The data flow has three stages. First, retrieval: a natural-language query hits the hosted TLR service, which does semantic search over the vectorized corpus, with a lexical mode for proper nouns and an exact case-number lookup that switches automatically when the query contains a full citation. If the exact lookup finds nothing, the documentation says the tool states plainly that absence does not mean the judgment does not exist, rather than substituting a semantically similar result. Second, packaging: `twlegalrag pack` writes a bundle containing the query, a `citation_id` per judgment (J1, J2 and so on), `citation_text`, `citation_url`, `doc_id`, a Layer-1 listing, a `fulltext_excerpt` of the reasoning with a length cap, `case_history` with the appeal chain and a reversed or dismissed flag, an `allowed_citations` whitelist limited to judgments whose full reasoning text was actually read, `unread_candidates` markers, and a `verification_instructions` block telling the downstream model to cite only bundle contents and mark unsupported propositions as unverified. A notice is also printed to stderr. Third, checking: `twlegalrag check bundle.json answer.txt` is described as a best-effort, bundle-level string check. It verifies whether cited case numbers appear in the bundle, whether the answer cites anything outside it, and whether a passage the answer attributes to a court appears somewhere in the bundle text. The README is unusually direct about the limits: the check cannot tell whether a quotation comes from the specific judgment the answer names, whether the court's holding was read correctly, whether a party's argument was mistaken for the court's view, whether an incidental remark was treated as controlling, or whether a paraphrase invented a holding. A pass means the cited case numbers match the bundle, nothing more.
Getting it running: pip, one MCP URL, and the commands that matter
Installation is `pip install twlegalrag`. The only dependencies listed are `httpx`, `typer` and `rich`; no LLM package and no API key are required. For MCP clients the setup is a single URL, `https://tlr.dr-legal.com.tw/mcp`, added to Claude, ChatGPT, Gemini CLI, Microsoft 365 Copilot, Codex or Cursor. The CLI flow starts with retrieval: `twlegalrag search "勞資 加班費" -n 5 --read` lists matching judgments. The main path is `twlegalrag pack "車禍對方全責,我可以求償什麼?" -o bundle.json`, after which you paste the bundle into a model and instruct it to cite only bundle judgments. Verification is `twlegalrag check bundle.json answer.txt`. Version 2.3.0 added statute and interpretation lookup to the CLI: `twlegalrag law 民法 184` returns current article text with the statute's last amendment date and repeal notes, and common abbreviations such as 勞基法, 刑法 and 憲法 resolve to official statute names. `twlegalrag ref "台財稅第881945861號"` looks up an interpretation by number and reports its validity state (verified valid, unverified, repealed, suspended or superseded), while `twlegalrag ref-search "扣繳義務人未依限申報之處罰" -n 5` does semantic search over interpretations. `twlegalrag health` checks the service. Note that the CLI does not bundle a judgment database; every query reaches the hosted endpoint, so it is useless offline.
The limitation that matters: a pass is not a correct reading
The citation check is the feature most likely to be misread, and the README pre-empts that. Because existence checking only asks whether a quoted sentence appears anywhere in the bundle, an answer can quote a passage accurately, attribute it to the wrong judgment in the same bundle, and still pass. Party arguments and court reasoning sit in the same excerpt, so an answer that presents a plaintiff's claim as the court's holding will not be caught. Paraphrased holdings are outside the check entirely. The check also only compares against the bundle as originally packed; if you later open a full judgment yourself and rewrite the answer, the check still sees only the original excerpt. There is a second boundary: the `law` command returns only the currently consolidated statute text, so behavior-time law, the pre-amendment version in force when the facts occurred, must be looked up in official legislative history. Third, the corpus lags. Judgments sync daily from Judicial Yuan public data, which itself releases with a delay of several days, and the README says very recent decisions should be checked against the official site. Fourth, the hosted endpoint is the whole product: the CLI does not expose model weights, vector indexes or retrieval pipeline internals, so a change to the service changes your results with nothing to inspect locally.
Where it sits against a Judicial Yuan site wrapper
The comparison the README draws is with tools that proxy the official Judicial Yuan or statute site search in real time. The difference is architectural, not cosmetic. A wrapper inherits the official site's keyword search, so a query phrased differently from the judgment's wording may miss. Taiwan Legal RAG runs semantic retrieval over its own 22.58 million-record corpus, which is what makes concept-level search possible, and it attaches `case_history` with the reversed or dismissed flag so you can see before citing whether a judgment was overturned upstream. A wrapper gives you immediacy and a direct official source; it typically offers no citation guard, and the README notes such tools are exposed to official site WAF changes and sometimes need a local browser to get around verification. The honest trade is stated in the table: for very recently announced judgments, the official site is more current. Neither approach generates advice, and the two can be used together. If your requirement is a citation trail back to the official publication, a wrapper is closer to that; if it is recall on a natural-language description of facts, the semantic index is the reason to pick this.
Maintenance, release cadence and the licence question
The release history is short and recent: v2.1.0 on 2026-08-20 added full reading of long judgments and hit-paragraph location, v2.2.0 on 2026-08-23 migrated endpoints to the Dr.Legal domain, and v2.3.0 on 2026-09-01 connected statute and interpretation lookup to the CLI. That cadence suggests active work, and each release maps to a named capability rather than a version bump. The upgrade cost for users is low because the CLI is a thin client over a hosted service: `pip install --upgrade twlegalrag` picks up client changes, but endpoint behavior can shift without a local install, which is exactly what v2.2.0 did. The repository's licence field reads NOASSERTION, which means GitHub could not map the file to a recognized identifier. The README repeatedly describes the CLI as source-available and states that the retrieval service, model weights and private indexes stay server-side. Source-available and open source are not the same thing, and the distinction affects redistribution and commercial reuse. Read the actual licence file before shipping this inside a product; nothing here is legal advice.
Who should take it, and what to confirm first
This fits a workflow where a Taiwan-law question needs candidate judgments pulled by concept rather than by exact wording, and where a human or a model will read the excerpts afterward. It fits teams that want the retrieval layer to be a separate, inspectable step and that are willing to treat `check` as a tripwire for fabricated case numbers rather than a correctness proof. It does not fit anyone who wants statutory text as it stood on a past date, anyone who needs a guarantee that a quotation is tied to the judgment it is attributed to, or anyone working offline. The MCP path also presumes your client supports MCP; otherwise the CLI is the entry point. Before relying on it, run `twlegalrag health`, pack a bundle for a question whose answer you already know and read the `case_history` and `allowed_citations` fields to see what was actually read, then run `check` against a deliberately wrong answer to see what it does and does not catch. If the NOASSERTION licence field does not resolve to terms your organization accepts, that alone decides the question.
Editorial conclusion
Adopt it if you already run an LLM client that speaks MCP and your question is Taiwan case law retrieval, not legal advice. Skip it if you need pre-amendment statute text or a guarantee that a quoted passage comes from the judgment it is attributed to; the check cannot see that. Verify three things before depending on it: that the hosted endpoint answers `twlegalrag health`, that `case_history` is populated for the judgments you care about, and whether the repository's NOASSERTION licence field matches the terms you need.
Community notes