Skip to main content
Glama

summarize_precedent

Generate a summary of a Korean legal precedent using its serial number. Choose the maximum length for the summary.

Instructions

[판례] 판례 요약 생성.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes판례일련번호
maxLengthYes요약 최대 길이 (기본값: 500자)
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • The main handler function 'summarizePrecedent' that takes an apiClient and input, fetches precedent text via getPrecedentText, extracts a summary using extractPrecedentSummary, and returns the result.
    export async function summarizePrecedent(
      apiClient: LawApiClient,
      input: SummarizePrecedentInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        // 1. 판례 전문 조회
        const precedentResult = await getPrecedentText(apiClient, { id: input.id, apiKey: input.apiKey })
    
        if (precedentResult.isError || precedentResult.content.length === 0) {
          return {
            content: [{
              type: "text",
              text: "판례를 찾을 수 없습니다."
            }],
            isError: true
          }
        }
    
        const fullText = precedentResult.content[0].text
    
        // 2. 핵심 정보 추출
        const summary = extractPrecedentSummary(fullText, input.maxLength)
    
        return {
          content: [{
            type: "text",
            text: truncateResponse(summary)
          }]
        }
      } catch (error) {
        return formatToolError(error, "summarize_precedent")
      }
    }
  • Zod schema 'SummarizePrecedentSchema' defining input: id (string), maxLength (optional number, default 500), and apiKey (optional string).
    export const SummarizePrecedentSchema = z.object({
      id: z.string().describe("판례일련번호"),
      maxLength: z.number().optional().default(500).describe("요약 최대 길이 (기본값: 500자)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    })
  • Registration of the 'summarize_precedent' tool in the tool registry with its name, description, schema, and handler.
    {
      name: "summarize_precedent",
      description: "[판례] 판례 요약 생성.",
      schema: SummarizePrecedentSchema,
      handler: summarizePrecedent
    },
  • Helper function 'extractPrecedentSummary' that parses the full precedent text, extracting key sections (caseNumber, court, judgment, summary, mainText) and assembling a summarized output.
    function extractPrecedentSummary(fullText: string, maxLength: number): string {
      const lines = fullText.split('\n')
    
      // 판시사항, 판결요지, 주문 등 핵심 섹션 추출
      const sections = {
        title: "",
        court: "",
        caseNumber: "",
        judgment: "",
        summary: "",
        mainText: ""
      }
    
      let currentSection = ""
    
      for (const line of lines) {
        const trimmed = line.trim()
    
        // 섹션 구분
        if (trimmed.includes("사건번호:") || trimmed.startsWith("사건:")) {
          sections.caseNumber = trimmed
        } else if (trimmed.includes("법원:") || trimmed.includes("선고:")) {
          sections.court = trimmed
        } else if (trimmed === "【판시사항】" || trimmed.startsWith("판시사항")) {
          currentSection = "judgment"
        } else if (trimmed === "【판결요지】" || trimmed.startsWith("판결요지")) {
          currentSection = "summary"
        } else if (trimmed === "【주문】" || trimmed.startsWith("주문")) {
          currentSection = "mainText"
        } else if (currentSection === "judgment" && trimmed.length > 0) {
          sections.judgment += trimmed + "\n"
        } else if (currentSection === "summary" && trimmed.length > 0) {
          sections.summary += trimmed + "\n"
        } else if (currentSection === "mainText" && trimmed.length > 0) {
          sections.mainText += trimmed + "\n"
        }
      }
    
      // 요약 생성
      let result = "📋 판례 요약\n\n"
    
      if (sections.caseNumber) {
        result += `${sections.caseNumber}\n`
      }
      if (sections.court) {
        result += `${sections.court}\n\n`
      }
    
      if (sections.judgment) {
        result += "【판시사항】\n"
        result += truncateText(sections.judgment, maxLength / 3) + "\n\n"
      }
    
      if (sections.summary) {
        result += "【판결요지】\n"
        result += truncateText(sections.summary, maxLength / 3) + "\n\n"
      }
    
      if (sections.mainText) {
        result += "【주문】\n"
        result += truncateText(sections.mainText, maxLength / 3) + "\n"
      }
    
      return result
    }
  • Helper function 'truncateText' that truncates text to a maximum length with ellipsis.
    function truncateText(text: string, maxLength: number): string {
      const trimmed = text.trim()
      if (trimmed.length <= maxLength) {
        return trimmed
      }
      return trimmed.substring(0, maxLength) + "..."
    }
Behavior2/5

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

No annotations provided; description only says 'generate summary' without disclosing API dependencies, error handling, 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?

Single sentence is concise, though arguably too sparse for a tool with multiple parameters.

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 behavioral details; agent cannot infer what is returned or how errors are handled.

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%, so baseline is 3; description adds no extra meaning beyond the schema.

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

Purpose5/5

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

The description clearly states the tool generates a summary of a precedent, distinguishing it from siblings like search_precedents or get_precedent_text.

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 extract_precedent_keywords or analyze_document.

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