Prototype · Preview: every server in the official registry, synced every 30 minutes. Sign in with Google to write reviews.Prototype · updated every 30 min
PopNx MCPMCP servers for people who use AI · explained in plain words Sign in

Tw Legal Rag

by aa0101181514version 2.3.4i★ 348iRuns in the cloudOfficial site ↗
Registry nameio.github.aa0101181514/tw-legal-rag

How to install

What it does

Taiwan law MCP server: 22M court judgments, statutes, agency rulings, with citation checks

  • Connects Runs in the cloud
  • Account or key Sign in to the service when you connect (OAuth)
  • Category Law & government data

Why it ranks here

Lists are ordered by a usage score (out of 100) built from these parts

Popularity31/80GitHub stars or weekly downloads: the larger counts 60, the smaller 20
Freshness12/12Full marks for a release or code change within 30 days
Still answering8/8The cloud endpoint answered at the last check
Usage score51/100

Quality: Passed 4/5 basic checks (shown, not used for ordering) · Momentum: No data yet (Used only on the Trending tab)

Install

Pick the AI app you use, then copy the settings.

Let your AI install it with one sentence

Please install Tw Legal Rag. Follow https://mcp.popnx.com/i/aa0101181514-tw-legal-rag.md, show me the commands and wait for my OK before running them.

Paste it into an AI that can work on your computer (such as Claude Code or Cursor). It reads our steps, shows you the commands and waits for your OK. No key, no sign-up. · See the full text your AI reads

Passed 4/5 checks · What you ask goes through the maker’s server (tlr.dr-legal.com.tw) · ✓ Commands checked Nov 20, 2026

First: which AI do you use?

Pick your app and the steps appear below.

Works with Claude · about 2 min

No key, nothing to install · Set it up once on claude.ai or the desktop app, then use it in chat · free accounts can add 1 · on Team/Enterprise an Owner adds it

  1. Open Claude’s Connectors page

    CustomizeConnectors

    CustomizeConnectors1Add2https://…3Add4
  2. Click “Add” → “Custom” → “Web” and fill in these 2 fields

    Copy each value into the field with the same name in Claude, then click Continue

    Name · NameTw Legal Rag
    Remote MCP server URL · Addresshttps://tlr.dr-legal.com.tw/mcp

    Click Continue past the sign-in settings Claude detected · under Authentication choose what the maker says (Sign in now, Sign in when needed or No sign in), then click Add

  3. Turn it on in a chat

    +ConnectorsTw Legal Rag

  4. Try it

    Use Tw Legal Rag and tell me what you can do for me, then show me one thing

    ✓ If Claude says it is using Tw Legal Rag or shows a Tw Legal Rag tool in the answer, you are connected

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with ChatGPT, depending on your plan

Full MCP: ChatGPT Business, Enterprise or Edu on the web · Pro: connects with read/fetch permissions, so tools that change data may not work · Plus: not confirmed in OpenAI’s docs; if you see an add-custom-MCP option on the Plugins page you can try these steps · web only

  1. Open ChatGPT’s add-MCP page on the web

    Plugins+Add custom MCP server

    ChatGPTPlugins1+2https://…3Create4
  2. Fill in the name and address

    Enter a name, paste the address under Connection, tick the risk warning and click Create as a plugin

    Name · NameTw Legal Rag
    Connection · Addresshttps://tlr.dr-legal.com.tw/mcp
  3. Pick Tw Legal Rag in a chat

    Start a new chat and pick Tw Legal Rag from your plugins before typing

  4. Try it

    Use Tw Legal Rag and tell me what you can do for me, then show me one thing

    ✓ If ChatGPT says it is using Tw Legal Rag or shows a Tw Legal Rag tool in the answer, you are connected

Menu names checked against OpenAI’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with Claude Code · about 2 min

