by lawchat-oss
台灣司法院判決 + 全國法規資料庫 MCP server · Query Taiwan legal data from any MCP AI agent
# Add to your Claude Code skills
git clone https://github.com/lawchat-oss/mcp-taiwan-legal-dbGuides for using ai agents skills like mcp-taiwan-legal-db.
mcp-taiwan-legal-db is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by lawchat-oss. 台灣司法院判決 + 全國法規資料庫 MCP server · Query Taiwan legal data from any MCP AI agent. It has 237 GitHub stars.
mcp-taiwan-legal-db's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/lawchat-oss/mcp-taiwan-legal-db" and add it to your Claude Code skills directory (see the Installation section above).
mcp-taiwan-legal-db is primarily written in Python. It is open-source under lawchat-oss on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh mcp-taiwan-legal-db against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
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") |
搜尋司法院判決系統。支援:
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號")
取得單筆判決的結構化全文。
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,只在使用者明確需要時才抓全文。
查詢全國法規資料庫的條文:單條、區間或跨號多條,一次最多 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