get_interpretation_text
Retrieve the full text of a Korean legal interpretation consultation, including the query, official answer, and detailed reasoning, to verify how PIPA provisions are applied.
Instructions
법령해석례 본문 (법제처 lawService · target=expc). 안건명·질의요지·회답·이유 + 질의/해석기관 추출. PIPA 조문 적용 의문 시 법제처·부처가 회신한 공식 해석 직접 확인. 긴 이유는 자동 축약. 다음: search_interpretations로 유사 해석례, get_law_text로 인용 조문 확인.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 법령해석례 일련번호 (search_interpretations 결과의 [id=N]) |
Implementation Reference
- The async handler that executes the tool logic: fetches interpretation text from lawService.do (target=expc) using the provided ID, parses JSON, formats fields (title, agency, date, question, answer, reasoning), appends suggestions, and returns formatted text with source URL.
async handler(args, client) { try { const jsonText = await client.fetchApi({ endpoint: "lawService.do", target: "expc", type: "JSON", extraParams: { ID: args.id }, }); let parsed: { ExpcService?: InterpretationData; Law?: string }; try { parsed = JSON.parse(jsonText); } catch { return notFoundResponse(`법령해석례 응답 파싱 실패 (id=${args.id})`, [ `search_interpretations(query="...") — 유효한 id 확인`, ]); } if (typeof parsed.Law === "string") { return notFoundResponse(`법령해석례 없음: ${parsed.Law}`, [ `search_interpretations(query="...") — 유효한 id 확인`, ]); } const interp = parsed.ExpcService; if (!interp) { return notFoundResponse(`법령해석례 데이터 없음 (id=${args.id})`, [ `search_interpretations(query="...") — 유효한 id 확인`, ]); } const title = interp.안건명 ?? "(안건명 없음)"; let text = `=== ${title} ===\n`; if (interp.안건번호) text += `안건번호: ${interp.안건번호}\n`; if (interp.질의기관명) text += `질의기관: ${interp.질의기관명}\n`; if (interp.해석기관명) text += `회신기관: ${interp.해석기관명}\n`; if (interp.해석일자) text += `회신일: ${interp.해석일자}\n`; if (interp.법령해석례일련번호) text += `해석례ID: ${interp.법령해석례일련번호}\n`; // 핵심 본문 — 질의요지 → 회답 → 이유 순 text += formatField("질의요지", interp.질의요지); text += formatField("회답", interp.회답); text += formatField("이유", interp.이유); text = appendSuggestions(text, [ { tool: "search_interpretations", args: { query: title.slice(0, 20) }, reason: "유사 법령해석례 검색", }, ]); text += `\n📎 출처: 법령해석례 (id=${args.id}) — ${interpretationUrl(args.id)}`; return { content: [{ type: "text", text }] }; } catch (err) { return formatToolError(err, "get_interpretation_text"); } }, }; - Zod input schema: requires a non-empty string 'id' (the interpretation serial number from search_interpretations).
const inputSchema = z.object({ id: z .string() .min(1) .describe("법령해석례 일련번호 (search_interpretations 결과의 [id=N])"), }); - src/tools/registry.ts:22-67 (registration)Import and registration of getInterpretationText in the ALL_TOOLS array (line 22 import, line 67 in the array).
import { getInterpretationText } from "./primitives/get-interpretation-text.js"; import { getEnglishLawText } from "./primitives/get-english-law-text.js"; import { compareAdminRuleOldNew } from "./primitives/compare-admin-rule-old-new.js"; import { getLawHistory } from "./primitives/get-law-history.js"; import { getHistoricalLaw } from "./primitives/get-historical-law.js"; import { compareOldNew } from "./primitives/compare-old-new.js"; import { getThreeTier } from "./primitives/get-three-tier.js"; import { getArticleChangeHistory } from "./primitives/get-article-change-history.js"; import { getDelegatedLaws } from "./primitives/get-delegated-laws.js"; import { getLawSystemTree } from "./primitives/get-law-system-tree.js"; import { getIntelligentRelatedLaws } from "./primitives/get-intelligent-related-laws.js"; import { compareArticles } from "./primitives/compare-articles.js"; import { getLegalTerm } from "./primitives/get-legal-term.js"; import { getTermArticles } from "./primitives/get-term-articles.js"; import { getLawAbbreviations } from "./primitives/get-law-abbreviations.js"; import { getLawTree } from "./primitives/get-law-tree.js"; // W3 — Layer C corpus import { searchPrivacyCorpus } from "./corpus/search-privacy-corpus.js"; import { searchPrivacyCases } from "./corpus/search-privacy-cases.js"; import { searchPrivacyGuides } from "./corpus/search-privacy-guides.js"; // W3 — Layer B+ hints (PIPC 공식 출처 인덱스화) import { getSectoralRelatedLaws } from "./hints/get-sectoral-related-laws.js"; import { getPipcCuratedCorpus } from "./hints/get-pipc-curated-corpus.js"; // W4 — Validator (4계층 환각 검증) import { verifyPipaCitation } from "./validator/verify-pipa-citation.js"; export const ALL_TOOLS: Tool[] = [ // W1.5 searchLaw, getLawText, intelligentLawSearch, getRelatedLaws, getAnnexes, // W2 — search primitives (admin rule + decisions + interpretations + english) searchAdminRule, searchPipcDecisions, searchConstitutionalDecisions, searchAdminAppeals, searchInterpretations, searchEnglishLaw, // W2 — get text primitives getAdminRuleText, getPipcDecisionText, getConstitutionalDecisionText, getAdminAppealText, getInterpretationText, - formatField helper: strips HTML tags, optionally compacts long text (over 2500 chars), and formats with label.
function formatField(label: string, value: string | undefined): string { if (!value) return ""; const cleaned = stripHtmlTags(value); if (!cleaned) return ""; const compacted = cleaned.length > FIELD_COMPACT_THRESHOLD ? compactBody(cleaned, { headLimit: 1500, tailLimit: 800, minLength: FIELD_COMPACT_THRESHOLD, }) : cleaned; return `\n[${label}]\n${compacted}\n`; } - InterpretationData interface: defines the shape of the parsed API response fields.
interface InterpretationData { 법령해석례일련번호?: string; 안건명?: string; 안건번호?: string; 질의기관명?: string; 질의기관코드?: string; 해석기관명?: string; 해석기관코드?: string; 해석일자?: string; 등록일시?: string; 질의요지?: string; 회답?: string; 이유?: string; }