get_customs_interpretation_text
Retrieve the full text of a Korean customs interpretation by its serial number, including the query, answer, reasoning, and related statutes.
Instructions
[관세] 관세 해석례 전문 조회. 질의요지·회답·이유·관련법령 포함.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Customs interpretation serial number (법령해석일련번호) from search results | |
| interpretationName | No | Interpretation name (optional, for verification) | |
| apiKey | No | 법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달 |
Implementation Reference
- Main handler function that fetches the full text of a customs interpretation by serial number (ID) from the Law API. Parses the JSON response and formats it with basic info, question summary, reply, reasoning, related laws, and original document link.
export async function getCustomsInterpretationText( apiClient: LawApiClient, args: GetCustomsInterpretationTextInput ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> { try { const extraParams: Record<string, string> = { ID: args.id }; if (args.interpretationName) extraParams.LM = args.interpretationName; const responseText = await apiClient.fetchApi({ endpoint: "lawService.do", target: "kcsCgmExpc", 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.CgmExpcService) { throw new Error("Customs interpretation not found or invalid response format"); } const expc = data.CgmExpcService; const basic = { 안건명: expc.안건명, 법령해석일련번호: expc.법령해석일련번호, 업무분야: expc.업무분야, 해석일자: expc.해석일자, 해석기관명: expc.해석기관명, 질의기관명: expc.질의기관명, 등록일시: expc.등록일시 }; const content = { 질의요지: expc.질의요지, 회답: expc.회답, 이유: expc.이유, 관련법령: expc.관련법령, 관세법령정보포털원문링크: expc.관세법령정보포털원문링크 }; let output = `=== ${basic.안건명 || "Customs Interpretation"} ===\n\n`; output += `📋 기본 정보:\n`; output += ` 해석일련번호: ${basic.법령해석일련번호 || "N/A"}\n`; output += ` 업무분야: ${basic.업무분야 || "N/A"}\n`; output += ` 해석일자: ${basic.해석일자 || "N/A"}\n`; output += ` 질의기관: ${basic.질의기관명 || "N/A"}\n`; output += ` 해석기관: ${basic.해석기관명 || "N/A"}\n`; output += ` 등록일시: ${basic.등록일시 || "N/A"}\n\n`; if (content.질의요지) { output += `📌 질의요지:\n${content.질의요지}\n\n`; } if (content.회답) { output += `📝 회답:\n${content.회답}\n\n`; } if (content.이유) { output += `💡 이유:\n${content.이유}\n\n`; } if (content.관련법령) { output += `📖 관련법령:\n${content.관련법령}\n\n`; } if (content.관세법령정보포털원문링크) { output += `🔗 원문 링크: ${content.관세법령정보포털원문링크}\n`; } return { content: [{ type: "text", text: truncateResponse(output) }] }; } catch (error) { return formatToolError(error, "get_customs_interpretation_text"); } } - Zod schema for input validation: requires 'id' (serial number), optional 'interpretationName' for verification, and optional 'apiKey'.
export const getCustomsInterpretationTextSchema = z.object({ id: z.string().describe("Customs interpretation serial number (법령해석일련번호) from search results"), interpretationName: z.string().optional().describe("Interpretation name (optional, for verification)"), apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"), }); - src/tool-registry.ts:344-349 (registration)Registration of the tool in the tool registry: name 'get_customs_interpretation_text' with description, schema reference, and handler reference.
{ name: "get_customs_interpretation_text", description: "[관세] 관세 해석례 전문 조회. 질의요지·회답·이유·관련법령 포함.", schema: getCustomsInterpretationTextSchema, handler: getCustomsInterpretationText }, - src/lib/tool-chain-config.ts:36-39 (helper)Tool-chain configuration mapping search_customs_interpretations to get_customs_interpretation_text as the detail tool, enabling automatic chaining from search results to full text retrieval.
search_customs_interpretations: { detailTool: "get_customs_interpretation_text", detailParam: "id", idRegex: BRACKET_ID,