Skip to main content
Glama

compare_old_new

Compare old and new versions of Korean national laws. Use law serial number, ID, or promulgation date to retrieve a side-by-side comparison of changes.

Instructions

[비교] 신구법 대조표 조회.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mstNo법령일련번호
lawIdNo법령ID
ldNo공포일자 (YYYYMMDD)
lnNo공포번호
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Main handler that fetches old vs new law comparison data via API, parses XML response to extract old/new articles, and formats them as a side-by-side comparison text.
    export async function compareOldNew(
      apiClient: LawApiClient,
      input: CompareOldNewInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        const xmlText = await apiClient.compareOldNew({
          mst: input.mst,
          lawId: input.lawId,
          ld: input.ld,
          ln: input.ln,
          apiKey: input.apiKey
        })
    
        const parser = new DOMParser()
        const doc = parser.parseFromString(xmlText, "text/xml")
    
        const lawName = doc.getElementsByTagName("법령명")[0]?.textContent || "알 수 없음"
        const oldInfo = doc.getElementsByTagName("구조문_기본정보")[0]
        const newInfo = doc.getElementsByTagName("신조문_기본정보")[0]
    
        const oldDate = oldInfo?.getElementsByTagName("공포일자")[0]?.textContent || ""
        const newDate = newInfo?.getElementsByTagName("공포일자")[0]?.textContent || ""
        const revisionType = newInfo?.getElementsByTagName("제개정구분명")[0]?.textContent || ""
    
        let resultText = `법령명: ${lawName}\n`
        if (revisionType) resultText += `개정구분: ${revisionType}\n`
        if (oldDate) resultText += `구법 공포일: ${oldDate}\n`
        if (newDate) resultText += `신법 공포일: ${newDate}\n`
        resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n`
        resultText += `신구법 대조\n`
        resultText += `━━━━━━━━━━━━━━━━━━━━━━\n\n`
    
        // 구조문목록과 신조문목록 파싱
        const oldArticleList = doc.getElementsByTagName("구조문목록")[0]
        const newArticleList = doc.getElementsByTagName("신조문목록")[0]
    
        if (!oldArticleList || !newArticleList) {
          return {
            content: [{
              type: "text",
              text: resultText + "개정 이력이 없거나 신구법 대조 데이터가 없습니다."
            }]
          }
        }
    
        const oldArticles = oldArticleList.getElementsByTagName("조문")
        const newArticles = newArticleList.getElementsByTagName("조문")
    
        if (oldArticles.length === 0 && newArticles.length === 0) {
          return {
            content: [{
              type: "text",
              text: resultText + "개정 이력이 없거나 신구법 대조 데이터가 없습니다."
            }]
          }
        }
    
        // 구/신 조문을 쌍으로 매칭 (동일 인덱스 기반 — API가 대응 쌍을 순서대로 반환)
        const maxArticles = Math.max(oldArticles.length, newArticles.length)
        const displayCount = Math.min(maxArticles, 30)
    
        for (let i = 0; i < displayCount; i++) {
          const oldArticle = oldArticles[i]
          const newArticle = newArticles[i]
    
          const oldContent = oldArticle?.textContent?.trim() || ""
          const newContent = newArticle?.textContent?.trim() || ""
    
          // 조문 번호 추출 시도
          const articleNumMatch = (newContent || oldContent).match(/제\d+조(?:의\d+)?/)
          const articleLabel = articleNumMatch ? articleNumMatch[0] : `조문 ${i + 1}`
    
          resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n`
          resultText += `${articleLabel}\n`
          resultText += `━━━━━━━━━━━━━━━━━━━━━━\n\n`
    
          if (oldContent) {
            resultText += `[개정 전]\n${oldContent}\n\n`
          } else {
            resultText += `[개정 전] (신설)\n\n`
          }
    
          if (newContent) {
            resultText += `[개정 후]\n${newContent}\n\n`
          } else {
            resultText += `[개정 후] (삭제)\n\n`
          }
        }
    
        if (maxArticles > displayCount) {
          resultText += `\n... 외 ${maxArticles - displayCount}개 조문 (생략)\n`
          resultText += `💡 전체 ${maxArticles}개 조문 중 ${displayCount}개만 표시합니다.\n`
        }
    
        return {
          content: [{
            type: "text",
            text: truncateResponse(resultText)
          }]
        }
      } catch (error) {
        return formatToolError(error, "compare_old_new")
      }
    }
  • Zod schema for input validation: accepts optional mst, lawId, ld, ln, apiKey fields, requiring either mst or lawId.
    export const CompareOldNewSchema = z.object({
      mst: z.string().optional().describe("법령일련번호"),
      lawId: z.string().optional().describe("법령ID"),
      ld: z.string().optional().describe("공포일자 (YYYYMMDD)"),
      ln: z.string().optional().describe("공포번호"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    }).refine(data => data.mst || data.lawId, {
      message: "mst 또는 lawId 중 하나는 필수입니다"
    })
  • Tool registration entry mapping the name 'compare_old_new' to its schema and handler function.
    {
      name: "compare_old_new",
      description: "[비교] 신구법 대조표 조회.",
      schema: CompareOldNewSchema,
      handler: compareOldNew
    },
  • API client method that constructs the REST call to the law service endpoint with target=oldAndNew, passing optional MST, ID, LD, LN parameters.
    async compareOldNew(params: {
      mst?: string
      lawId?: string
      ld?: string
      ln?: string
      apiKey?: string
    }): Promise<string> {
      const apiParams = new URLSearchParams({
        target: "oldAndNew",
        OC: this.getApiKey(params.apiKey),
        type: "XML",
      })
    
      if (params.mst) apiParams.append("MST", String(params.mst))
      if (params.lawId) apiParams.append("ID", String(params.lawId))
      if (params.ld) apiParams.append("LD", String(params.ld))
      if (params.ln) apiParams.append("LN", String(params.ln))
    
      const url = `${LAW_API_BASE}/lawService.do?${apiParams.toString()}`
      return await this.fetchText(url, "compareOldNew")
    }
Behavior2/5

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

No annotations are present, so the description fully bears the burden. It only states '조회' (retrieve), implying a read operation, but does not disclose any behavioral traits such as input requirements (no required params), output format, potential side effects, or rate limits.

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 a single sentence that efficiently conveys the core purpose. It is front-loaded with the action and resource. However, it is in Korean, which may reduce clarity for some agents; still acceptably concise.

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?

Given the tool has 5 parameters with no required fields, no output schema, and no annotations, the description is too minimal. It does not explain how to use the parameters, what the comparison table contains, or what happens with an empty input. This leaves significant ambiguity 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?

All 5 parameters have descriptions in the input schema (100% coverage). The tool description does not add any additional meaning beyond what the schema already provides, so it meets the baseline for high schema coverage.

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 indicates retrieving a comparison table of old and new laws. The tool name 'compare_old_new' reinforces this. However, the description does not specify the exact scope (e.g., full law text or specific provisions) or differentiate from sibling tools like 'compare_articles' or 'compare_regulation_timeline'.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. Among many sibling comparison tools (e.g., compare_articles, compare_regulation_timeline), there is no context to help an agent choose correctly.

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