get_historical_law
Retrieve historical Korean law texts as they existed at a specific point in time. Provide a law serial number and optional article number to get the exact legal text from that date.
Instructions
[이력] 특정 시점 연혁법령 조회.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mst | Yes | 법령일련번호 (MST) - search_historical_law 에서 획득 | |
| jo | No | 특정 조문 번호 (예: '제38조') | |
| apiKey | No | 법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달 |
Implementation Reference
- src/tools/historical-law.ts:104-155 (handler)Main handler function for get_historical_law. Fetches a specific historical law text by MST (law serial number) from the lawjosub API, with JSON/HTML fallback and response formatting.
export async function getHistoricalLaw( apiClient: LawApiClient, input: GetHistoricalLawInput ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> { try { // 법제처 lawjosub: 특정 시점(MST) 본문. JSON 또는 HTML. const extraParams: Record<string, string> = { MST: input.mst } if (input.jo) extraParams.JO = input.jo let body: string try { body = await apiClient.fetchApi({ endpoint: "lawService.do", target: "lawjosub", type: "JSON", extraParams, apiKey: input.apiKey, }) } catch { // JSON 미지원 시 HTML 폴백 body = await apiClient.fetchApi({ endpoint: "lawService.do", target: "lawjosub", type: "HTML", extraParams, apiKey: input.apiKey, }) } const text = body.trim().startsWith("{") || body.trim().startsWith("[") ? formatJsonBody(body) : stripHtml(body) if (!text || text.length < 20) { return { content: [ { type: "text", text: `[NOT_FOUND] MST=${input.mst} 본문을 가져오지 못했습니다.`, }, ], isError: true, } } return { content: [{ type: "text", text: truncateResponse(text) }], } } catch (err) { return formatToolError(err, "get_historical_law") } } - src/tools/historical-law.ts:96-100 (schema)Zod schema for get_historical_law input: mst (required), jo (optional article number), apiKey (optional).
export const getHistoricalLawSchema = z.object({ mst: z.string().describe("법령일련번호 (MST) - search_historical_law 에서 획득"), jo: z.string().optional().describe("특정 조문 번호 (예: '제38조')"), apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"), }) - src/tools/historical-law.ts:102-102 (schema)TypeScript type inferred from the Zod schema for get_historical_law input.
export type GetHistoricalLawInput = z.infer<typeof getHistoricalLawSchema> - src/tool-registry.ts:266-271 (registration)Tool registration entry mapping the name 'get_historical_law' to its schema and handler function.
{ name: "get_historical_law", description: "[이력] 특정 시점 연혁법령 조회.", schema: getHistoricalLawSchema, handler: getHistoricalLaw }, - src/tool-registry.ts:53-53 (registration)Import of getHistoricalLaw and getHistoricalLawSchema from the historical-law module.
import { getHistoricalLaw, getHistoricalLawSchema, searchHistoricalLaw, searchHistoricalLawSchema } from "./tools/historical-law.js"