No key, nothing to install

  1. Open Terminal

    Mac: press Command+Space and type Terminal · Windows: open PowerShell

  2. Paste this command and press Enter

    claude mcp add --transport http --scope user tw-legal-rag https://tlr.dr-legal.com.tw/mcp
  3. Type /mcp in Claude Code

    You should see Tw Legal Rag listed as connected

  4. Try it

    Use Tw Legal Rag and tell me what you can do for me, then show me one thing

    ✓ If Claude Code says it is using Tw Legal Rag or shows a Tw Legal Rag tool in the answer, you are connected

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with Cursor · about 2 min

No key, nothing to install

  1. Click this button to open Cursor

    Open in Cursor

    Cursor asks you to confirm; click Install

  2. Open the AI chat in Cursor in Agent mode

  3. Try it

    Use Tw Legal Rag and tell me what you can do for me, then show me one thing

    ✓ If Cursor says it is using Tw Legal Rag or shows a Tw Legal Rag tool in the answer, you are connected

Menu names checked against Cursor’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with VS Code · about 2 min

No key, nothing to install

  1. Click this button to open VS Code

    Open in VS Code

    VS Code asks you to confirm; click Install

  2. Open the AI chat in VS Code in Agent mode

  3. Try it

    Use Tw Legal Rag and tell me what you can do for me, then show me one thing

    ✓ If VS Code says it is using Tw Legal Rag or shows a Tw Legal Rag tool in the answer, you are connected

Menu names checked against VS Code’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Other apps that use MCP, such as Windsurf, Zed or Gemini CLI, each add servers differently. See how in the app list.

See every app that uses MCP →

Address for apps that connect over the web

Addresshttps://tlr.dr-legal.com.tw/mcp

JSON settings are under “For developers” below

Stuck? Ask people who use Tw Legal Rag💬 Discussion →
For developers: Terminal commands and JSON settings

Over the web

Claude Code

claude mcp add --transport http --scope user tw-legal-rag https://tlr.dr-legal.com.tw/mcp

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "tw-legal-rag": {
      "url": "https://tlr.dr-legal.com.tw/mcp"
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "tw-legal-rag": {
      "type": "http",
      "url": "https://tlr.dr-legal.com.tw/mcp"
    }
  }
}

These settings are generated from the maker’s registry entry. If the README says otherwise, follow the README.

At a glance

Downloads per weeki
Not on npm/PyPI
Licencei
No licence stated
Connection
Runs in the cloud
Transport
streamable-http
Latest versioni
2.3.4
Published to registryi
Nov 12, 2026
Code last changedi
Nov 12, 2026
Last checked
Nov 19, 2026
Maker
aa0101181514
Registry status
Active

Which apps can use it

Based on how this server connects and on each app’s own docs, checked Nov 10, 2026.

Connect over the internet in

ClaudeChatGPTGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatOpen WebUIRaycast

All apps, with pros and cons →

Related guides

What it can do

The server asks you to sign in before it lists its tools.

Basic checksi

We check information anyone can see; we have not read the code. Checks that do not apply are left out of the count. · Checked Nov 20, 2026

  • ✓ Pass

    Maker matches the repo

    The registry name was verified with the GitHub account aa0101181514, which owns the repo

  • ✓ Pass

    Still maintained

    Code last changed 8 days ago

  • ! Caution

    Has a licence

    GitHub could not identify the licence type; open the file to check

  • ✓ Pass

    Endpoint responds

    Responded in 1136 ms (HTTP 401)

  • ✓ Pass

    Sign-in with OAuth

    Declares OAuth sign-in, so your AI app can take you to log in

  • … Not checked yet

    No hidden instructions in tool descriptions

    Not checked yet; we read the tool list when we check the endpoint

The cloud address answered 5 of the last 5 checks · latest 1,136 ms · checked Nov 19, 2026

What we check → · JSON

Makers: ask for a re-check or report wrong info
For makers: add a badge to your README

If you made this, paste this code into your README. The badge links back to this page.

