accurlex-mcp-server 0.2.0 → 0.3.0

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  ACCURLEX_PROXY_BASE_URL=https://accurlex.com
2
2
  ACCURLEX_API_BASE_URL=https://accurlex.com/index.php
3
3
 
4
- # Fill in after running accurlex_login tool, or manually from the website.
5
- # JWT token is valid for 7 days.
4
+ # Required for all query tools (legal QA, contract review, drafting).
5
+ # Register at https://accurlex.com to get your phone-number account.
6
6
  ACCURLEX_BILLING_PHONE=
7
7
  ACCURLEX_BEARER_TOKEN=
8
8
 
package/README.md CHANGED
@@ -1,51 +1,24 @@
1
1
  # accurLex MCP Server
2
2
 
3
- accurLex 法律 AI 的 MCP 服务,支持 OpenClaw、VS Code GitHub Copilot、Claude Desktop 等 MCP 客户端。
3
+ ## Overview
4
4
 
5
- ## 快速开始
6
-
7
- ### 方式一:npx 直接运行(推荐)
8
-
9
- 无需 clone 代码,无需手动安装依赖:
10
-
11
- ```bash
12
- npx accurlex-mcp-server
13
- ```
14
-
15
- ### 方式二:全局安装
16
-
17
- ```bash
18
- npm install -g accurlex-mcp-server
19
- ```
5
+ accurLex MCP Server 是一个面向中国法律工作流的 MCP 服务,支持法律问答、合同审查、法律文书生成等能力。通过 MCP(Model Context Protocol)协议,可在 VS Code Copilot、Claude Desktop、Cursor、Windsurf、OpenClaw 等 AI 客户端中使用。
20
6
 
21
- ### 方式三:从源码运行
7
+ - **npm 包名:** `accurlex-mcp-server`
8
+ - **npm 页面:** https://www.npmjs.com/package/accurlex-mcp-server
9
+ - **官网:** https://accurlex.com
22
10
 
23
- ```bash
24
- git clone https://github.com/accurlex/accurlex-mcp-server.git
25
- cd accurlex-mcp-server
26
- npm install
27
- cp .env.example .env
28
- npm start
29
- ```
11
+ ## 前置条件
30
12
 
31
- ## 客户端配置
13
+ - **Node.js ≥ 18** — 运行 `node --version` 确认。无需 clone 代码,无需手动安装依赖。
32
14
 
33
- ### OpenClaw
15
+ ## 快速开始
34
16
 
35
- ```json
36
- {
37
- "mcpServers": {
38
- "accurlex": {
39
- "command": "npx",
40
- "args": ["accurlex-mcp-server"]
41
- }
42
- }
43
- }
44
- ```
17
+ ### 1. 配置 MCP
45
18
 
46
- ### VS Code GitHub Copilot
19
+ 根据你使用的 AI 客户端,将以下配置添加到对应位置:
47
20
 
48
- 在工作区 `.vscode/settings.json` 中添加:
21
+ **VS Code Copilot** — 在工作区**根目录**创建 `.vscode/settings.json`:
49
22
 
50
23
  ```json
51
24
  {
@@ -54,277 +27,107 @@ npm start
54
27
  "accurlex": {
55
28
  "type": "stdio",
56
29
  "command": "npx",
57
- "args": ["accurlex-mcp-server"]
30
+ "args": ["-y", "accurlex-mcp-server"],
31
+ "env": {
32
+ "ACCURLEX_PROXY_BASE_URL": "https://accurlex.com",
33
+ "ACCURLEX_API_BASE_URL": "https://accurlex.com/index.php",
34
+ "ACCURLEX_BILLING_PHONE": "你的注册手机号"
35
+ }
58
36
  }
59
37
  }
60
38
  }
61
39
  }
62
40
  ```
63
41
 
