get_ordinance
Retrieve the full text of a Korean local ordinance or rule by providing its sequence number.
Instructions
[자치법규] 조례/규칙 전문 조회.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ordinSeq | Yes | 자치법규 일련번호 | |
| apiKey | No | 법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달 |
Implementation Reference
- src/tools/ordinance.ts:18-103 (handler)Main handler function for the get_ordinance tool. Fetches ordinance details via API client, parses JSON response, formats output including articles (with TOC for >20 articles), and returns tool response.
export async function getOrdinance( apiClient: LawApiClient, input: GetOrdinanceInput ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> { try { const jsonText = await apiClient.getOrdinance(input.ordinSeq, input.apiKey) const json = JSON.parse(jsonText) const lawService = json?.LawService if (!lawService) { return { content: [{ type: "text", text: "자치법규 데이터를 찾을 수 없습니다." }], isError: true } } const ordinance = lawService.자치법규기본정보 || {} let resultText = `자치법규명: ${ordinance.자치법규명 || "알 수 없음"}\n` resultText += `제정일: ${ordinance.공포일자 || ""}\n` resultText += `자치단체: ${ordinance.지자체기관명 || ""}\n` resultText += `시행일: ${ordinance.시행일자 || ""}\n` if (ordinance.담당부서명) { resultText += `소관부서: ${ordinance.담당부서명}\n` } resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n\n` // 조문 내용 (단일 객체 → 배열 정규화) const rawArticles = lawService.조문?.조 const articles = Array.isArray(rawArticles) ? rawArticles : rawArticles ? [rawArticles] : [] if (articles.length > 0) { // 대형 조례(20개 초과): TOC 반환 (law-text.ts 패턴) if (articles.length > 20) { const tocItems: string[] = [] for (const article of articles) { if (article.조제목) tocItems.push(article.조제목) } resultText += `📋 목차 (총 ${articles.length}개 조문)\n\n` resultText += tocItems.join("\n") resultText += `\n\n💡 전체 내용이 길어 목차만 표시합니다.` resultText += `\n💡 특정 조문 조회: get_law_text(mst="${input.ordinSeq}", jo="제XX조")` } else { for (const article of articles) { if (article.조제목) { resultText += `${article.조제목}\n` } if (article.조내용) { resultText += `${cleanHtml(String(article.조내용))}\n\n` } } } } // 상위법령 동적 추천 (조례명 키워드 기반) const name = (ordinance.자치법규명 || "").toLowerCase() const parentLawHints: string[] = [] if (/휴직|병가|육아/.test(name)) parentLawHints.push('search_law(query="지방공무원법") → 제63조(휴직)') if (/복무|근무/.test(name)) parentLawHints.push('search_law(query="지방공무원법") → 제48조(복무)') if (/징계|파면|해임/.test(name)) parentLawHints.push('search_law(query="지방공무원법") → 제69조(징계)') if (/수당|급여|보수/.test(name)) parentLawHints.push('search_law(query="지방공무원 보수규정")') if (/임용|채용|승진|전보/.test(name)) parentLawHints.push('search_law(query="지방공무원 임용령")') if (parentLawHints.length > 0) { resultText += `\n💡 상위법령 참고:\n` parentLawHints.forEach(h => { resultText += ` - ${h}\n` }) } else { resultText += `\n💡 상위법령 확인: search_law 또는 get_related_laws 도구를 사용하세요.` } return { content: [{ type: "text", text: truncateResponse(resultText) }] } } catch (error) { return formatToolError(error, "get_ordinance") } } - src/tools/ordinance.ts:11-14 (schema)Zod schema defining input parameters for get_ordinance: ordinSeq (required string) and apiKey (optional string).
export const GetOrdinanceSchema = z.object({ ordinSeq: z.string().describe("자치법규 일련번호"), apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달") }) - src/tool-registry.ts:162-167 (registration)Registration of get_ordinance in the MCP tool registry with name, description, schema, and handler references.
{ name: "get_ordinance", description: "[자치법규] 조례/규칙 전문 조회.", schema: GetOrdinanceSchema, handler: getOrdinance }, - src/lib/api-client.ts:322-335 (helper)API client method that makes the HTTP request to the law service API to fetch ordinance data by ordinSeq.
async getOrdinance(ordinSeq: string, apiKey?: string): Promise<string> { const apiParams = new URLSearchParams({ target: "ordin", OC: this.getApiKey(apiKey), type: "JSON", MST: ordinSeq, }) const url = `${LAW_API_BASE}/lawService.do?${apiParams.toString()}` const text = await this.fetchText(url, "getOrdinance") this.checkHtmlError(text, "자치법규를 찾을 수 없습니다. ordinSeq를 확인해주세요") return text } - src/lib/tool-chain-config.ts:76-80 (helper)Tool chain configuration linking search_ordinance to get_ordinance as its detail tool with ordinSeq as the detail parameter.
search_ordinance: { detailTool: "get_ordinance", detailParam: "ordinSeq", idRegex: BRACKET_ID, },