get_article_with_precedents
Retrieve a Korean law article and its associated precedents simultaneously using the article number and law details.
Instructions
[통합] 조문 + 관련 판례 동시 조회.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mst | No | 법령일련번호 (search_law에서 획득) | |
| lawId | No | 법령ID (search_law에서 획득) | |
| jo | Yes | 조문 번호 (예: '제38조') | |
| efYd | No | 시행일자 (YYYYMMDD 형식) | |
| includePrecedents | Yes | 관련 판례 포함 여부 | |
| apiKey | No | 법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달 |
Implementation Reference
- The main handler function `getArticleWithPrecedents`. It calls `getLawText` to fetch the article, extracts the law name from the result, then calls `searchPrecedents` to find related precedents. Returns combined content with article text + up to 5 related precedents.
export async function getArticleWithPrecedents( apiClient: LawApiClient, input: GetArticleWithPrecedentsInput ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> { try { // 1. 조문 조회 const articleResult = await getLawText(apiClient, { mst: input.mst, lawId: input.lawId, jo: input.jo, efYd: input.efYd, apiKey: input.apiKey } as GetLawTextInput) if (articleResult.isError || !input.includePrecedents) { return articleResult } let resultText = articleResult.content[0].text // 2. 법령명 추출 (조문 결과에서) const lawNameMatch = resultText.match(/법령명: (.+?)\n/) if (!lawNameMatch) { return articleResult // 법령명을 찾을 수 없으면 조문만 반환 } const lawName = lawNameMatch[1].trim() // 3. 관련 판례 검색 const precedentQuery = `${lawName} ${input.jo}` try { const precedentResult = await searchPrecedents(apiClient, { query: precedentQuery, display: 5, page: 1, apiKey: input.apiKey }) if (!precedentResult.isError) { const precedentText = precedentResult.content[0].text // 판례 결과가 있으면 추가 if (precedentText && !precedentText.includes("검색 결과가 없습니다")) { resultText += `\n${"=".repeat(60)}\n` resultText += `\n📚 관련 판례 (상위 5건)\n\n` resultText += precedentText resultText += `\n💡 판례 전문을 보려면 get_precedent_text Tool을 사용하세요.` } else { resultText += `\n\n📚 관련 판례: 검색 결과 없음` } } } catch (error) { // 판례 검색 실패는 무시하고 조문 내용만 반환 // 판례 검색 실패는 무시 (조문 내용만 반환) } return { content: [{ type: "text", text: resultText }] } } catch (error) { return formatToolError(error, "get_article_with_precedents") } } - Zod schema `GetArticleWithPrecedentsSchema` defining input params: mst (optional), lawId (optional), jo (required), efYd (optional), includePrecedents (default true), apiKey (optional). Requires either mst or lawId via refine.
export const GetArticleWithPrecedentsSchema = z.object({ mst: z.string().optional().describe("법령일련번호 (search_law에서 획득)"), lawId: z.string().optional().describe("법령ID (search_law에서 획득)"), jo: z.string().describe("조문 번호 (예: '제38조')"), efYd: z.string().optional().describe("시행일자 (YYYYMMDD 형식)"), includePrecedents: z.boolean().optional().default(true).describe("관련 판례 포함 여부"), apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달") }).refine(data => data.mst || data.lawId, { message: "mst 또는 lawId 중 하나는 필수입니다" }) export type GetArticleWithPrecedentsInput = z.infer<typeof GetArticleWithPrecedentsSchema> - src/tool-registry.ts:596-601 (registration)Tool registration in the registry: name 'get_article_with_precedents', description '[통합] 조문 + 관련 판례 동시 조회.', references GetArticleWithPrecedentsSchema and getArticleWithPrecedents handler.
{ name: "get_article_with_precedents", description: "[통합] 조문 + 관련 판례 동시 조회.", schema: GetArticleWithPrecedentsSchema, handler: getArticleWithPrecedents }, - src/tool-registry.ts:31-31 (registration)Import statement importing the handler and schema from src/tools/article-with-precedents.ts into the registry.
import { getArticleWithPrecedents, GetArticleWithPrecedentsSchema } from "./tools/article-with-precedents.js" - Type alias `GetArticleWithPrecedentsInput` inferred from the Zod schema.
export type GetArticleWithPrecedentsInput = z.infer<typeof GetArticleWithPrecedentsSchema> export async function getArticleWithPrecedents( apiClient: LawApiClient, input: GetArticleWithPrecedentsInput