64
- ### Claude Desktop
65
-
66
- 编辑 `%APPDATA%\Claude\claude_desktop_config.json`(Windows)或 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS):
67
-
68
- ```json
69
- {
70
- "mcpServers": {
71
- "accurlex": {
72
- "command": "npx",
73
- "args": ["accurlex-mcp-server"]
74
- }
75
- }
76
- }
77
- ```
78
-
79
- ## 登录认证
80
-
81
- ### 方式一:使用 `accurlex_login` 工具(推荐)
82
-
83
- 连接 MCP 服务后,在 AI 客户端中说:
84
-
85
- > "帮我登录 accurLex,手机号 138xxxx1234,密码 xxx"
86
-
87
- 工具会返回 JWT token,按提示保存到 `.env` 文件,然后重启 AI 客户端即可。
88
-
89
- ### 方式二:手动配置
90
-
91
- 1. 在 https://accurlex.com 登录
92
- 2. 打开浏览器开发者工具 → Application → localStorage → 复制 `al_jwt` 值
93
- 3. 填入 `.env`:
94
-
95
- ```env
96
- ACCURLEX_BILLING_PHONE=你的手机号
97
- ACCURLEX_BEARER_TOKEN=你的JWT令牌
98
- ```
99
-
100
- JWT 令牌有效期 **7 天**,过期后需重新登录获取。
101
-
102
- ## 可用工具
103
-
104
- | 工具 | 功能 | 计费 |
105
- |------|------|------|
106
- | `accurlex_login` | 手机号+密码登录,返回 JWT 令牌 | 免费 |
107
- | `accurlex_legal_qa` | 中国法律问答(deep 免费 / expert 付费) | deep=免费, expert=扣点 |
108
- | `accurlex_contract_review` | 合同审查 → 审查意见书(仅 normal 模式) | 扣点 |
109
- | `accurlex_draft_document` | 法律文书生成(起诉状/答辩状/代理词等) | 扣点 |
110
- | `accurlex_get_account_status` | 查询账户点数余额 | 免费 |
111
- | `accurlex_extract_text_from_file` | 提取本地纯文本文件内容 | 免费 |
112
-
113
- ## 输入限制(与网站对齐)
114
-
115
- - 法律问答问题:**10,000 字**
116
- - 合同审查:合同文本 + 立场合计 **10,000 字**
117
- - 文书生成事实描述:**10,000 字**
118
- - 审查人姓名:**40 字**
119
-
120
- ## 环境变量
121
-
122
- | 变量 | 必填 | 说明 |
123
- |------|------|------|
124
- | `ACCURLEX_PROXY_BASE_URL` | 是 | 流式 API 地址(默认 `https://accurlex.com`) |
125
- | `ACCURLEX_API_BASE_URL` | 是 | PHP API 地址(默认 `https://accurlex.com/index.php`) |
126
- | `ACCURLEX_BILLING_PHONE` | 付费工具需要 | 计费手机号 |
127
- | `ACCURLEX_BEARER_TOKEN` | 账户查询需要 | 登录后获取的 JWT 令牌 |
128
- | `ACCURLEX_REQUEST_TIMEOUT_MS` | 否 | 请求超时毫秒数(默认 600000 = 10 分钟) |
129
-
130
- ## 当前限制
131
-
132
- - 单账户模式(凭证来自 `.env`)
133
- - 文件提取仅支持纯文本:`.txt`、`.md`、`.json`、`.csv`、`.text`
134
- - 合同审查仅支持 normal 模式(审查意见书),不支持修订版
135
- - 不支持 DOCX、PDF、图片 OCR(请使用网站处理这些格式)
136
-
137
- ## 常见问题
138
-
139
- ### PowerShell 编码问题
140
-
141
- 通过 PowerShell 管道手动测试时,中文字符可能被破坏。这**不影响**正常使用(VS Code、OpenClaw、Claude Desktop 均正确处理 UTF-8)。
142
-
143
- 如需命令行测试,先将 JSON 写入 UTF-8 文件:
144
-
145
- ```powershell
146
- [System.IO.File]::WriteAllText("test.jsonl", $jsonContent, [System.Text.Encoding]::UTF8)
147
- Get-Content test.jsonl -Encoding UTF8 | node src/index.js
148
- ```
149
-
150
- ### "tool_unavailable" 错误
151
-
152
- 缺少 `.env` 配置。确保 `ACCURLEX_PROXY_BASE_URL` 和 `ACCURLEX_API_BASE_URL` 已设置。付费工具还需要 `ACCURLEX_BILLING_PHONE`。
153
-
154
- ### "insufficient_balance"(HTTP 402)
155
-
156
- 账户点数不足,请到 https://accurlex.com 充值。
157
-
158
- ### JWT 令牌过期
159
-
160
- 重新调用 `accurlex_login` 获取新令牌,更新 `.env` 后重启即可。
161
-
162
- ---
163
-
164
- # accurLex MCP Server (English)
165
-
166
- Node.js MCP server that exposes accurLex legal capabilities as MCP tools.
167
- Designed for use with OpenClaw, VS Code GitHub Copilot, Claude Desktop, or any MCP-compatible AI client.
168
-
169
- ## Quick Start
170
-
171
- ### Option A: npx (recommended)
172
-
173
- ```bash
174
- npx accurlex-mcp-server
175
- ```
176
-
177
- ### Option B: Global install
178
-
179
- ```bash
180
- npm install -g accurlex-mcp-server
181
- ```
182
-
183
- ### Option C: From source
184
-
185
- ```bash
186
- git clone https://github.com/accurlex/accurlex-mcp-server.git
187
- cd accurlex-mcp-server
188
- npm install
189
- cp .env.example .env
190
- npm start
191
- ```
192
-
193
- ## Configuration
194
-
195
- ### For OpenClaw
42
+ **Claude Desktop** — 编辑 `%APPDATA%\Claude\claude_desktop_config.json`(Windows)或 `~/Library/Application Support/Claude/claude_desktop_config.json`(macOS):
196
43
 
