@jurislm/judicial-mcp 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +7 -0
- package/CHANGELOG.md +67 -0
- package/CODE_OF_CONDUCT.md +78 -0
- package/LICENSE +37 -0
- package/MCP_TUTORIAL.md +83 -0
- package/README.md +72 -0
- package/__tests__/mcp.test.js +145 -0
- package/__tests__/tools.test.js +346 -0
- package/bin/judicial-mcp.js +18 -0
- package/oxlintrc.json +22 -0
- package/package.json +58 -0
- package/src/index.js +105 -0
- package/src/tools.js +360 -0
- package/types/index.d.ts +113 -0
package/.env.example
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.2.1] - 2025-07-23
|
|
4
|
+
### 改進
|
|
5
|
+
- 達成 100% 測試覆蓋率 (46 tests, 278 lines covered)
|
|
6
|
+
- 移除未使用的 Express 伺服器相關檔案和依賴
|
|
7
|
+
- 修正所有 oxlint 警告,提升程式碼品質
|
|
8
|
+
- 增強 MCP 配置測試,包含所有 7 個工具的完整驗證
|
|
9
|
+
- 新增工具架構安全性驗證 (`additionalProperties: false`)
|
|
10
|
+
|
|
11
|
+
### 移除
|
|
12
|
+
- 刪除 `server.js`, `start.js` 及相關測試檔案
|
|
13
|
+
- 清理 62 個未使用的 npm 套件依賴
|
|
14
|
+
- 移除 Express.js 和 HTTP API 相關程式碼
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## [1.2.0] - 2025-07-22
|
|
19
|
+
### 新增
|
|
20
|
+
- TypeScript 類型定義檔案 (`types/index.d.ts`)
|
|
21
|
+
- 輸入驗證功能
|
|
22
|
+
- 測試覆蓋率腳本 (`test:coverage`)
|
|
23
|
+
- 環境變數範例檔案 (`.env.example`)
|
|
24
|
+
|
|
25
|
+
### 改進
|
|
26
|
+
- 強化錯誤處理和日誌記錄
|
|
27
|
+
- 新增 API 參數驗證機制
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## [1.1.1] - 2025-07-10
|
|
32
|
+
### 修復
|
|
33
|
+
- 修正版本號不一致的問題
|
|
34
|
+
- 同步所有文件中的版本資訊
|
|
35
|
+
|
|
36
|
+
### 改進
|
|
37
|
+
- 優化專案版本管理流程
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## [1.1.0] - 2025-07-02
|
|
42
|
+
### 新增
|
|
43
|
+
- 增加對 `list_resources` 工具的完整支持,允許用戶根據分類編號檢索資料源。
|
|
44
|
+
- 完善 `download_file` 工具,支持分頁參數 `top` 和 `skip`。
|
|
45
|
+
|
|
46
|
+
### 改進
|
|
47
|
+
- 優化 `auth_token` 工具的錯誤處理,提供更詳細的錯誤信息。
|
|
48
|
+
- 更新測試覆蓋率,新增對 `list_resources` 和 `download_file` 工具的測試用例。
|
|
49
|
+
- 改善 `README.md` 文檔,新增對新功能的使用說明。
|
|
50
|
+
|
|
51
|
+
### 修復
|
|
52
|
+
- 修正 `get_judgment` 工具在處理無效裁判書 ID 時的錯誤回應。
|
|
53
|
+
- 修復環境變數未正確加載時的潛在問題。
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## [1.0.0] - 2025-06-30
|
|
58
|
+
### ✨ 主要功能
|
|
59
|
+
|
|
60
|
+
- 🏛️ **司法院裁判書 API** - 取得裁判書授權、清單和內容
|
|
61
|
+
- 📊 **開放資料 API** - 存取司法院開放資料平台
|
|
62
|
+
- 🔍 **分類資料** - 瀏覽主題分類和資料源
|
|
63
|
+
- 📥 **檔案下載** - 下載司法資料檔案
|
|
64
|
+
- 🧪 **完整測試** - Jest 測試覆蓋
|
|
65
|
+
- 🔒 **安全認證** - 支援 Token 基礎認證
|
|
66
|
+
- 📖 **完整文檔** - 詳細的 API 文檔和使用範例
|
|
67
|
+
- ⚡ **高效能** - 基於 Express.js 框架,支援非同步處理
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 貢獻者行為準則
|
|
2
|
+
|
|
3
|
+
## 我們的承諾
|
|
4
|
+
|
|
5
|
+
為了營造一個開放且友善的環境,我們身為貢獻者和維護者承諾,無論年齡、體型、身心障礙、族群、性別認同與表達、經驗程度、教育程度、社會經濟地位、國籍、個人外觀、種族、宗教或性取向,參與我們專案和社群的每個人都能享有無騷擾的體驗。
|
|
6
|
+
|
|
7
|
+
## 我們的標準
|
|
8
|
+
|
|
9
|
+
有助於創造正面環境的行為範例包括:
|
|
10
|
+
|
|
11
|
+
* 使用友善和包容的語言
|
|
12
|
+
* 尊重不同的觀點和經驗
|
|
13
|
+
* 優雅地接受建設性批評
|
|
14
|
+
* 專注於對社群最有益的事情
|
|
15
|
+
* 對其他社群成員展現同理心
|
|
16
|
+
|
|
17
|
+
不能接受的參與者行為範例包括:
|
|
18
|
+
|
|
19
|
+
* 使用與性有關的言語或圖像,以及令人不悦的性關注或性騷擾
|
|
20
|
+
* 惡意攻擊、侮辱或貶損的評論,人身攻擊或政治攻擊
|
|
21
|
+
* 公開或私下的騷擾
|
|
22
|
+
* 未經明確許可,發佈他人的個人資料,例如住址或電子信箱
|
|
23
|
+
* 其他可以被合理認定為不恰當或不專業的行為
|
|
24
|
+
|
|
25
|
+
## 我們的責任
|
|
26
|
+
|
|
27
|
+
專案維護者有責任為可接受的行為標準做出澄清,並且會對任何不當行為採取適當且公平的糾正措施。
|
|
28
|
+
|
|
29
|
+
專案維護者有權力及責任去移除、編輯或拒絕與本行為準則不符的評論(comments)、提交(commits)、程式碼、wiki 編輯、問題(issues)和其他貢獻,或暫時或永久禁止任何他們認為有不適當、威脅、冒犯或有害行為的貢獻者。
|
|
30
|
+
|
|
31
|
+
## 適用範圍
|
|
32
|
+
|
|
33
|
+
本行為準則適用於所有專案空間,也適用於個人在公共空間代表該專案或其社群的情況。代表專案或社群的例子包括使用官方專案的電子郵件地址、透過官方社群媒體帳號發文,或在線上或線下活動中擔任指定代表。專案的代表可由專案維護者進一步定義及澄清。
|
|
34
|
+
|
|
35
|
+
## 執行
|
|
36
|
+
|
|
37
|
+
若遇到濫用、騷擾或其他不當行為,可以透過 [zxtw17985321@gmail.com] 與專案團隊聯繫。所有投訴都會被審查及調查,並會依情況給予必要且適當的回應。專案團隊有義務為舉報者的隱私保密。具體執行政策的更多細節可能會單獨發佈。
|
|
38
|
+
|
|
39
|
+
專案維護者若未能以誠信原則遵守或執行本行為準則,可能會面臨專案領導階層其他成員所決定的暫時或永久的影響。
|
|
40
|
+
|
|
41
|
+
## 特定於司法院 MCP 專案的補充說明
|
|
42
|
+
|
|
43
|
+
作為一個專注於台灣司法資料存取的開源專案,我們特別重視:
|
|
44
|
+
|
|
45
|
+
### 法律資料的正確性和倫理使用
|
|
46
|
+
|
|
47
|
+
* 貢獻者應確保所提供的程式碼和文件準確無誤
|
|
48
|
+
* 尊重司法資料的隱私和敏感性
|
|
49
|
+
* 遵守相關的法律法規和資料使用條款
|
|
50
|
+
* 不得將本專案用於任何非法或不當目的
|
|
51
|
+
|
|
52
|
+
### 技術討論的專業性
|
|
53
|
+
|
|
54
|
+
* 在討論技術問題時保持專業和建設性的態度
|
|
55
|
+
* 提供清晰的問題描述和重現步驟
|
|
56
|
+
* 尊重不同的技術觀點和解決方案
|
|
57
|
+
* 鼓勵學習和知識分享
|
|
58
|
+
|
|
59
|
+
### 社群參與
|
|
60
|
+
|
|
61
|
+
* 歡迎各種背景的開發者參與貢獻
|
|
62
|
+
* 提供中文和英文的雙語支援
|
|
63
|
+
* 協助新手理解專案架構和貢獻流程
|
|
64
|
+
* 分享使用案例和最佳實踐
|
|
65
|
+
|
|
66
|
+
## 歸屬
|
|
67
|
+
|
|
68
|
+
本行為準則改編自 [Contributor Covenant][homepage] 2.1 版,可於 [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1] 取得。
|
|
69
|
+
|
|
70
|
+
社群影響指引的靈感來自 [Mozilla's code of conduct enforcement ladder][Mozilla CoC]。
|
|
71
|
+
|
|
72
|
+
關於本行為準則的常見問題,請參閱 [https://www.contributor-covenant.org/faq][FAQ]。翻譯可於 [https://www.contributor-covenant.org/translations][translations] 取得。
|
|
73
|
+
|
|
74
|
+
[homepage]: https://www.contributor-covenant.org
|
|
75
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
76
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
77
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
78
|
+
[translations]: https://www.contributor-covenant.org/translations
|
package/LICENSE
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# MIT 授權條款
|
|
2
|
+
|
|
3
|
+
版權所有 (c) 2025 Terry Chen
|
|
4
|
+
|
|
5
|
+
特此免費授予任何取得本軟體及相關文件檔案(「軟體」)副本之人員,得不受限制地處置該軟體,包括但不限於使用、複製、修改、合併、發佈、散布、再授權及/或銷售軟體副本之權利;惟須符合以下條件:
|
|
6
|
+
|
|
7
|
+
上述之版權聲明及本授權聲明應包含在本軟體之所有副本或主要部分中。
|
|
8
|
+
|
|
9
|
+
本軟體係依「現況」提供,不提供任何形式之明示或暗示擔保,包括但不限於適售性、特定目的適用性及未侵害他人權利之擔保。於任何情況下,無論是契約訴訟、侵權行為或其他訴訟,作者或版權持有人均不承擔因本軟體或本軟體之使用或其他dealings軟體而產生、引起或與其相關之任何索賠、損害或其他責任。
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 關於此專案
|
|
14
|
+
|
|
15
|
+
本專案(judicial-mcp)為開源軟體,專門提供存取台灣司法院開放資料和裁判書的 Model Context Protocol (MCP) 伺服器。
|
|
16
|
+
|
|
17
|
+
### 使用條款補充說明
|
|
18
|
+
|
|
19
|
+
1. **資料來源聲明**:本軟體僅提供存取司法院公開資料之介面,所有司法資料之版權歸屬於中華民國司法院。
|
|
20
|
+
|
|
21
|
+
2. **合法使用**:使用者應遵守相關法律法規,不得將本軟體用於任何非法目的。
|
|
22
|
+
|
|
23
|
+
3. **資料隱私**:在處理司法資料時,請特別注意個人隱私保護及相關資料保護法規。
|
|
24
|
+
|
|
25
|
+
4. **免責聲明**:本軟體開發者不對司法院資料之準確性、完整性或時效性負責。
|
|
26
|
+
|
|
27
|
+
### 貢獻與支援
|
|
28
|
+
|
|
29
|
+
歡迎社群貢獻程式碼和回報問題。參與本專案前,請先閱讀 [行為準則](CODE_OF_CONDUCT.md)。
|
|
30
|
+
|
|
31
|
+
如有技術問題或建議,請至 [GitHub Issues](https://github.com/terry90918/judicial-mcp/issues) 頁面回報。
|
|
32
|
+
|
|
33
|
+
### 聯絡資訊
|
|
34
|
+
|
|
35
|
+
- 作者:Terry Chen
|
|
36
|
+
- 電子郵件:zxtw17985321@gmail.com
|
|
37
|
+
- GitHub:https://github.com/terry90918/judicial-mcp
|
package/MCP_TUTORIAL.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# 司法院 MCP 伺服器教學
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
司法院 MCP 伺服器讓 AI 助手透過 Model Context Protocol 存取台灣司法院的開放資料和裁判書。
|
|
6
|
+
|
|
7
|
+
## 快速開始
|
|
8
|
+
|
|
9
|
+
### 安裝
|
|
10
|
+
```bash
|
|
11
|
+
npm install judicial-mcp
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### 環境設定
|
|
15
|
+
```bash
|
|
16
|
+
cp .env.example .env
|
|
17
|
+
# 編輯 .env 設定司法院帳號密碼
|
|
18
|
+
JUDICIAL_USER=your_username
|
|
19
|
+
JUDICIAL_PASSWORD=your_password
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## MCP 客戶端配置
|
|
23
|
+
|
|
24
|
+
### Claude Desktop
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"mcpServers": {
|
|
28
|
+
"judicial-mcp": {
|
|
29
|
+
"command": "npx",
|
|
30
|
+
"args": ["-y", "judicial-mcp@latest"],
|
|
31
|
+
"env": {
|
|
32
|
+
"JUDICIAL_USER": "your_username",
|
|
33
|
+
"JUDICIAL_PASSWORD": "your_password"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 可用工具
|
|
41
|
+
|
|
42
|
+
### 裁判書開放
|
|
43
|
+
- `auth_token` - 驗證權限(服務時間:00:00~06:00)
|
|
44
|
+
- `list_judgments` - 取得裁判書異動清單
|
|
45
|
+
- `get_judgment` - 取得裁判書內容
|
|
46
|
+
|
|
47
|
+
### 開放平台
|
|
48
|
+
- `list_categories` - 取得主題分類清單
|
|
49
|
+
- `list_resources` - 取得資料源清單
|
|
50
|
+
- `download_file` - 下載資料檔案(支援分頁)
|
|
51
|
+
- `member_token` - 取得會員授權 Token
|
|
52
|
+
|
|
53
|
+
## 使用流程
|
|
54
|
+
|
|
55
|
+
### 裁判書開放查詢
|
|
56
|
+
1. `auth_token` → 驗證權限
|
|
57
|
+
2. `list_judgments` → 取得異動清單
|
|
58
|
+
3. `get_judgment` → 取得裁判書內容
|
|
59
|
+
|
|
60
|
+
### 開放平台查詢
|
|
61
|
+
1. `member_token` → 取得會員授權 Token
|
|
62
|
+
2. `list_categories` → 取得主題分類
|
|
63
|
+
3. `list_resources` → 取得資料源
|
|
64
|
+
4. `download_file` → 下載資料檔案
|
|
65
|
+
|
|
66
|
+
## 常見問題
|
|
67
|
+
|
|
68
|
+
**Q: 授權失敗**
|
|
69
|
+
A: 確認司法院帳號密碼正確,檢查環境變數設定
|
|
70
|
+
|
|
71
|
+
**Q: 服務時間限制**
|
|
72
|
+
A: `auth_token` 僅在 00:00~06:00 提供服務
|
|
73
|
+
|
|
74
|
+
**Q: 大檔案處理**
|
|
75
|
+
A: `download_file` 工具會將檔案轉為 base64 格式回傳
|
|
76
|
+
|
|
77
|
+
## 開發命令
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm start # 啟動伺服器
|
|
81
|
+
npm test # 執行測試
|
|
82
|
+
npm run lint # 程式碼檢查
|
|
83
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @jurislm/judicial-mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for [Taiwan Judicial Yuan](https://www.judicial.gov.tw) — provides 6 tools for accessing open data and judgments via natural language.
|
|
4
|
+
|
|
5
|
+
## Tools
|
|
6
|
+
|
|
7
|
+
### Authentication (1 tool)
|
|
8
|
+
- `auth_token` — Get authorization token (uses `JUDICIAL_USER` / `JUDICIAL_PASSWORD` env vars by default)
|
|
9
|
+
|
|
10
|
+
### Judgments (2 tools)
|
|
11
|
+
- `list_judgments` — Get judgment change list (requires token)
|
|
12
|
+
- `get_judgment` — Get judgment content by JID (requires token)
|
|
13
|
+
|
|
14
|
+
### Open Data (3 tools)
|
|
15
|
+
- `list_categories` — List topic categories
|
|
16
|
+
- `list_resources` — List data sources for a category (requires `categoryNo`)
|
|
17
|
+
- `download_file` — Download a data file with pagination support (requires `fileSetId`)
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
### Environment Variables
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
JUDICIAL_USER=your_username
|
|
25
|
+
JUDICIAL_PASSWORD=your_password
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Usage with Claude Code (via bunx)
|
|
29
|
+
|
|
30
|
+
Add to your MCP configuration (`.mcp.json` or `~/.claude/settings.json`):
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"judicial": {
|
|
36
|
+
"command": "bunx",
|
|
37
|
+
"args": ["@jurislm/judicial-mcp@latest"],
|
|
38
|
+
"env": {
|
|
39
|
+
"JUDICIAL_USER": "your_username",
|
|
40
|
+
"JUDICIAL_PASSWORD": "your_password"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Usage with Claude Code Plugin (jurislm-tools)
|
|
48
|
+
|
|
49
|
+
If you use the [jurislm-tools](https://github.com/jurislm/jurislm-tools) Claude Code plugin, `jt:judicial` is included:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
/plugin marketplace update jurislm-tools
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then set environment variables in `~/.zshenv`:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
export JUDICIAL_USER=your_username
|
|
59
|
+
export JUDICIAL_PASSWORD=your_password
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm install
|
|
66
|
+
npm test # Run tests
|
|
67
|
+
npm run lint # oxlint
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## License
|
|
71
|
+
|
|
72
|
+
MIT
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file __tests__/mcp.test.js
|
|
3
|
+
* @description MCP 伺服器功能測試
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { TOOLS_CONFIG, TOOL_HANDLERS } = require('../src/tools');
|
|
7
|
+
|
|
8
|
+
describe('MCP 伺服器測試', () => {
|
|
9
|
+
describe('工具配置', () => {
|
|
10
|
+
test('所有工具都有必要的屬性', () => {
|
|
11
|
+
const tools = Object.values(TOOLS_CONFIG);
|
|
12
|
+
|
|
13
|
+
tools.forEach(tool => {
|
|
14
|
+
expect(tool).toHaveProperty('name');
|
|
15
|
+
expect(tool).toHaveProperty('description');
|
|
16
|
+
expect(tool).toHaveProperty('inputSchema');
|
|
17
|
+
expect(tool.inputSchema).toHaveProperty('type');
|
|
18
|
+
expect(tool.inputSchema.type).toBe('object');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('工具名稱唯一性', () => {
|
|
23
|
+
const tools = Object.values(TOOLS_CONFIG);
|
|
24
|
+
const names = tools.map(tool => tool.name);
|
|
25
|
+
const uniqueNames = [...new Set(names)];
|
|
26
|
+
|
|
27
|
+
expect(names.length).toBe(uniqueNames.length);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('所有工具都有對應的處理器', () => {
|
|
31
|
+
const toolNames = Object.keys(TOOLS_CONFIG);
|
|
32
|
+
const handlerNames = Object.keys(TOOL_HANDLERS);
|
|
33
|
+
|
|
34
|
+
expect(toolNames.sort()).toEqual(handlerNames.sort());
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('所有工具都禁止額外屬性', () => {
|
|
38
|
+
const tools = Object.values(TOOLS_CONFIG);
|
|
39
|
+
|
|
40
|
+
tools.forEach(tool => {
|
|
41
|
+
expect(tool.inputSchema.additionalProperties).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('工具處理器', () => {
|
|
47
|
+
test('list_categories 處理器存在', () => {
|
|
48
|
+
expect(TOOL_HANDLERS.list_categories).toBeDefined();
|
|
49
|
+
expect(typeof TOOL_HANDLERS.list_categories).toBe('function');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('auth_token 處理器參數驗證', async () => {
|
|
53
|
+
// 測試缺少環境變數時的行為
|
|
54
|
+
const originalUser = process.env.JUDICIAL_USER;
|
|
55
|
+
const originalPassword = process.env.JUDICIAL_PASSWORD;
|
|
56
|
+
|
|
57
|
+
delete process.env.JUDICIAL_USER;
|
|
58
|
+
delete process.env.JUDICIAL_PASSWORD;
|
|
59
|
+
|
|
60
|
+
await expect(TOOL_HANDLERS.auth_token({}))
|
|
61
|
+
.rejects
|
|
62
|
+
.toThrow('未提供使用者帳號或密碼');
|
|
63
|
+
|
|
64
|
+
// 恢復環境變數
|
|
65
|
+
if (originalUser) process.env.JUDICIAL_USER = originalUser;
|
|
66
|
+
if (originalPassword) process.env.JUDICIAL_PASSWORD = originalPassword;
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('工具配置驗證', () => {
|
|
71
|
+
test('auth_token 工具配置正確', () => {
|
|
72
|
+
const tool = TOOLS_CONFIG.auth_token;
|
|
73
|
+
|
|
74
|
+
expect(tool.name).toBe('auth_token');
|
|
75
|
+
expect(tool.inputSchema.properties).toHaveProperty('user');
|
|
76
|
+
expect(tool.inputSchema.properties).toHaveProperty('password');
|
|
77
|
+
expect(tool.inputSchema.required).toBeUndefined(); // 因為有預設值
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('list_judgments 工具配置正確', () => {
|
|
81
|
+
const tool = TOOLS_CONFIG.list_judgments;
|
|
82
|
+
|
|
83
|
+
expect(tool.name).toBe('list_judgments');
|
|
84
|
+
expect(tool.inputSchema.properties).toHaveProperty('token');
|
|
85
|
+
expect(tool.inputSchema.required).toContain('token');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('get_judgment 工具配置正確', () => {
|
|
89
|
+
const tool = TOOLS_CONFIG.get_judgment;
|
|
90
|
+
|
|
91
|
+
expect(tool.name).toBe('get_judgment');
|
|
92
|
+
expect(tool.inputSchema.properties).toHaveProperty('token');
|
|
93
|
+
expect(tool.inputSchema.properties).toHaveProperty('jid');
|
|
94
|
+
expect(tool.inputSchema.required).toContain('token');
|
|
95
|
+
expect(tool.inputSchema.required).toContain('jid');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('download_file 工具配置正確', () => {
|
|
99
|
+
const tool = TOOLS_CONFIG.download_file;
|
|
100
|
+
|
|
101
|
+
expect(tool.name).toBe('download_file');
|
|
102
|
+
expect(tool.inputSchema.properties).toHaveProperty('fileSetId');
|
|
103
|
+
expect(tool.inputSchema.properties).toHaveProperty('top');
|
|
104
|
+
expect(tool.inputSchema.properties).toHaveProperty('skip');
|
|
105
|
+
expect(tool.inputSchema.properties).toHaveProperty('token');
|
|
106
|
+
expect(tool.inputSchema.required).toEqual(['fileSetId', 'token']);
|
|
107
|
+
expect(tool.inputSchema.properties.top.pattern).toBe('^[0-9]+$');
|
|
108
|
+
expect(tool.inputSchema.properties.skip.pattern).toBe('^[0-9]+$');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('list_categories 工具配置正確', () => {
|
|
112
|
+
const tool = TOOLS_CONFIG.list_categories;
|
|
113
|
+
|
|
114
|
+
expect(tool.name).toBe('list_categories');
|
|
115
|
+
expect(tool.inputSchema.properties).toEqual({
|
|
116
|
+
token: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: '從 member_token 工具取得的會員授權 Token'
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
expect(tool.inputSchema.required).toEqual(['token']);
|
|
122
|
+
expect(tool.inputSchema.additionalProperties).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('list_resources 工具配置正確', () => {
|
|
126
|
+
const tool = TOOLS_CONFIG.list_resources;
|
|
127
|
+
|
|
128
|
+
expect(tool.name).toBe('list_resources');
|
|
129
|
+
expect(tool.inputSchema.properties).toHaveProperty('categoryNo');
|
|
130
|
+
expect(tool.inputSchema.properties).toHaveProperty('token');
|
|
131
|
+
expect(tool.inputSchema.required).toEqual(['categoryNo', 'token']);
|
|
132
|
+
expect(tool.inputSchema.additionalProperties).toBe(false);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test('member_token 工具配置正確', () => {
|
|
136
|
+
const tool = TOOLS_CONFIG.member_token;
|
|
137
|
+
|
|
138
|
+
expect(tool.name).toBe('member_token');
|
|
139
|
+
expect(tool.inputSchema.properties).toHaveProperty('user');
|
|
140
|
+
expect(tool.inputSchema.properties).toHaveProperty('password');
|
|
141
|
+
expect(tool.inputSchema.required).toBeUndefined(); // 因為有預設值
|
|
142
|
+
expect(tool.inputSchema.additionalProperties).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|