get_english_law_text
Retrieve the full English text of Korean laws using law ID, series number, or name. Access official translations for legal research or compliance.
Instructions
[영문] 영문 법령 전문.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lawId | No | 법령ID (검색 결과에서 획득) | |
| mst | No | 법령일련번호 (MST) | |
| lawName | No | 법령명 (영문 또는 한글) | |
| apiKey | No | 법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달 |
Implementation Reference
- src/tools/english-law.ts:110-198 (handler)The actual handler function that executes the get_english_law_text tool logic. It calls the 법제처 (Korea Ministry of Legislation) API to retrieve the full English text of a law, given lawId, mst, or lawName. It parses the JSON response, extracts basic info (name, dates, ministry) and articles (up to 50), then formats and returns the text.
export async function getEnglishLawText( apiClient: LawApiClient, args: GetEnglishLawTextInput ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> { try { if (!args.lawId && !args.mst && !args.lawName) { throw new Error("lawId, mst, 또는 lawName 중 하나가 필요합니다."); } const extraParams: Record<string, string> = {}; if (args.lawId) extraParams.ID = String(args.lawId); if (args.mst) extraParams.MST = String(args.mst); if (args.lawName) extraParams.LM = String(args.lawName); const responseText = await apiClient.fetchApi({ endpoint: "lawService.do", target: "elaw", type: "JSON", extraParams, apiKey: args.apiKey, }); let data: any; try { data = JSON.parse(responseText); } catch (err) { throw new Error("Failed to parse JSON response from API"); } if (!data.ElawService) { throw new Error("영문법령을 찾을 수 없거나 응답 형식이 올바르지 않습니다."); } const law = data.ElawService; const basic = { 영문법령명: law.영문법령명 || law.법령명_영문, 한글법령명: law.한글법령명 || law.법령명_한글, 시행일자: law.시행일자, 공포일자: law.공포일자, 법령구분: law.법령구분, 소관부처: law.소관부처, }; let output = `=== ${basic.영문법령명 || "English Law"} ===\n`; output += `(${basic.한글법령명 || "N/A"})\n\n`; output += `📋 Basic Information:\n`; output += ` English Name: ${basic.영문법령명 || "N/A"}\n`; output += ` Korean Name: ${basic.한글법령명 || "N/A"}\n`; output += ` Effective Date: ${basic.시행일자 || "N/A"}\n`; output += ` Promulgation Date: ${basic.공포일자 || "N/A"}\n`; output += ` Law Type: ${basic.법령구분 || "N/A"}\n`; output += ` Competent Ministry: ${basic.소관부처 || "N/A"}\n\n`; // Extract articles from the response const articles = law.조문 || law.조문목록 || []; if (Array.isArray(articles) && articles.length > 0) { output += `📄 Articles:\n\n`; for (const article of articles.slice(0, 50)) { // Limit to first 50 articles const articleNo = article.조문번호 || article.조번호 || ""; const articleTitle = article.조문제목_영문 || article.조문제목 || ""; const articleContent = article.조문내용_영문 || article.조문내용 || ""; if (articleNo || articleTitle) { output += `Article ${articleNo}`; if (articleTitle) output += ` ${articleTitle}`; output += `\n`; } if (articleContent) { output += `${articleContent}\n\n`; } } if (articles.length > 50) { output += `\n... and ${articles.length - 50} more articles\n`; } } else if (law.법령내용_영문 || law.법령내용) { output += `📄 Content:\n${law.법령내용_영문 || law.법령내용}\n`; } return { content: [{ type: "text", text: truncateResponse(output) }] }; } catch (error) { return formatToolError(error, "get_english_law_text"); } } - src/tools/english-law.ts:101-106 (schema)Zod schema defining inputs for get_english_law_text: lawId (법령ID), mst (법령일련번호), lawName (법령명), and optional apiKey. All input fields are optional but at least one must be provided.
export const getEnglishLawTextSchema = z.object({ lawId: z.string().optional().describe("법령ID (검색 결과에서 획득)"), mst: z.string().optional().describe("법령일련번호 (MST)"), lawName: z.string().optional().describe("법령명 (영문 또는 한글)"), apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"), }); - src/tool-registry.ts:512-517 (registration)The tool registration entry: name 'get_english_law_text', description '[영문] 영문 법령 전문.', schema linked to getEnglishLawTextSchema, handler linked to getEnglishLawText function.
{ name: "get_english_law_text", description: "[영문] 영문 법령 전문.", schema: getEnglishLawTextSchema, handler: getEnglishLawText }, - src/tool-registry.ts:46-46 (registration)Import of getEnglishLawText and getEnglishLawTextSchema from the english-law.ts tool file.
import { searchEnglishLaw, searchEnglishLawSchema, getEnglishLawText, getEnglishLawTextSchema } from "./tools/english-law.js" - src/lib/tool-chain-config.ts:66-70 (helper)Tool chain configuration: links search_english_law to get_english_law_text as the detail tool, mapping lawId as the detail parameter.
search_english_law: { detailTool: "get_english_law_text", detailParam: "lawId", idRegex: /\[([^\]]+)\]/, // 영문 법령 ID는 숫자가 아닐 수 있음 },