claude-for-legal
Reference agents, skills, and data connectors for legal teams, covering AI governance work such as EU AI Act system inventories, impact assessments, and matter workspaces that keep each client's context separate.
An MCP server that lets compatible AI assistants search and retrieve public Taiwanese legal material, including statutes, court judgments and Constitutional Court rulings. Results are not legal advice.
$ pip install mcp-taiwan-legal-db
English · 繁體中文
台灣法規、裁判書、憲法法庭裁判與卷宗、行政函釋、判解、訴願與準司法決定、立法資料、司法統計與法學文獻 — MCP Server。
讓任何 MCP 相容的 AI 助手直接存取台灣公開法律資料:
本工具即時爬取官網公開資料,請求由使用者自己的電腦發出。使用前請先讀免責聲明:使用者須自行遵守各網站的使用規定與相關法令,查詢結果不構成法律意見。
以 Python 搭配 MCP Python SDK 寫成。純工具 wrapper,只連線下方「資料來源與統計」列出的官方網站(政府機關,以及國家圖書館、中研院、國立大學、證券交易所等公共機構),不發送任何其他網路請求;釋字/憲判字資料為內建離線打包。
| 功能 | 說明 |
|---|---|
| 26 個 MCP 工具 | 裁判書搜尋/全文/歷審、法規查詢(含英譯與修法追蹤)、釋字/憲判字查詢、引用關係圖譜、憲法法庭卷宗、行政函釋與審查基準、判解、訴願與準司法決定、立法理由與立法紀錄、統計與量刑、法學文獻、地方法規與條約 |
| 離線快取 | 871 筆大法官解釋與憲判字(含理由書全文,以及從官網 PDF 擷取的大法官意見書全文)從本地資料即時回傳 |
| 引用關係圖譜 | 從理由書抽取所有引用的釋字/憲判字(往前追溯),或列出後來引用某件的釋字/憲判字(往後追溯),追溯憲法學說演變 |
| 全文搜尋 | 裁判書關鍵字搜尋 + 釋字爭點/理由書全文搜尋 |
| 混合請求策略 | 預設用 httpx 直打(~0.25s);司法院 F5 WAF 或其他官網的 JavaScript 檢查擋下時,自動改用 Playwright 瀏覽器後繼續 |
pip install mcp-taiwan-legal-db
Debian / Ubuntu / WSL 注意:系統 Python 受 PEP 668 保護,直接
pip install會被擋。請改用:
pipx install mcp-taiwan-legal-db(推薦,自動建隔離 venv,CLI tool 標準裝法)- 或
pip install --user --break-system-packages mcp-taiwan-legal-db
Windows / 企業部署:建議用 uv 或 pipx 裝成獨立工具,不碰系統 Python 的 site-packages:
uv tool install mcp-taiwan-legal-db uv tool update-shell # 把工具目錄加進 PATH,重開終端機後生效套件目錄只讀不寫:查詢快取、WAF cookies 與每週更新的法規代碼表都寫在每位使用者自己的目錄(Windows:
%LOCALAPPDATA%\mcp-taiwan-legal-db;macOS / Linux:~/.cache/mcp-taiwan-legal-db),所以裝到C:\Program Files等全使用者共用位置也能用。要改位置可設環境變數MCP_TAIWAN_LEGAL_DB_HOME。
裝完後 entry point mcp-taiwan-legal-db 會在 PATH 上。接到 Claude Code(任何專案都能用):
claude mcp add taiwan-legal-db mcp-taiwan-legal-db --scope user
接著 /mcp 重啟連線、Claude 就會在自然語言查詢時自動用 26 個 MCP tool。
Chromium:司法院 WAF(伺服器第一次啟動、還沒有 cookies 時就會用到,見WAF 處理機制),以及文化部訴願、NCC、雲林縣等需要瀏覽器的來源,會在第一次需要時自動下載安裝(約 150MB,僅一次)。無法連外下載的環境請預先安裝:
uvx --from mcp-taiwan-legal-db playwright install chromium # 僅在查詢需要瀏覽器時啟動,平時 idle
內政部、衛福部、勞動部訴願與醫事懲戒需要通過官網驗證碼,預設不查詢。啟用前請確認符合各網站的使用規定與相關法令,使用責任由使用者自行承擔。
關閉時查到這些來源(例如 source="內政部"、source="訴願"),工具不連官網,只回「此來源預設關閉」和官網網址,請自行到官網查詢。要啟用,設定環境變數 MCP_TAIWAN_LEGAL_DB_ENABLE_CAPTCHA_SOURCES=1 後重新啟動;內政部、衛福部另外需要本機 OCR 依賴 [captcha]:
pip install "mcp-taiwan-legal-db[captcha]"
claude mcp add taiwan-legal-db --scope user -e MCP_TAIWAN_LEGAL_DB_ENABLE_CAPTCHA_SOURCES=1 -- mcp-taiwan-legal-db
Claude Code plugin 不啟用這些來源,也不帶 [captcha];要用請改照上面自行安裝。
下面是 clone 來修程式 / 跑測試的流程:
# 1. Clone repo
git clone https://github.com/lawchat-oss/mcp-taiwan-legal-db.git
cd mcp-taiwan-legal-db
# 2. 建立並初始化虛擬環境
python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -e .
# 3. 安裝 Playwright Chromium(供需要瀏覽器的官方來源使用)
.venv/bin/playwright install chromium
# 4. 驗證伺服器可以啟動並註冊 26 個工具
.venv/bin/python -c "
import asyncio
from mcp_server.server import mcp
print('Server:', mcp.name)
tools = asyncio.run(mcp.list_tools())
print('Tools:', [t.name for t in tools])
assert len(tools) == 26, f'Expected 26 tools, got {len(tools)}'
print('✓ Setup OK')
"
預期輸出:
Server: 台灣法律資料庫
Tools: ['search_judgments', 'get_judgment', 'query_regulation', 'get_pcode', 'search_regulations', 'get_interpretation', 'search_interpretations', 'get_citations', 'search_agency_interpretations', 'get_agency_interpretation', 'search_precedents', 'get_precedent', 'search_administrative_decisions', 'get_administrative_decision', 'get_legislative_history', 'search_constitutional_docket', 'get_constitutional_case_file', 'search_legislative_records', 'get_legislative_record', 'search_statistics', 'get_statistics', 'get_sentencing_statistics', 'search_legal_literature', 'get_legal_literature', 'search_other_regulations', 'get_other_regulation']
✓ Setup OK
上面沒報錯就完成了。Repo 根目錄已經帶一份 .mcp.json,任何在此資料夾內開的 Claude Code session 會自動載入這個 server,不需要額外註冊。
26 個 MCP 工具,全部唯讀,全部只連線官方公開資料庫(見「資料來源與統計」)。
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
search_judgments | 搜尋司法院裁判書資料庫 | search_judgments(keyword="預售屋 遲延交屋", case_type="民事") |
get_judgment | 依 JID 或 URL 取得單筆判決全文與歷審清單 | get_judgment(jid="TPSM,114,台上,3753,20251112,1") |
query_regulation | 查詢法規條文(單條、區間、跨號多條)、章節目錄、修法沿革、官方英譯 | query_regulation(law_name="民法", article_no="184~186,247-1") |
get_pcode | 將法規名稱解析為 pcode(法規代號) | get_pcode(law_name="律師法") |
search_regulations | 以關鍵字搜尋 11,700+ 部法規,或列出某日以後修正公布的法規 | search_regulations(keyword="勞動") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
get_interpretation | 大法官解釋/憲判字全文(離線快取) | get_interpretation("釋字748", reasoning_keyword="婚姻") |
search_interpretations | 搜尋釋字/憲判字(爭點 + 理由書全文) | search_interpretations(keyword="集會自由") |
get_citations | 引用關係圖譜(往前或往後追溯) | get_citations("釋字748", include_context=True) |
search_constitutional_docket | 受理中、排定言詞辯論、徵求法庭之友意見的案件 | search_constitutional_docket(status="amicus") |
get_constitutional_case_file | 卷內文書:聲請書、答辯書、鑑定意見、法庭之友意見書、言詞辯論筆錄等 | get_constitutional_case_file("113年憲判字第8號") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
search_agency_interpretations | 搜尋各機關行政函釋與智慧局審查基準(51 個官方來源,即時查詢;標出停止適用) | search_agency_interpretations(keyword="加班費", agency="勞動部") |
get_agency_interpretation | 取得函釋全文(主旨、說明、相關法條、編註、效力標示) | get_agency_interpretation("moj:FE393340") |
search_precedents | 搜尋決議、法律問題座談、停止適用判例、司法解釋(院字/院解字)、大法庭裁定、精選裁判 | search_precedents(keyword="借名登記", category="決議") |
get_precedent | 取得判解全文(含編註,例如「不再援用」) | get_precedent("D:A,20170214,001") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
search_administrative_decisions | 搜尋訴願決定(行政院、各部會、縣市政府)與準司法機關的決定、處分 | search_administrative_decisions(keyword="個人資料", source="行政院") |
get_administrative_decision | 取得決定書/處分書全文(由官網 HTML 或 PDF 擷取) | get_administrative_decision("ey:A-115-000633") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
get_legislative_history | 某一條文歷次制定、修正時的條文與立法理由,附最近一次修正的立法歷程 | get_legislative_history("勞動基準法", "24") |
search_legislative_records | 搜尋立法院議案(含審查中草案)、立法院公報、法規命令草案預告 | search_legislative_records("勞動基準法", kind="bills") |
get_legislative_record | 取得議案、公報紀錄或草案預告全文 | get_legislative_record("bill:202110226160000") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
search_statistics | 搜尋司法統計年報/月報、法務統計、《犯罪狀況及其分析》 | search_statistics(keyword="收結", source="司法統計") |
get_statistics | 取得統計表內容或報告全文 | get_statistics("moj:INF_COMMON_P/807") |
get_sentencing_statistics | 司法院量刑資訊系統的刑度統計(判決數、刑度平均與分布) | get_sentencing_statistics(crime="竊盜") |
search_legal_literature | 搜尋司法院專題研究報告、國圖期刊論文索引、GRB 研究計畫、開放取用法學期刊 | search_legal_literature("量刑", source="司法研究年報") |
get_legal_literature | 取得書目、摘要與全文(有公開全文時) | get_legal_literature("ncl:A15001353") |
| 工具 | 用途 | 典型呼叫 |
|---|---|---|
search_other_regulations | 搜尋全國法規資料庫以外的規範:地方自治法規、條約協定、交易所規章 | search_other_regulations("違章建築", source="臺北市") |
get_other_regulation | 取得條文(單條、區間、多條;未分條的文件回全文) | get_other_regulation("taichung:GL001385", article_no="3") |
search_judgments
搜尋司法院判決系統。支援:
case_word + case_number + year_fromkeywordmain_text="被告應將 移轉" + keyword="借名登記" → 找被告敗訴的借名登記案court、case_type(民事/刑事/行政/懲戒)、year_from/year_to 過濾重要:要查某個特定案號時,一定要用 case_word+case_number,不要放進 keyword。
# ✅ 正確 — 查 114 台上 3753 最高法院
search_judgments(case_word="台上", case_number="3753", year_from=114, court="最高法院")
# ✅ 正確 — 全文搜尋
search_judgments(keyword="預售屋 遲延交屋")
# ❌ 錯 — 把案號放進 keyword
search_judgments(keyword="114年度台上字第3753號")
get_judgment
取得單筆判決的結構化全文。
jid(從 search_judgments 結果取得)或 url{case_id, court, date, main_text, facts, reasoning, cited_statutes, cited_cases, full_text, source_url, history, history_note}get_judgment(jid="TPSM,114,台上,3753,20251112,1")
# → history: 臺中地院 111 易 203 → 臺中高分院 113 上易 80 → … 各審級裁判(含 jid、url)
history 是司法院依案號串起的歷審清單,引用判決前先看後面還有沒有上級審裁判、是否已被廢棄或發回。pending_supreme_court=true 表示案件目前在最高法院/最高行政法院審理中;清單最後一筆之後沒有更高審級,不等於已經確定(可能仍在上訴期間內,或上級審裁判尚未上網)。
單筆判決可能超過 1 萬 token。建議先用 search_judgments 取得 metadata,只在使用者明確需要時才抓全文。
query_regulation
查詢全國法規資料庫的條文:單條、區間或跨號多條,一次最多 50 條。不指定條號時不回傳條文,只回傳章節目錄(structure,各編章節的標題與起始條號)與條號範圍;整部法規動輒上千條,一次全給只會塞滿 agent 的 context。
# 單一條文
query_regulation(law_name="民法", article_no="184")
# 區間、跨號多條,可混用(也接受「第184條」「247之1」)
query_regulation(law_name="民法", article_no="184~198")
query_regulation(law_name="民法", article_no="184,185,247-1")
# 不指定條號:章節目錄與條號範圍
query_regulation(law_name="律師法")
# 附修法沿革;指定條號時另回傳該條歷次條文(article_history)
query_regulation(law_name="勞動基準法", article_no="24", include_history=True)
# 官方英譯(約 970 部法律與部分命令)
query_regulation(law_name="勞動基準法", article_no="24", language="en")
回傳的 law 另含 last_amended(最新公布日)與 category(主管機關分類);有特殊施行日時含 effective_date/effective_note(如「自公布後六個月施行」「施行日期由行政院定之」),引用新修正條文前先看這兩欄確認是否已施行。這些欄位來自每週更新的 law_meta.json。
language="en" 回傳官方英譯本與 english_version_date;英譯常落後中文修正,版本較舊時 note 會提醒,法律效力以中文為準。英譯檔第一次查詢時下載到使用者資料目錄(約 16 MB),每週更新。
指定條號並開啟 include_history 時,article_history.revisions 會列出該條每次制定、增訂、修正、刪除的日期與當時條文,可直接前後對照。只讀取修法沿革中動到該條的歷史版本(例如民法第 184 條只需 36 個版本中的 5 個),版本清單與歷史版本全文都會快取;讀取失敗的版本會列在 failed_versions 並標 partial。
支援 law_name(自動解析 pcode,縮寫如「勞基法」也可)或直接傳 pcode。超過 50 條時回傳 has_more 與續查起點;指定了卻不存在的單條列在 missing。from_no/to_no 等同 article_no="起~迄"。
search_regulations
以名稱關鍵字搜尋法規,每頁 50 筆,現行法規排在已廢止之前。每筆含 last_amended 與 category,可用來追蹤修法:
search_regulations(keyword="勞動")
search_regulations(keyword="消費", exclude_abolished=True)
# 某日以後新制定/修正公布的法規(新到舊),可再依主管機關篩選
search_regulations(amended_since="2026-09-01")
search_regulations(amended_since="115-07-01", category="勞動部")
get_interpretation
取得大法官解釋(釋字第 1–813 號)或憲法法庭裁判(憲判字)全文。預設層從本地 JSON 快取即時回傳。
分層設計(節省 context):
| 層級 | 觸發條件 | 離線? |
|---|---|---|
| 預設層(字號/日期/爭點/解釋文) | 永遠回傳 | ✓ |
| 理由書片段 | reasoning_keyword="關鍵字" | ✓ |
| 理由書全文(不按字數截斷) | include_reasoning=True | ✓ |
| 意見書片段 | opinions_keyword="關鍵字" | ✓ |
| 意見書全文 | include_opinions=True | ✓ |
| 單份意見書全文 | opinion_document="許宗力" | ✓ |
| 從指定位置讀到文末(相容舊參數) | opinions_offset=15000 | ✓ |
# 預設層(離線,~0ms)
get_interpretation("釋字748")
# 理由書中搜尋關鍵字
get_interpretation("釋字748", reasoning_keyword="婚姻自由")
# 在意見書中定位特定大法官
get_interpretation("釋字758", opinions_keyword="湯德宗")
# 只讀某位大法官的完整意見書
get_interpretation("釋字758", opinion_document="許宗力")
# 需要從指定字元位置開始時,回傳該位置以後的全部文字
get_interpretation("釋字777", opinion_document="吳陳鐶", opinions_offset=15000)
# 新制憲判字
get_interpretation("111年憲判字第1號")
建議先用 keyword 片段模式定位,只在需要時才開全文模式。
Reference agents, skills, and data connectors for legal teams, covering AI governance work such as EU AI Act system inventories, impact assessments, and matter workspaces that keep each client's context separate.
Reviews contracts, generates NDAs and business agreements, flags missing clauses, compares contract versions, and audits websites for compliance gaps, with PDF reports for Claude Code users doing legal work.
Helps Chinese legal practitioners work through PRC statutory law, from finding the relevant articles and cases to weighing evidence and building an argument for a dispute or a judgment. Each aid is hand-written and checked by lawyers.
Gives lawyers case tracking and document tools: a local case dashboard with deadline alerts and weekly analysis, progress and task updates, scheduling of court and travel dates with reminders, and turning existing articles or notes into books or courses.
An MCP server that lets compatible AI assistants search and retrieve public Taiwanese legal material, including statutes, court judgments and Constitutional Court rulings. Results are not legal advice. Install it with the command on its page. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it