[![Featured on PopNx MCP](https://mcp.popnx.com/badge/aa0101181514-tw-legal-rag.svg)](https://mcp.popnx.com/en/servers/aa0101181514-tw-legal-rag)

Discussion

Ask, share a tip or report that it does not work. Sorted by what people marked helpful.

No posts yet. Be the first to ask or share.

Posts here are written by users, not the PopNx team.

Sign in to post

User reviews

No reviews yet

Sign in to write a review

Compared with others in Law & government datai

  • More stars than 99% of the other 1957 servers in this category
  • Published to the registry more recently than 85% of the other 1957 servers in this category
  • Basic checks equal to or better than 51% of the other 1957 servers in this category

Compared with every active server in this category in the registry. Stars count only when the publisher owns the repo.

Common questions

Is Tw Legal Rag safe?

It passed 4 of 5 applicable basic checks. We have not read the code. Before adding a key or token, see what access the server asks for and use a key with only the permissions you need.

What keys or codes does it need?

The registry does not list a required key, though some servers ask you to sign in on first use.

Does it run on my computer or in the cloud?

It runs in the maker’s cloud. Connect over the internet with nothing to install, but what you send passes through the maker’s servers.

Is it still maintained?

The GitHub repo last changed 8 days ago, and the latest version (2.3.4) reached the registry 8 days ago.

Which apps can use it?

Apps that support MCP, such as Claude Desktop, Claude Code, Cursor and VS Code. It connects by URL, so apps that accept remote MCP servers work too, such as ChatGPT on the web (full MCP on Business and above; Pro read-only).

What can I use instead?

In the same category: Global law, Open Legal Data (Germany), LibreJustice, InfraNode, Fedlex Connector

Similar alternatives

Same category, other makers, commands already checked. Official ones first, then by stars.

Reading a card:↓ Downloads per weeki★ GitHub starsiThree pillars: reviews · checks · usageiUpdated = latest version published to the registryi

Global law

The law of nearly every country on earth, any date: read it, see what changed it, check citations.

by lexifinaWidely used★ 2.1KUpdated 10 days ago

Runs in the cloud✓ lexifina.com

LibreJustice

Search French-language and European case law and French legal texts (codes, statutes, treaties).

by librejusticeEarly★ 38Updated 2 months ago

Runs in the cloud✓ service owner · librejustice.fr

InfraNode

Keyless open data for 84 German cities: 12 lean read-only MCP tools covering 67 data types.

by street1983nkEarly★ 18Updated 5 months ago

Runs in the cloud✓ service owner · infranode.dev

Fedlex Connector

Search Swiss federal legislation: laws, articles, amendments via the Fedlex SPARQL endpoint.

by JayTheSkierEarly★ 8Updated 7 months ago

Runs in the cloud✓ service owner · fedlex-connector.ch
Compared with similar ones
This one
Tw Legal Rag
Global lawOpen Legal Data (Germany)LibreJusticeInfraNodeFedlex Connector
Runs whereRuns in the cloud, nothing to installRuns in the cloud, nothing to installRuns in the cloud, nothing to installRuns in the cloud, nothing to installRuns in the cloud, nothing to installRuns in the cloud, nothing to install
Needs a keyNoNoNoNoNoNo
Add with + in ClaudeNoNoNoNoNoNo
Basic checks4/54/44/44/44/44/4
LicenseNOASSERTIONNOASSERTIONMITApache-2.0Apache-2.0MIT
PriceNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registryNo cost listed in the registry

README from the maker

Open the README

Copied from the maker’s repo as written. PopNx MCP has not reviewed or endorsed it. HTML, images and scripts are removed. Links lead off this site.

Taiwan Legal RAG:台灣法律 MCP 伺服器與 CLI(twlegalrag)

🌐 Language / 語言 / 言語

繁體中文 ・ English ・ 日本語


免費、免 API key,連接時登入法律偵探帳號 的台灣法律 MCP 伺服器:在 Claude、ChatGPT、Gemini CLI、Microsoft 365 Copilot、Codex、Cursor 加入

https://tlr.dr-legal.com.tw/mcp 一個網址,AI 助理就能直接語義檢索 2,280 萬筆台灣裁判書、

行政函釋與憲法法庭裁判,逐筆附引用查核。另提供同一後端的公開原始碼 CLI(twlegalrag)。

Free, no API key; sign in to a Dr.Legal account when connecting. Taiwan legal MCP server

(Taiwan law MCP) + source-available CLI, backed by Dr.Legal's 22M-judgment semantic retrieval infrastructure.

快速連接:台灣法律 MCP

MCP 端點(Streamable HTTP,OAuth 授權):

https://tlr.dr-legal.com.tw/mcp
工具連接方式
Claude(網頁/桌面)在 Claude 連接器目錄 按連接;或於 Connectors 新增自訂連接器,貼上端點
Claude Codeclaude mcp add --transport http --scope user tlr https://tlr.dr-legal.com.tw/mcp
Codex CLIcodex mcp add tlr --url https://tlr.dr-legal.com.tw/mcp,再執行 codex mcp login tlr
ChatGPT、Gemini、Cursor、Microsoft 365 Copilot新增自訂 MCP 連接器並貼上端點,步驟見下方「其他接法」

首次連接會開啟法律偵探登入頁,以 Google 或電子郵件帳號登入(免費註冊),不需申請 API 金鑰。 提供六個工具:裁判檢索、裁判全文與審級關聯、附引用白名單的 bundle、現行法條查詢、行政函釋字號查詢、行政函釋語義檢索。 圖文步驟見 dr-legal.com.tw/mcp。

Taiwan Legal RAG CLI retrieves Taiwan court judgments from Legal Detective's public TLR endpoint and packages them for use with your own AI tools. It does not generate legal advice, does not call any LLM, and does not guarantee semantic faithfulness of third-party model outputs. Its built-in citation check only verifies whether cited judgments belong to the retrieved bundle.

作者:黃思齊(Aaron Huang)律師,法律偵探/Dr.Legal 創辦人(個人介紹)。

繁中:Taiwan Legal RAG CLI 是一個公開原始碼命令列工具,連接法律偵探建置的 2,280 萬筆 台灣裁判語義檢索服務(22,795,389 筆,截至 2026-11-11),讓你能用自然語言搜尋判決,並將檢索結果帶入自己的 AI 工具使用。

資料涵蓋(統計截至 2026-11-11,取自 production 資料庫)

一、法規範(依法位階)

位階資料類型數量說明
憲法憲法位階7 部/228 條憲法本文、增修條文、實施準備程序及解嚴令等現行規範
憲法釋字與憲判字872 筆大法官解釋 813 筆、憲法法庭判決 59 筆,有拘束全國各機關及人民之效力
法律法律1,022 部/44,503 條定名為法、律、條例或通則者(中央法規標準法 §2)
命令法規命令7,255 部/128,753 條定名為規程、規則、細則、辦法、綱要、標準或準則者(同法 §3)
命令行政規則107,889 筆107 個機關發布之解釋性規定與裁量基準(行政程序法 §159),對外不生法規範效力
沿革已廢止法規3,526 部法律 320 部、法規命令 3,204 部,及動員戡亂時期臨時條款等憲法位階規範,標示廢止狀態供查考

二、裁判與裁決

資料類型數量說明
裁判書(司法院各級法院)22,795,389 筆語義檢索+詞彙檢索+案號精確調卷;每日增量同步司法院公開資料,含事後更正與下架之同步對齊
不當勞動行為裁決(勞動部裁決委員會)466 筆勞動議題查詢自動並列,明確標示為裁決、非法院判決

三、輔助資料

資料類型數量說明
審級關聯(上訴鏈)4,384,977 筆隨判決附 case_history,含主文「廢棄/駁回」旗標
函釋效力履歷84,966 筆廢止/停止適用/被取代狀態追蹤,引用前驗效力

法規範與裁判之取用方式:裁判書、行政規則走 hosted MCP 的語義檢索與字號精確查詢; 現行憲法、法律、法規命令的條文,以 hosted MCP 的 get_law_article 依法規名稱與條號精確查詢;法規全文檢索於 dr-legal.com.tw 站上進行。

裁判書為每日增量同步(司法院公開資料釋出有數日時差,極新宣判的裁判請以官網為準)。 以上數字直接取自 production 資料庫並標註統計日,非估計值。

裁判書明細(依法院層級/案件類別)
法院層級筆數
地方法院17,176,339
地方法院簡易庭3,341,870
高等法院及分院1,363,241
最高法院406,823
高等行政法院203,478
最高行政法院124,470
地方行政訴訟庭95,634
高雄少年及家事法院25,751
智慧財產及商業法院24,214
其他專業法庭・委員會33,569
合計22,795,389
案件類別筆數
民事14,623,447
刑事7,551,203
行政594,940
其他25,799
行政規則發布機關明細(107 個機關,統計日 2026-11-11)
機關筆數
財政部10,707
內政部國土管理署8,769
金管會8,408
經濟部智慧財產局7,203
勞動部7,194
法務部7,113
內政部6,746
經濟部6,689
行政院環境保護署4,467
行政院公共工程委員會4,104
銓敘部4,015
考試院3,414
農業部3,091
教育部2,912
文化部1,519
前司法行政部1,432
法務部行政執行署1,417
內政部戶政司1,391
環境部1,123
主計總處721
公務人員保障暨培訓委員會693
國科會576
文化部文化資產局561
農業部水保署543
司法行政部444
考選部429
人事行政總處325
行政院消費者保護處269
核能安全委員會229
原住民族委員會227
行政院227
海洋委員會224
公平交易委員會205
僑務委員會184
法務部矯正署170
外交部136
中央選舉委員會112
農業部林業及自然保育署103
客家委員會97
國家發展委員會86
個人資料保護委員會籌備處76
故宮博物院59
司法院56
大陸委員會52
臺灣高等法院檢察署41
法務部政風司37
法務部廉政署32
經濟部能源署28
法務部調查局20
其他 58 個機關(各未滿 20 筆)120
合計98,796

(機關名稱依函釋原始發文機關記載,含已改制機關之歷史名稱,如「行政院環境保護署」 「前司法行政部」;改制前後分列、不合併,以保留原始發文脈絡。)

為什麼不一樣

這不是一般關鍵字判決搜尋工具。背後連到的是法律偵探長期建置的 TLR 檢索服務:

  • 22,795,389 筆台灣裁判資料(截至 2026-11-11),經過結構化處理與向量化。
  • 語義模糊搜尋:不是只靠案號、法院、關鍵字,用自然語言就能找到 「概念相近但用詞不同」的判決;另有詞彙精確檢索模式供專有名詞查找。
  • 案號精確調卷:完整裁判字號自動切換精確調卷;查無時明確告知 「查無不代表該裁判不存在」,不拿語義近似結果充數。
  • 審級關聯 `case_history`:隨判決附上資料庫記錄的上下審級與主文 「廢棄/駁回」旗標,引用前就能看到判決是否已被上級審廢棄。
  • 行政規則雙工具:字號精確查詢(附效力狀態:已驗證有效/未驗證/已廢止/ 停止適用/已被取代)與語義檢索成對使用;函釋與判決嚴格分流,不混排、 不得引為法院見解。詳見 docs/mcp-anchor.zh.md。
  • 現行法條精確查詢:以法規名稱+條號取回現行條文原文,並附法規最後修正 日期、廢止註記與本庫所對應的官方資料集版本日期。引用法條前可先核驗條號存在 與文字內容,不必憑模型記憶背條文;常用縮寫(勞基法、刑法、憲法)自動解析為 官方法規名。法規語料每日核對全國法規資料庫官方版本更新;僅提供現行整編版本, 行為時法(修法前舊條文)請至官方沿革查詢。
  • 引用防護是一等公民:allowed_citations 白名單(只含實際讀入理由全文的 判決)、unread_candidates 標記、寫進每個 bundle 的驗證指示,加上 CLI 端的 citation check。整套設計針對法律 AI 最痛的幻覺型態:字號真實、見解捏造。
  • 本 CLI 不內建判決庫,也不暴露後端模型權重、向量索引或檢索管線細節; 它是連接公開 TLR retrieval endpoint 的工具。
與「官方網站 wrapper」型工具的差異

另一類常見做法是即時轉打司法院/法規官網的站內搜尋。兩者定位不同,可以互補:

官網 wrapperTaiwan Legal RAG
搜尋方式官方站內關鍵字搜尋自建 2,280 萬筆語料的語義檢索,概念相近、用詞不同也找得到
引用防護通常無read-whitelist + 驗證指示 + citation check
案號調卷依官網功能精確調卷,查無時明確告知不得臆測
審級關聯需自行逐案追case_history 直接附上,含廢棄標記
可用性受官網 WAF / 改版影響,常需本地跑瀏覽器繞驗證hosted endpoint,零本地環境需求
資料即時性官網即時極新公告的裁判請以官網為準

官網 wrapper 的強項是即時性與官方來源直連;本工具的強項是語義檢索品質與引用 紀律。

Unlike keyword-only legal search tools, Taiwan Legal RAG CLI connects to a

production semantic retrieval backend built on 22M+ Taiwan court judgments,

enabling fuzzy concept-level search while keeping model weights, infrastructure,

and private indexes server-side.

(措辭說明:公開原始碼的是 CLI,不是模型或向量庫;後端的檢索服務、模型權重、私有 索引都留在伺服器端,不隨本工具公開。)

它做什麼 / 不做什麼

做:用自然語言檢索判決 → 取得結構化清單、判決全文片段(excerpt)、引用連結 → 打包成 bundle 交給你自己的 AI;並可對 AI 產生的答案做 bundle 層級的引用檢查。

不做:本工具不呼叫任何 LLM、不生成法律意見、不背書任何模型輸出。答案要由 你自己選的 AI(ChatGPT / Claude / Gemini / 本地模型)生成。

內建的 citation check 能檢查什麼

check 是 bundle 層級、盡力而為的字串檢查,只驗:

  • 答案引用的判決字號是否在 bundle 內(抓「引用了不在 bundle 的字號」= 疑似捏造);
  • 是否引用 bundle 外、或不存在的判決;
  • 引文存在性(bundle 層級):答案宣稱「法院說……」的逐字句,是否出現在 bundle 文字的某處。
它不能檢查什麼(重要)
  • 引文是否出自答案所指的那一篇判決(存在性檢查只看「整個 bundle 裡有沒有這句」, 不綁定到特定判決);
  • 法院見解是否讀對;
  • 是否把當事人主張(原告/被告/上訴人)當成法院見解;
  • 是否把附帶論述當成判決核心權威;
  • paraphrase(改寫)型的見解幻覺。

這些都需要閱讀判決全文才能判斷,這也是為什麼 bundle 內附上判決全文片段與 verification instructions,要求下游模型自行核對。`pass` 只代表「引用的字號身分對得上 bundle」,不代表「法律推論正確」或「引文確實出自那篇」。 另外,check 只比對 bundle 內的內容,不是整個法律偵探資料庫,若你事後自己開判決全文再改寫答案, check 仍只看 bundle 當初打包的片段。

安裝

pip install twlegalrag

只依賴 httpx / typer / rich。不需要任何 LLM 套件或 LLM 金鑰,本工具不呼叫 LLM。 使用前先設定 TLR 連線金鑰(見下方「設定」);未設定時,指令會提示取得方式。

使用

# 1) 純檢索:列出符合的判決

twlegalrag search "勞資 加班費" -n 5 --read

限定裁判日期與法院、新到舊排序 (日期寫在查詢字串裡不會篩選)

twlegalrag search "商標權 侵害" --from 2026-10-01 --to 2026-10-31 --court 智慧財產及商業法院 --newest

限定案件類別 (刑事、民事、行政)

twlegalrag search "小額付費 詐欺得利" --case-type 刑事

2) 打包:產生可交給任何 AI 的 bundle ★主流程

twlegalrag pack "車禍對方全責,我可以求償什麼?" -o bundle.json

→ 把 bundle.json 貼給 ChatGPT / Claude / Gemini,要求它只引用 bundle 內的判決

3) 引用檢查:對任何 AI 產生的答案做 bundle 層級檢查

