Skip to main content
Glama

compare_admin_rule_old_new

Search for administrative rules by keyword and compare old and new versions side-by-side using the rule ID.

Instructions

[행정규칙] 행정규칙 신구법 비교. query로 검색, id로 본문 대조표 조회.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo행정규칙명 키워드 (검색용)
idNo행정규칙ID (본문 조회용, search_admin_rule에서 획득)
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Main handler function for compare_admin_rule_old_new. Calls lawService.do (target=admrulOldAndNew) with id for detailed comparison, or lawSearch.do (target=admrulOldAndNew) with query for search. Parses XML to extract old/new articles (구조문/신조문) and returns formatted comparison text.
    export async function compareAdminRuleOldNew(
      apiClient: LawApiClient,
      input: CompareAdminRuleOldNewInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        if (input.id) {
          // 본문 조회: lawService.do, target=admrulOldAndNew
          const xmlText = await apiClient.fetchApi({
            endpoint: "lawService.do",
            target: "admrulOldAndNew",
            type: "XML",
            extraParams: { ID: String(input.id) },
            apiKey: input.apiKey
          })
    
          const parser = new DOMParser()
          const doc = parser.parseFromString(xmlText, "text/xml")
    
          const ruleName = doc.getElementsByTagName("행정규칙명")[0]?.textContent || "알 수 없음"
    
          let resultText = `행정규칙 신구법 대조: ${ruleName}\n`
          resultText += `━━━━━━━━━━━━━━━━━━━━━━\n\n`
    
          const oldArticles = doc.getElementsByTagName("구조문")
          const newArticles = doc.getElementsByTagName("신조문")
          const maxCount = Math.max(oldArticles.length, newArticles.length)
    
          if (maxCount === 0) {
            resultText += "신구법 대조 데이터가 없습니다."
            return { content: [{ type: "text", text: resultText }] }
          }
    
          const displayCount = Math.min(maxCount, 30)
          for (let i = 0; i < displayCount; i++) {
            const oldContent = oldArticles[i]?.textContent?.trim() || ""
            const newContent = newArticles[i]?.textContent?.trim() || ""
    
            resultText += `━━━━━━━━━━━━━━━━━━━━━━\n`
            resultText += `[개정 전] ${oldContent || "(신설)"}\n\n`
            resultText += `[개정 후] ${newContent || "(삭제)"}\n\n`
          }
    
          if (maxCount > displayCount) {
            resultText += `\n... 외 ${maxCount - displayCount}개 항목 (생략)\n`
          }
    
          return { content: [{ type: "text", text: truncateResponse(resultText) }] }
        }
    
        // 검색: lawSearch.do, target=admrulOldAndNew
        const xmlText = await apiClient.fetchApi({
          endpoint: "lawSearch.do",
          target: "admrulOldAndNew",
          type: "XML",
          extraParams: { query: String(input.query) },
          apiKey: input.apiKey
        })
    
        const parser = new DOMParser()
        const doc = parser.parseFromString(xmlText, "text/xml")
    
        const rules = doc.getElementsByTagName("admrul")
        if (rules.length === 0) {
          return {
            content: [{ type: "text", text: "행정규칙 신구법 검색 결과가 없습니다." }],
            isError: true
          }
        }
    
        let resultText = `행정규칙 신구법 검색 결과 (총 ${rules.length}건):\n\n`
    
        const display = Math.min(rules.length, 20)
        for (let i = 0; i < display; i++) {
          const rule = rules[i]
          const name = rule.getElementsByTagName("행정규칙명")[0]?.textContent || "알 수 없음"
          const ruleId = rule.getElementsByTagName("행정규칙ID")[0]?.textContent || ""
          const promDate = rule.getElementsByTagName("발령일자")[0]?.textContent || ""
          const orgName = rule.getElementsByTagName("소관부처명")[0]?.textContent || ""
    
          resultText += `${i + 1}. ${name}\n`
          resultText += `   - 행정규칙ID: ${ruleId}\n`
          resultText += `   - 발령일: ${promDate}\n`
          resultText += `   - 소관부처: ${orgName}\n\n`
        }
    
        resultText += `\n💡 본문 조회: compare_admin_rule_old_new(id="행정규칙ID")`
    
        return { content: [{ type: "text", text: truncateResponse(resultText) }] }
      } catch (error) {
        return formatToolError(error, "compare_admin_rule_old_new")
      }
    }
  • Zod schema defining input validation for compare_admin_rule_old_new: optional query (search keyword), optional id (rule ID for detail), optional apiKey. Refines to require at least one of query or id.
    // compare_admin_rule_old_new 스키마
    export const CompareAdminRuleOldNewSchema = z.object({
      query: z.string().optional().describe("행정규칙명 키워드 (검색용)"),
      id: z.string().optional().describe("행정규칙ID (본문 조회용, search_admin_rule에서 획득)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    }).refine(data => data.query || data.id, {
      message: "query(검색) 또는 id(본문조회) 중 하나는 필수입니다"
    })
  • Tool registration in the allTools array. Maps the name 'compare_admin_rule_old_new' to its schema (CompareAdminRuleOldNewSchema) and handler (compareAdminRuleOldNew) with a Korean description.
    {
      name: "compare_admin_rule_old_new",
      description: "[행정규칙] 행정규칙 신구법 비교. query로 검색, id로 본문 대조표 조회.",
      schema: CompareAdminRuleOldNewSchema,
      handler: compareAdminRuleOldNew
    },
  • Imports used by the handler: zod for validation, DOMParser for XML parsing, LawApiClient type, truncateResponse for output limiting, and formatToolError for error handling.
    import { z } from "zod"
    import { DOMParser } from "@xmldom/xmldom"
    import type { LawApiClient } from "../lib/api-client.js"
    import { truncateResponse } from "../lib/schemas.js"
    import { formatToolError } from "../lib/errors.js"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions two modes but omits important details: what the comparison table contains, authentication needs (apiKey), side effects, or output format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short and front-loaded with the tool's purpose. However, it could be more structured (e.g., separate lines for modes) for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Missing output schema and annotation details. The description does not explain what the comparison table looks like or the role of apiKey, leaving significant gaps for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for all parameters. The description adds that id comes from search_admin_rule, which is helpful but not substantial beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool compares old and new administrative rules, with two modes (search by query, lookup by id). However, it does not differentiate from sibling compare tools like compare_old_new, which may cause confusion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use query vs. id (id from search_admin_rule), but lacks explicit guidance on when to prefer this tool over other comparison tools or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/workbookbulb863/korean-law-alio-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server