korean-law-mcp 4.6.2 → 4.6.3

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.
@@ -9,6 +9,7 @@ import { formatToolError, noResultHint } from "../lib/errors.js";
9
9
  import { expandLawQuery, normalizeAliasKey, resolveLawAlias } from "../lib/search-normalizer.js";
10
10
  import { buildUpcomingNotes, fetchUpcomingLaws } from "../lib/upcoming-laws.js";
11
11
  import { searchAdminRule } from "./admin-rule.js";
12
+ import { searchOrdinance } from "./ordinance-search.js";
12
13
  export const SearchLawSchema = z.object({
13
14
  query: z.string().describe("검색할 법령명 (예: '관세법', 'fta특례법', '화관법')"),
14
15
  display: z.number().optional().default(50).describe("최대 결과 개수 (기본 50 — 짧은 법령명 정확매칭 누락 방지)"),
@@ -33,6 +34,13 @@ function parseLawsXml(xmlText) {
33
34
  }
34
35
  return out;
35
36
  }
37
+ // '광진구 복무 조례'처럼 조례 키워드나 지역명 토큰(○○시/군/구)이 있으면 자치법규 쿼리로 판단.
38
+ // '도'는 도로법·양도세 등 오탐이 많아 제외. 토큰 3자 미만('구', '시')도 제외.
39
+ function looksLikeOrdinanceQuery(query) {
40
+ if (query.includes("조례"))
41
+ return true;
42
+ return query.split(/\s+/).some((t) => t.length >= 3 && /[시군구]$/.test(t));
43
+ }
36
44
  function formatHit(idx, h) {
37
45
  const status = h.statusCode === "연혁" ? " ⚠️[연혁-과거버전]" : h.statusCode === "현행" ? " [현행]" : "";
38
46
  let line = `${idx}. ${h.name}${status}\n - 법령ID: ${h.lawId}\n - MST: ${h.mst}\n - 공포일: ${h.promDate}`;
@@ -95,6 +103,23 @@ export async function searchLaw(apiClient, input) {
95
103
  content: [{ type: "text", text: truncateResponse(prefix + text) }],
96
104
  };
97
105
  }
106
+ // Fallback: 조례·규칙(지자체)은 자치법규라 국가법령 검색에 안 잡힘.
107
+ // 쿼리가 자치법규 형태면 search_ordinance 자동 시도.
108
+ if (looksLikeOrdinanceQuery(input.query)) {
109
+ const ordinFallback = await searchOrdinance(apiClient, {
110
+ query: input.query,
111
+ display: Math.min(input.display, 100),
112
+ apiKey: input.apiKey,
113
+ }).catch(() => null);
114
+ if (ordinFallback && !ordinFallback.isError) {
115
+ const text = ordinFallback.content[0]?.text || "";
116
+ const prefix = `[FALLBACK] 법령 '${input.query}' 0건 → 자치법규로 자동 폴백.\n` +
117
+ `💡 조례·규칙(지자체)은 자치법규이며 search_ordinance(execute_tool 경유)가 본 도구입니다.\n\n`;
118
+ return {
119
+ content: [{ type: "text", text: truncateResponse(prefix + text) }],
120
+ };
121
+ }
122
+ }
98
123
  return noResultHint(input.query, "법령");
99
124
  }
100
125
  // 정확매칭 분리: 법제처 API는 LIKE 검색 + 가나다순 정렬이라
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korean-law-mcp",
3
- "version": "4.6.2",
3
+ "version": "4.6.3",
4
4
  "description": "법제처 42개 API → 9개 MCP 도구. 법령·판례·조례·조약 + 다단계 리서치(legal_research, 8 task) + 정밀분석(legal_analysis: 인용검증·판례생사·행위시법·영향그래프) + 시점 비교(time_travel) + 상황별 5단계 안내(action_plan) + 국세청 해석례(nts)",
5
5
  "type": "module",
6
6
  "main": "build/index.js",