twlegalrag check bundle.json answer.txt

4) 法源查證: 法條原文與函釋效力 (零 LLM)

twlegalrag law 民法 184 twlegalrag ref "台財稅第881945861號" twlegalrag ref-search "扣繳義務人未依限申報之處罰" -n 5

服務是否正常

twlegalrag health

pack 產生的 bundle 包含 query、每筆判決的 citation_id(J1, J2, ...)、 citation_text、citation_url、doc_id、Layer-1 listing、fulltext_excerpt (判決理由的擷取片段,有長度上限)、case_history(資料庫記錄的審級關聯,v1.1)、 allowed_citations,以及一段 verification_instructions,明確要求下游模型只引用 bundle 內判決、把不支持的命題標為 unverified。stderr 也會印一段 AI USE NOTICE。

v1.1 起 verification_instructions 額外包含見解層自查規則(OPINION-LAYER SELF-CHECK),要求下游模型在作答後逐一回頭核對:(a) 歸給某判決的見解確實出現在 該判決的 excerpt(不是別篇的、不是推論的);(b) 裁判結果方向(勝訴/敗訴/廢棄/駁回/ 發回)沒有顛倒;(c) case_history 顯示已被廢棄的判決,不得當成現行有效見解引用。 這與 check 的 bundle 層級字號檢查互補,字號真實不代表見解真實,見解層的核對 只能由讀了全文的模型自己做,這些規則就是把該動作寫進每個 bundle 的硬性指示。

