law-mcp-server 0.1.3 → 0.1.4

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.
@@ -11,7 +11,7 @@ const withTimeout = async (promise, ms) => {
11
11
  clearTimeout(timer);
12
12
  }
13
13
  };
14
- const request = async (url) => {
14
+ const request = async (url, context) => {
15
15
  const res = await withTimeout(fetch(url, {
16
16
  headers: {
17
17
  "User-Agent": config.userAgent,
@@ -20,6 +20,9 @@ const request = async (url) => {
20
20
  }), config.httpTimeoutMs);
21
21
  if (!res.ok) {
22
22
  const body = await res.text();
23
+ if (res.status === 404 && context?.lawId) {
24
+ throw new Error(`Law not found for lawId "${context.lawId}". Use the official LawID (e.g., 平成十五年法律第五十七号 => H15HO57). Upstream: ${body}`);
25
+ }
23
26
  throw new Error(`Request failed ${res.status}: ${body}`);
24
27
  }
25
28
  const data = (await res.json());
@@ -36,7 +39,7 @@ export const fetchLawData = async (lawId, revisionDate) => {
36
39
  const url = new URL(`lawdata/${encodeURIComponent(lawId)}`, base);
37
40
  if (revisionDate)
38
41
  url.searchParams.set("revision", revisionDate);
39
- const data = await request(url.toString());
42
+ const data = await request(url.toString(), { lawId });
40
43
  cache.set(cacheKey, data, config.cacheTtlSeconds);
41
44
  return data;
42
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "description": "MCP server for e-Gov law API consistency checks",
6
6
  "files": [