Skip to main content
Glama

parse_article_links

Extracts all legal references and citations within a specific article of Korean law, enabling analysis of cross-references.

Instructions

[분석] 조문 내 법령 참조 추출.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mstNo법령일련번호
lawIdNo법령ID
joYes조문 번호 (예: '제38조')
efYdNo시행일자 (YYYYMMDD)
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • The main handler function for the parse_article_links tool. Fetches law article text via getLawText, then extracts inter-article references (제X조, 같은 조, 전항, 이 법 etc.) and formats them as a numbered list.
    export async function parseArticleLinks(
      apiClient: LawApiClient,
      input: ParseArticleLinksInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        // 1. 조문 조회
        const articleResult = await getLawText(apiClient, {
          mst: input.mst,
          lawId: input.lawId,
          jo: input.jo,
          efYd: input.efYd,
          apiKey: input.apiKey
        })
    
        if (articleResult.isError || articleResult.content.length === 0) {
          return {
            content: [{
              type: "text",
              text: "조문을 찾을 수 없습니다."
            }],
            isError: true
          }
        }
    
        const articleText = articleResult.content[0].text
    
        // 2. 조문 내 참조 파싱
        const references = extractArticleReferences(articleText)
    
        // 3. 결과 포맷
        let resultText = `🔗 조문 내 참조 링크 (${references.length}개)\n\n`
    
        if (references.length === 0) {
          resultText += "이 조문에는 다른 조문을 참조하는 내용이 없습니다.\n"
        } else {
          references.forEach((ref, idx) => {
            resultText += `${idx + 1}. ${ref.text}\n`
            resultText += `   → 참조: ${ref.reference}\n`
            if (ref.context) {
              resultText += `   문맥: "${ref.context}"\n`
            }
            resultText += `\n`
          })
        }
    
        return {
          content: [{
            type: "text",
            text: truncateResponse(resultText)
          }]
        }
      } catch (error) {
        return formatToolError(error, "parse_article_links")
      }
    }
  • Zod schema defining inputs: mst (optional), lawId (optional, at least one required), jo (required, e.g. '제38조'), efYd (optional date), apiKey (optional).
    export const ParseArticleLinksSchema = z.object({
      mst: z.string().optional().describe("법령일련번호"),
      lawId: z.string().optional().describe("법령ID"),
      jo: z.string().describe("조문 번호 (예: '제38조')"),
      efYd: z.string().optional().describe("시행일자 (YYYYMMDD)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    }).refine(data => data.mst || data.lawId, {
      message: "mst 또는 lawId 중 하나는 필수입니다"
    })
  • Registration entry mapping the name 'parse_article_links' to ParseArticleLinksSchema and the parseArticleLinks handler function.
    {
      name: "parse_article_links",
      description: "[분석] 조문 내 법령 참조 추출.",
      schema: ParseArticleLinksSchema,
      handler: parseArticleLinks
    },
  • Helper function extractContext that extracts surrounding context around a regex match within the article text.
    /**
     * 매칭된 텍스트 주변 문맥 추출
     */
    function extractContext(text: string, index: number, contextLength: number): string {
      const start = Math.max(0, index - contextLength)
      const end = Math.min(text.length, index + contextLength)
      let context = text.substring(start, end).trim()
    
      // 줄바꿈 제거
      context = context.replace(/\n/g, " ")
    
      return context
    }
  • Helper function extractArticleReferences that parses article text for Korean legal references: 제X조, 같은/이/당해 조, 전/다음 항/호, 이 법/영/규칙/령 patterns.
    function extractArticleReferences(text: string): Array<{
      text: string
      reference: string
      context?: string
    }> {
      const references: Array<{ text: string, reference: string, context?: string }> = []
    
      // 패턴 1: "제X조"
      const articlePattern = /제(\d+)조(의(\d+))?/g
      let match = articlePattern.exec(text)
      while (match) {
        const fullMatch = match[0]
        const context = extractContext(text, match.index, 30)
    
        references.push({
          text: fullMatch,
          reference: fullMatch,
          context
        })
    
        match = articlePattern.exec(text)
      }
    
      // 패턴 2: "같은 조", "이 조", "당해 조"
      const sameArticlePattern = /(같은|이|당해|해당)\s*조/g
      match = sameArticlePattern.exec(text)
      while (match) {
        const fullMatch = match[0]
        const context = extractContext(text, match.index, 30)
    
        references.push({
          text: fullMatch,
          reference: "현재 조문",
          context
        })
    
        match = sameArticlePattern.exec(text)
      }
    
      // 패턴 3: "전항", "전각호"
      const prevPattern = /(전|다음)\s*(항|각\s*호|호)/g
      match = prevPattern.exec(text)
      while (match) {
        const fullMatch = match[0]
        const context = extractContext(text, match.index, 30)
    
        references.push({
          text: fullMatch,
          reference: match[1] === "전" ? "이전 항/호" : "다음 항/호",
          context
        })
    
        match = prevPattern.exec(text)
      }
    
      // 패턴 4: "이 법", "이 영", "이 규칙"
      const lawPattern = /이\s*(법|영|규칙|령)/g
      match = lawPattern.exec(text)
      while (match) {
        const fullMatch = match[0]
        const context = extractContext(text, match.index, 30)
    
        references.push({
          text: fullMatch,
          reference: "현행 법령 전체",
          context
        })
    
        match = lawPattern.exec(text)
      }
    
      return references
    }
Behavior2/5

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

No annotations provided, so description carries full burden. It does not disclose any behavioral traits such as side effects, authentication needs, rate limits, or error handling.

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?

Single sentence is concise and front-loaded with '[분석]'. Could include more detail without being verbose.

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 5 parameters, no output schema, and no annotations, the description is too lean. It does not explain expected output or prerequisites for using the tool.

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 description coverage is 100%, so baseline is 3. Description adds no additional parameter meaning 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?

Description states it extracts legal references within articles. However, it does not distinguish from the sibling tool parse_alio_article_links, which appears to have a similar purpose.

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 on when to use this tool versus alternatives like parse_alio_article_links or other parsing tools. Agents must infer usage context.

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