allowed_citations 是「可引用判決」白名單,只含實際讀入理由全文的判決。CLI 的 pack 會讀入每一筆判決,所以兩者一致。Hosted Remote MCP 的 search_bundle (/v1/pack)若 read_top < max_results,只讀入前 read_top 筆;其餘判決仍列在 judgments 供瀏覽,但會移到 unread_candidates(非 authority,不可引為法院論理)。 詳見 docs/mcp-anchor.zh.md。

設定

預設連接公開端點 https://tlr.dr-legal.com.tw。2026-10-30 起 REST 需帶憑證:登入法律偵探帳號(免費)後, 到連線金鑰頁自助產生金鑰,放環境變數或 ~/.twlegalrag/config.toml(已 git-ignore,切勿 commit):

export TWLEGALRAG_TLR_BASE_URL=https://tlr.dr-legal.com.tw   # 預設

export TWLEGALRAG_TLR_API_KEY=... # 2026-10-30 起 REST 必須帶憑證:自助產生的連線金鑰、向 info@dr-legal.com.tw 申請的機構金鑰,或自行以 OAuth 取得的 access token

沒有機構金鑰、想在自己的程式裡直接呼叫 REST:走 OAuth 授權碼加 PKCE 流程登入一次(會開瀏覽器進法律偵探登入頁),之後以 refresh token 自動續期,持續使用不必重登。可直接用純標準函式庫的範例 [docs/tlr_oauth_cli.py](docs/tlr_oauth_cli.py):`python3 docs/tlr_oauth_cli.py login`,然後 `python3 docs/tlr_oauth_cli.py law 民法 184`。範例會把 token 存在 `~/.twlegalrag/tlr_oauth.json`(權限 600)。注意:請求要帶能辨識程式的 User-Agent,預設的 `Python-urllib` 會被邊緣防護擋下。
[tlr]

