get_external_links
Need external links to Korean legal documents? Get URLs for laws, precedents, interpretations, ordinances, and admin rules by providing the link type and identifier.
Instructions
[링크] 법령 외부 참조 링크.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| linkType | Yes | 링크 유형: law (법령), precedent (판례), interpretation (해석례), ordinance (자치법규), admin_rule (행정규칙) | |
| lawId | No | 법령ID (법령 링크 생성 시) | |
| mst | No | 법령일련번호 (법령/자치법규 링크 생성 시) | |
| lawName | No | 법령명 (한글 URL 생성용, 예: '관세법') | |
| jo | No | 조문 번호 (한글 URL 생성용, 예: '제38조') | |
| precedentId | No | 판례일련번호 (판례 링크 생성 시) | |
| interpretationId | No | 법령해석례일련번호 (해석례 링크 생성 시) | |
| adminRuleId | No | 행정규칙일련번호 (행정규칙 링크 생성 시) | |
| ordinanceId | No | 자치법규ID (자치법규 링크 생성 시) |
Implementation Reference
- src/tools/external-links.ts:24-130 (handler)Main handler function for the get_external_links tool. Accepts an input with linkType and optional IDs, then delegates to type-specific helper functions to generate external URLs to Korean legal databases (law.go.kr, glaw.scourt.go.kr, etc.).
export async function getExternalLinks( input: ExternalLinksInput ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> { try { let resultText = "🔗 외부 링크\n\n" switch (input.linkType) { case "law": { if (!input.lawId && !input.mst && !input.lawName) { return { content: [{ type: "text", text: "법령 링크 생성을 위해 lawId, mst 또는 lawName이 필요합니다." }], isError: true } } const lawLinks = generateLawLinks(input.lawId, input.mst, input.lawName, input.jo) resultText += lawLinks break } case "precedent": { if (!input.precedentId) { return { content: [{ type: "text", text: "판례 링크 생성을 위해 precedentId가 필요합니다." }], isError: true } } const precedentLinks = generatePrecedentLinks(input.precedentId) resultText += precedentLinks break } case "interpretation": { if (!input.interpretationId) { return { content: [{ type: "text", text: "해석례 링크 생성을 위해 interpretationId가 필요합니다." }], isError: true } } const interpretationLinks = generateInterpretationLinks(input.interpretationId) resultText += interpretationLinks break } case "ordinance": { if (!input.ordinanceId && !input.mst && !input.lawName) { return { content: [{ type: "text", text: "자치법규 링크 생성을 위해 ordinanceId, mst 또는 lawName이 필요합니다." }], isError: true } } const ordinanceLinks = generateOrdinanceLinks(input.ordinanceId, input.mst, input.lawName, input.jo) resultText += ordinanceLinks break } case "admin_rule": { if (!input.adminRuleId) { return { content: [{ type: "text", text: "행정규칙 링크 생성을 위해 adminRuleId가 필요합니다." }], isError: true } } const adminRuleLinks = generateAdminRuleLinks(input.adminRuleId) resultText += adminRuleLinks break } default: return { content: [{ type: "text", text: "지원하지 않는 링크 유형입니다." }], isError: true } } return { content: [{ type: "text", text: resultText }] } } catch (error) { return formatToolError(error, "get_external_links") } } - src/tools/external-links.ts:8-22 (schema)Zod schema defining the input for get_external_links. Requires linkType enum and various optional IDs for each link type.
export const ExternalLinksSchema = z.object({ linkType: z.enum(["law", "precedent", "interpretation", "ordinance", "admin_rule"]).describe( "링크 유형: law (법령), precedent (판례), interpretation (해석례), ordinance (자치법규), admin_rule (행정규칙)" ), lawId: z.string().optional().describe("법령ID (법령 링크 생성 시)"), mst: z.string().optional().describe("법령일련번호 (법령/자치법규 링크 생성 시)"), lawName: z.string().optional().describe("법령명 (한글 URL 생성용, 예: '관세법')"), jo: z.string().optional().describe("조문 번호 (한글 URL 생성용, 예: '제38조')"), precedentId: z.string().optional().describe("판례일련번호 (판례 링크 생성 시)"), interpretationId: z.string().optional().describe("법령해석례일련번호 (해석례 링크 생성 시)"), adminRuleId: z.string().optional().describe("행정규칙일련번호 (행정규칙 링크 생성 시)"), ordinanceId: z.string().optional().describe("자치법규ID (자치법규 링크 생성 시)") }) export type ExternalLinksInput = z.infer<typeof ExternalLinksSchema> - src/tool-registry.ts:240-245 (registration)Registration of the get_external_links tool in the tool registry with its name, description, schema, and handler.
{ name: "get_external_links", description: "[링크] 법령 외부 참조 링크.", schema: ExternalLinksSchema, handler: (_apiClient, input) => getExternalLinks(input) }, - src/tool-registry.ts:39-39 (registration)Import of getExternalLinks handler and schema from the external-links module.
import { getExternalLinks, ExternalLinksSchema } from "./tools/external-links.js" - src/tools/external-links.ts:135-169 (helper)Helper function to generate law-related external links to law.go.kr, including direct URLs, detail pages, English versions, and history.
function generateLawLinks(lawId?: string, mst?: string, lawName?: string, jo?: string): string { let links = "📜 법령 관련 링크:\n\n" let linkNum = 1 // 1. 한글 URL (법령명 기반) - 우선순위 최상위 if (lawName) { if (jo) { const url = `https://www.law.go.kr/법령/${encodeURIComponent(lawName)}/${encodeURIComponent(jo)}` links += `${linkNum++}. [법제처 조문 직접 링크](${url})\n\n` } else { const url = `https://www.law.go.kr/법령/${encodeURIComponent(lawName)}` links += `${linkNum++}. [법제처 법령 직접 링크](${url})\n\n` } } // 2. 법령ID 기반 링크 (쿼리 파라미터) if (lawId) { const detailUrl = `https://www.law.go.kr/LSW/lawLsInfoP.do?lsiSeq=${lawId}` links += `${linkNum++}. [법제처 법령 상세 (ID)](${detailUrl})\n\n` const engUrl = `https://www.law.go.kr/eng/LSW/lawLsInfoP.do?lsiSeq=${lawId}` links += `${linkNum++}. [법령 전문 (영문)](${engUrl})\n\n` } // 3. 법령 연혁 if (mst) { const historyUrl = `https://www.law.go.kr/LSW/lsStmdInfoP.do?lsiSeq=${mst}` links += `${linkNum++}. [법령 연혁](${historyUrl})\n\n` } // 4. 법제처 홈페이지 links += `${linkNum}. [법제처 홈페이지](https://www.law.go.kr/)\n\n` return links }