197
44
  ```json
198
45
  {
199
46
  "mcpServers": {
200
47
  "accurlex": {
201
48
  "command": "npx",
202
- "args": ["accurlex-mcp-server"]
203
- }
204
- }
205
- }
206
- ```
207
-
208
- ### For VS Code GitHub Copilot
209
-
210
- Add to your workspace `.vscode/settings.json`:
211
-
212
- ```json
213
- {
214
- "mcp": {
215
- "servers": {
216
- "accurlex": {
217
- "type": "stdio",
218
- "command": "npx",
219
- "args": ["accurlex-mcp-server"]
49
+ "args": ["-y", "accurlex-mcp-server"],
50
+ "env": {
51
+ "ACCURLEX_PROXY_BASE_URL": "https://accurlex.com",
52
+ "ACCURLEX_API_BASE_URL": "https://accurlex.com/index.php",
53
+ "ACCURLEX_BILLING_PHONE": "你的注册手机号"
220
54
  }
221
55
  }
222
56
  }
223
57
  }
224
- ```
225
-
226
- ### For Claude Desktop
227
-
228
- Edit `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
229
-
230
- ```json
231
- {
232
- "mcpServers": {
233
- "accurlex": {
234
- "command": "npx",
235
- "args": ["accurlex-mcp-server"]
58
+ "ACCURLEX_API_BASE_URL": "https://accurlex.com/index.php"
59
+ }
236
60
  }
237
61
  }
238
62
  }
