law-mcp-server 0.1.5 → 0.1.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/dist/lawApi.js +19 -3
- package/dist/src/index.js +1 -1
- package/dist/src/lawApi.js +20 -3
- package/package.json +1 -1
package/dist/lawApi.js
CHANGED
|
@@ -40,7 +40,23 @@ export const fetchLawData = async (lawId, revisionDate) => {
|
|
|
40
40
|
};
|
|
41
41
|
export const searchLaws = async (keyword) => {
|
|
42
42
|
const base = config.apiBase.endsWith("/") ? config.apiBase : `${config.apiBase}/`;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const queryUrl = new URL(`lawsearch`, base);
|
|
44
|
+
queryUrl.searchParams.set("keyword", keyword);
|
|
45
|
+
try {
|
|
46
|
+
return await request(queryUrl.toString());
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
50
|
+
if (message.includes("404")) {
|
|
51
|
+
const pathUrl = new URL(`lawsearch/${encodeURIComponent(keyword)}`, base);
|
|
52
|
+
try {
|
|
53
|
+
return await request(pathUrl.toString());
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
57
|
+
throw new Error(`Law search failed for keyword "${keyword}". Tried query and path styles. Upstream: ${msg}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
46
62
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { StdioJsonRpcServer } from "./mcp.js";
|
|
3
3
|
import { tools, resolveTool } from "./tools.js";
|
|
4
4
|
const server = new StdioJsonRpcServer();
|
|
5
|
-
const serverInfo = { name: "law-mcp-server", version: "0.1.
|
|
5
|
+
const serverInfo = { name: "law-mcp-server", version: "0.1.5" };
|
|
6
6
|
server.register("initialize", async (params) => {
|
|
7
7
|
const payload = (params ?? {});
|
|
8
8
|
const protocolVersion = typeof payload.protocolVersion === "string"
|
package/dist/src/lawApi.js
CHANGED
|
@@ -47,7 +47,24 @@ export const searchLaws = async (keyword) => {
|
|
|
47
47
|
const base = config.apiBase.endsWith("/")
|
|
48
48
|
? config.apiBase
|
|
49
49
|
: `${config.apiBase}/`;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const queryUrl = new URL(`lawsearch`, base);
|
|
51
|
+
queryUrl.searchParams.set("keyword", keyword);
|
|
52
|
+
try {
|
|
53
|
+
return await request(queryUrl.toString());
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
if (message.includes("404")) {
|
|
58
|
+
// Some deployments expect the keyword in the path; retry once
|
|
59
|
+
const pathUrl = new URL(`lawsearch/${encodeURIComponent(keyword)}`, base);
|
|
60
|
+
try {
|
|
61
|
+
return await request(pathUrl.toString());
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
65
|
+
throw new Error(`Law search failed for keyword "${keyword}". Tried query and path styles. Upstream: ${msg}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
53
70
|
};
|