get_delegated_laws
Retrieve delegated laws by ministry, listing those without enacted enforcement decrees or rules. Filter by ministry name and control result count.
Instructions
[연계] 위임법령 목록. 소관부처별 위임법령(시행령/시행규칙 미제정) 조회.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 부처명 (예: '보건복지부') | |
| display | Yes | 결과 개수 (기본:20, 최대:100) | |
| page | Yes | 페이지 번호 (기본:1) | |
| apiKey | No | 법제처 Open API 인증키(OC) |
Implementation Reference
- src/tools/law-linkage.ts:125-129 (handler)Handler function for get_delegated_laws. Delegates to handleLinkage with target='lnkDep' (위임법령), searching delegated laws by ministry name.
export const getDelegatedLaws = (apiClient: LawApiClient, input: LinkageInput) => handleLinkage(apiClient, input, { target: "lnkDep", primaryRoot: "LawSearch", fallbackRoot: "LnkDepSearch", title: "위임법령 목록", emptyMsg: "위임법령이 없습니다." }) - src/tools/law-linkage.ts:30-32 (schema)Zod schema for get_delegated_laws. Extends baseLinkageSchema with query describing a ministry/department name.
export const DelegatedLawsSchema = baseLinkageSchema.extend({ query: z.string().describe("부처명 (예: '보건복지부')") }) - src/tool-registry.ts:182-187 (registration)Registration of the get_delegated_laws tool in the tool registry with its name, description, schema, and handler.
{ name: "get_delegated_laws", description: "[연계] 위임법령 목록. 소관부처별 위임법령(시행령/시행규칙 미제정) 조회.", schema: DelegatedLawsSchema, handler: getDelegatedLaws }, - src/tools/law-linkage.ts:84-109 (helper)Core shared handler logic used by getDelegatedLaws. Fetches XML from the lawSearch.do API with the configured target, parses it with fallback root, formats and returns results.
async function handleLinkage(apiClient: LawApiClient, input: LinkageInput, cfg: LinkageConfig) { try { const xml = await apiClient.fetchApi({ endpoint: "lawSearch.do", target: cfg.target, extraParams: { query: String(input.query), display: String(input.display || 20), page: String(input.page || 1) }, apiKey: input.apiKey, }) let result = parseLinkageXML(xml, cfg.primaryRoot, "law") if (result.totalCnt === 0 && result.items.length === 0) { result = parseLinkageXML(xml, cfg.fallbackRoot, "law") } if (result.items.length === 0) { return { content: [{ type: "text", text: truncateResponse(`'${input.query}' ${cfg.emptyMsg}`) }] } } let output = `${cfg.title} (총 ${result.totalCnt}건, ${result.page}페이지)\n` output += `검색어: ${input.query}\n\n` output += formatItems(result.items) return { content: [{ type: "text", text: truncateResponse(output) }] } } catch (error) { return formatToolError(error, cfg.title) } }