239
63
  ```
240
64
 
241
- ## Authentication
65
+ **Cursor** — 在项目根目录创建 `.cursor/mcp.json`,格式同 Claude Desktop。
242
66
 
243
- Two ways to authenticate:
67
+ **Windsurf** 在项目根目录创建 `.windsurf/mcp.json`,格式同 Claude Desktop。
244
68
 
245
- ### Option A: Use the `accurlex_login` tool (recommended)
69
+ **OpenClaw** 使用与 Claude Desktop 相同的 stdio MCP 配置结构。
246
70
 
247
- After connecting the MCP server, ask the AI client:
71
+ > ⚠️ **Windows 上如果遇到 `npx` 找不到的问题,将 `"command"` 改为 `"npx.cmd"`。**
248
72
 
249
- > "帮我登录 accurLex,手机号 138xxxx1234,密码 xxx"
250
-
251
- The tool will return a JWT token and instructions to save it in `.env`. Then restart the MCP server (reload the AI client window).
73
+ ### 2. 重启客户端
252
74
 
253
- ### Option B: Manual configuration
75
+ - VS Code:`Ctrl+Shift+P` → `Developer: Reload Window`
76
+ - Claude Desktop:完全退出并重新打开
77
+ - Cursor / Windsurf:重启编辑器
254
78
 
255
- 1. Login at https://accurlex.com
256
- 2. Open browser DevTools → Application → localStorage → copy `al_jwt` value
257
- 3. Fill in `.env`:
79
+ ### 3. 验证安装
258
80
 
259
- ```env
260
- ACCURLEX_BILLING_PHONE=your_phone_number
261
- ACCURLEX_BEARER_TOKEN=your_jwt_token
262
- ```
81
+ 在 AI 对话中发送以下消息测试(免费配额,需已配置 `ACCURLEX_BILLING_PHONE`):
263
82
 
264
- JWT tokens are valid for **7 days**. After expiry, re-login to get a new token.
83
+ > "劳动合同试用期最长不能超过多久?"
265
84
 
266
- ## Implemented Tools
85
+ 如果 AI 调用了 `accurlex_legal_qa` 工具并返回了法律分析,说明安装成功。
267
86
 
268
- | Tool | Description | Billing |
269
- |------|-------------|---------|
270
- | `accurlex_login` | Login with phone + password, returns JWT | free |
271
- | `accurlex_legal_qa` | Chinese-law legal Q&A (deep free / expert paid) | deep=free, expert=paid |
272
- | `accurlex_contract_review` | Contract review → 审查意见书 (normal mode only) | paid |
273
- | `accurlex_draft_document` | Draft legal documents (起诉状/答辩状/代理词 etc.) | paid |
274
- | `accurlex_get_account_status` | Query account and point balances | free |
275
- | `accurlex_extract_text_from_file` | Extract text from local plaintext files | free |
87
+ ### 4. 配置登录信息(账户查询、付费功能)
276
88
 
277
- ## Input Limits (aligned with website)
89
+ 使用前,请先到 https://accurlex.com 注册账号,将手机号填入客户端配置的 `ACCURLEX_BILLING_PHONE` 字段。
278
90
 
279
- - Legal QA question: **10,000 chars** max
280
- - Contract review: contract text + standpoint combined **10,000 chars** max
281
- - Draft document facts: **10,000 chars** max
282
- - Reviewer name: **40 chars** max
91
+ 如果需要账户查询,可在 AI 对话中说:
283
92
 
284
- ## Environment Variables
285
-
286
- | Variable | Required | Description |
287
- |----------|----------|-------------|
288
- | `ACCURLEX_PROXY_BASE_URL` | Yes | Streaming API base URL (default: `https://accurlex.com`) |
289
- | `ACCURLEX_API_BASE_URL` | Yes | PHP API base URL (default: `https://accurlex.com/index.php`) |
290
- | `ACCURLEX_BILLING_PHONE` | For paid tools | Phone number for billing identity |
291
- | `ACCURLEX_BEARER_TOKEN` | For account status | JWT token from login |
292
- | `ACCURLEX_REQUEST_TIMEOUT_MS` | No | Request timeout in ms (default: 600000) |
293
-
294
- ## Current Limitations
295
-
296
- - Single-account per server instance (credentials from `.env`)
297
- - Local file extraction supports plaintext only: `.txt`, `.md`, `.json`, `.csv`, `.text`
298
- - Contract review only supports normal mode (审查意见书), revision mode is not available
299
- - DOCX, PDF, image OCR are not supported (use the website for these)
93
+ > "帮我登录 accurLex,手机号 138xxxx1234,密码 xxx"
300
94
 
301
- ## Troubleshooting
95
+ 登录成功后,将返回的 `ACCURLEX_BEARER_TOKEN` 添加到客户端配置的 `env` 字段中,然后重启客户端。
302
96
 
303
- ### PowerShell encoding issues
97
+ 说明:
304
98
 
305
- When testing via PowerShell stdin pipe, Chinese characters may get corrupted. This only affects manual CLI testing — it does **not** affect normal MCP client usage (VS Code, OpenClaw, Claude Desktop all handle UTF-8 correctly).
99
+ - `ACCURLEX_BILLING_PHONE` 是注册手机号,所有工具(login/extract 除外)均需要
100
+ - `ACCURLEX_BEARER_TOKEN` 是 JWT 令牌,`accurlex_get_account_status` 需要
306
101
 
307
- If you must test via CLI, write the JSON-RPC input to a UTF-8 file first:
102
+ ## 可用功能
308
103
 
309
- ```powershell
310
- [System.IO.File]::WriteAllText("test.jsonl", $jsonContent, [System.Text.Encoding]::UTF8)
311
- Get-Content test.jsonl -Encoding UTF8 | node src/index.js
312
- ```
104
+ | 功能 | 工具名 | 计费 | 预期耗时 |
105
+ |------|--------|------|---------|
106
+ | 法律问答(免费配额,需注册) | `accurlex_legal_qa` (deep) | 免费 | 10-30 秒 |
107
+ | 法律问答(专业) | `accurlex_legal_qa` (expert) | 扣点 | 10-30 秒 |
108
+ | 合同审查 | `accurlex_contract_review` | 扣点 | 1-3 分钟 |
109
+ | 法律文书生成 | `accurlex_draft_document` | 扣点 | 1-2 分钟 |
110
+ | 查询账户余额 | `accurlex_get_account_status` | 免费 | 1-3 秒 |
111
+ | 提取文件文本 | `accurlex_extract_text_from_file` | 免费 | <1 秒 |
313
112
 
314
- ### "tool_unavailable" errors
113
+ ## 详细文档
315
114
 