base_url = "https://tlr.dr-legal.com.tw"

api_key = "..."

隱私與資料流向

先講清楚哪些東西永遠不會經過 TLR 伺服器:

  • 你與 AI(Claude / ChatGPT / 本地模型)的完整對話內容、上傳的文件、AI 生成的 回答,全部發生在你與你的 AI provider 之間,從不經過 TLR。TLR 是 retrieval-only 伺服器,唯一收到的是你的 AI client 決定送出的檢索 query 字串與後續調閱的 判決編號。
  • 連接時登入帳號:2026 年 10 月 30 日起,MCP 授權需登入法律偵探帳號(Google 或 email,免費註冊), 查詢記錄會綁定該帳號,用於識別使用者與統計用量;REST 端點需帶機構金鑰或 OAuth access token,匿名請求回 401。
  • 判決資料本身是台灣公開裁判書,查詢回傳的內容不含非公開個資。

其餘請務必理解的網路傳輸:

  • 你的搜尋字詞 / 問題會送到 TLR 檢索端點(https://tlr.dr-legal.com.tw)以取得判決。
  • TLR may log your query text, timestamp, IP-derived metadata, and result counts for retrieval-quality analysis. Do not submit personal secrets or confidential facts. Queries are not used to train generative models. (TLR 後端可能以明文記錄你的查詢字串、時間、由 IP 推得的中介資料與結果筆數, 供檢索品質分析之用。請勿送出個人機密或保密事實。查詢不會用於訓練生成模型。)
  • 本工具不呼叫 LLM、不使用 server-side token;若你自行把 bundle 餵給某個 AI, 那段傳輸與費用發生在你與你選的 AI provider 之間,與本工具無關。
  • 端點 API 金鑰(若有)請放環境變數,不要 commit 設定檔。

citation check 如何運作

twlegalrag/faithful/ 是一組零依賴純函式(只用標準庫 re + unicodedata)。 給定答案文字與 bundle 內判決片段,回 pass / needs_review / fail。設計上保守: 不確定時回 needs_review 而非 fail,以壓低誤報。它不呼叫 LLM、不碰資料庫,是 確定性的字串分析。

⚠️ 這個目錄是內部程式的快照,裡面有些函式(如 check_party_as_court / run_all_checks)CLI 並沒有用到。它們存在不代表 CLI 能做見解層 / 語義驗證, CLI 只用其中兩個 bundle 層級檢查。請勿把檔案清單當功能清單。詳見 twlegalrag/faithful/VENDORED.md。

2026-08-20 服務端更新(hosted MCP / REST)

  • bundle 回應附 result_token,可對 bundle 內任一判決直接調閱全文。
  • 每筆結果附 hit_excerpt(命中段落預覽);引用仍以理由全文為準。
  • get_judgment_fulltext 支援 excerpt_offset 分頁,長判決可完整讀畢。
  • 詞彙精確檢索模式(search_type: keyword / phrase)強化,適合專有名詞 與技術用語;概念性問題建議預設的 hybrid。

以上為伺服器端能力,REST 與 Remote MCP 介面即日可用。CLI v2.1.0 已跟進: pack 自動分頁讀完長判決(bundle 每篇全文預算加倍),並將命中段落 hit_excerpt 帶入 bundle。

其他接法(同一個 TLR 後端)

這個 CLI 是接 TLR 檢索服務的方式之一。同一個後端 tlr.dr-legal.com.tw 也支援把判決 搜尋透過 Remote MCP 直接接進你的 AI 工具。兩者填同一個 MCP 端點 https://tlr.dr-legal.com.tw/mcp,連線時會自動完成 OAuth(動態註冊,無需自行申請或 設定 API key):

  • Claude(Remote MCP):Settings → Connectors → Add custom connector,URL 填 https://tlr.dr-legal.com.tw/mcp。
  • ChatGPT(MCP connector):在 Connectors 新增自訂 MCP server,URL 填 https://tlr.dr-legal.com.tw/mcp。
  • Gemini 網頁版(Spark):開啟 gemini.google.com/spark/apps →「自訂應用程式」→ 在「Spark 適用的自訂應用程式」貼上 https://tlr.dr-legal.com.tw/mcp → 按「繼續」完成授權(自動動態註冊,免金鑰)。 需帳號具備 Gemini Spark;連結後在 Spark 輸入框打 @ 選「法律偵探」即可指名呼叫,一般聊天視窗不會呼叫。 2026-09

Only the beginning is shown; read the rest in the repo