316
- Missing `.env` configuration. Ensure `ACCURLEX_PROXY_BASE_URL` and `ACCURLEX_API_BASE_URL` are set. For paid tools, also set `ACCURLEX_BILLING_PHONE`.
115
+ 完整的工具参数、工作流、错误处理和平台特定的故障排查指南,请参阅 [.github/skills/accurlex-legal-assistant/SKILL.md](../.github/skills/accurlex-legal-assistant/SKILL.md)。
317
116
 
318
- ### "insufficient_balance" (HTTP 402)
117
+ ## 常见问题
319
118
 
320
- Your account has insufficient points. Top up at https://accurlex.com.
119
+ | 问题 | 解决方案 |
120
+ |------|---------|
121
+ | 工具未出现在 AI 对话中 | 确认配置文件路径正确(VS Code 必须在工作区**根目录**的 `.vscode/settings.json`),然后重启客户端 |
122
+ | `tool_unavailable` 错误 | 环境变量未设置,检查 `env` 字段中的 `ACCURLEX_PROXY_BASE_URL`、`ACCURLEX_API_BASE_URL`、`ACCURLEX_BILLING_PHONE` |
123
+ | `ENOENT` / `npx` 找不到 | Node.js 未安装或未在 PATH 中,Windows 上尝试将 `command` 改为 `npx.cmd` |
124
+ | 合同审查“超时” | 合同审查正常需要 1-3 分钟,请耐心等待 |
125
+ | JWT 令牌过期 | 重新调用 `accurlex_login`,更新配置中的 `ACCURLEX_BEARER_TOKEN`,重启客户端 |
321
126
 
322
- ### JWT token expired
127
+ ## Contributing
323
128
 
324
- Re-run `accurlex_login` to get a new token, then update `.env` and restart.
129
+ Contributions are welcome. Please follow the standard Git workflow.
325
130
 
326
- ## Suggested Next Steps
131
+ ## License
327
132
 
328
- 1. Add OAuth or SMS-based login tool for seamless credential setup
329
- 2. Add file upload handling for DOCX, PDF, and OCR workflows
330
- 3. Replace env-bound billing identity with per-user auth for multi-user support
133
+ MIT License. See the LICENSE file for more details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accurlex-mcp-server",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "MCP server for accurLex Chinese legal AI — legal Q&A, contract review, law lookup, document drafting",
6
6
  "keywords": ["mcp", "legal", "chinese-law", "contract-review", "accurlex", "ai"],
@@ -9,7 +9,7 @@
9
9
  "homepage": "https://accurlex.com",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/accurlex/accurlex-mcp-server"
12
+ "url": "git+https://github.com/MrPunchLeoanrdo/accurlex-mcp-server.git"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=18"
package/src/index.js CHANGED
@@ -46,7 +46,7 @@ const tools = [
46
46
  type: 'string',
47
47
  enum: ['deep', 'expert'],
48
48
  default: 'deep',
49
- description: 'deep is free/basic mode. expert is paid mode.',
49
+ description: 'deep = free query quota, requires registered account (ACCURLEX_BILLING_PHONE). expert = paid mode, costs points.',
50
50
  },
51
51
  history: {
52
52
  type: 'array',
@@ -185,11 +185,8 @@ async function handleLegalQa(args) {
185
185
  stream: true,
186
186
  };
187
187
 
188
- const headers = { 'Content-Type': 'application/json' };
189
- if (mode === 'expert') {
190
- assertConfigured(BILLING_PHONE, 'ACCURLEX_BILLING_PHONE is required for expert mode');
191
- headers['X-Billing-Phone'] = BILLING_PHONE;
192
- }
188
+ assertConfigured(BILLING_PHONE, 'ACCURLEX_BILLING_PHONE is required. Register at https://accurlex.com to get your account.');
189
+ const headers = { 'Content-Type': 'application/json', 'X-Billing-Phone': BILLING_PHONE };
193
190
 
194
191
  const rawText = await postJsonToRoute(route, payload, headers);
195
192
  const events = extractAccurlexEvents(rawText);
@@ -312,7 +309,7 @@ async function handleGetAccountStatus() {
312
309
  res_point: toInt(user.res_point),
313
310
  vip_point: toInt(user.vip_point),
314
311
  capabilities: {
315
- deep_qa: true,
312
+ deep_qa: Boolean(BILLING_PHONE),
316
313
  expert_qa: Boolean(BILLING_PHONE),
317
314
  contract_review: Boolean(BILLING_PHONE),
318
315
  draft_document: Boolean(BILLING_PHONE),