Skip to main content
Glama

suggest_law_names

Input a partial law name to get a list of matching law candidates for accurate law identification.

Instructions

[자동완성] 법령명 일부 입력 시 후보 목록 제안. 정확한 법령명을 모를 때 사용.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
partialYes부분 입력된 법령명 (예: '관세', '환경')
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • The main handler function for suggest_law_names. Takes partial law name input, calls searchLaw to find matches, parses results by type (law, decree, rule), and returns formatted suggestions grouped by category.
    export async function suggestLawNames(
      apiClient: LawApiClient,
      input: SuggestLawNamesInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        if (input.partial.length < 2) {
          return {
            content: [{
              type: "text",
              text: "검색어는 최소 2글자 이상이어야 합니다."
            }],
            isError: true
          }
        }
    
        // Search for laws matching the partial input
        const searchResult = await searchLaw(apiClient, {
          query: input.partial,
          display: 20,
          apiKey: input.apiKey
        })
    
        if (searchResult.isError) {
          return searchResult
        }
    
        const text = searchResult.content[0].text
    
        // Parse search results to extract law names
        const lines = text.split('\n')
        const suggestions: Array<{ name: string; type: string }> = []
    
        for (let i = 0; i < lines.length; i++) {
          const line = lines[i]
          // Match lines like "1. 관세법"
          const nameMatch = line.match(/^\d+\.\s+(.+)$/)
          if (nameMatch) {
            const name = nameMatch[1].trim()
            // Look ahead for the type line "   - 구분: 법률"
            const typeLine = lines[i + 4] // 4 lines down: lawId, MST, promDate, lawType
            const typeMatch = typeLine?.match(/구분:\s+(.+)/)
            if (typeMatch) {
              const type = typeMatch[1].trim()
              suggestions.push({ name, type })
            }
          }
        }
    
        if (suggestions.length === 0) {
          return {
            content: [{
              type: "text",
              text: `'${input.partial}'로 시작하는 법령을 찾을 수 없습니다.`
            }]
          }
        }
    
        let output = `=== 법령명 자동완성: "${input.partial}" ===\n\n`
    
        // Group by type
        const laws = suggestions.filter(s => s.type === "법률")
        const decrees = suggestions.filter(s => s.type === "대통령령")
        const rules = suggestions.filter(s => s.type === "총리령" || s.type === "부령")
    
        if (laws.length > 0) {
          output += `📜 법률 (${laws.length}건)\n`
          for (const law of laws.slice(0, 10)) {
            output += `  • ${law.name}\n`
          }
          if (laws.length > 10) {
            output += `  ... 외 ${laws.length - 10}건\n`
          }
          output += `\n`
        }
    
        if (decrees.length > 0) {
          output += `📋 시행령 (${decrees.length}건)\n`
          for (const decree of decrees.slice(0, 5)) {
            output += `  • ${decree.name}\n`
          }
          if (decrees.length > 5) {
            output += `  ... 외 ${decrees.length - 5}건\n`
          }
          output += `\n`
        }
    
        if (rules.length > 0) {
          output += `📄 시행규칙 (${rules.length}건)\n`
          for (const rule of rules.slice(0, 5)) {
            output += `  • ${rule.name}\n`
          }
          if (rules.length > 5) {
            output += `  ... 외 ${rules.length - 5}건\n`
          }
          output += `\n`
        }
    
        output += `💡 자세한 정보는 search_law Tool을 사용하세요.`
    
        return {
          content: [{
            type: "text",
            text: output
          }]
        }
      } catch (error) {
        return formatToolError(error, "suggest_law_names")
      }
    }
  • Zod schema defining the tool's input: partial (string, required) and apiKey (optional).
    export const SuggestLawNamesSchema = z.object({
      partial: z.string().describe("부분 입력된 법령명 (예: '관세', '환경')"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    })
  • Tool registration entry in the tool registry. Maps name 'suggest_law_names' to its schema and handler function. Imported from src/tools/autocomplete.ts via line 27.
    {
      name: "suggest_law_names",
      description: "[자동완성] 법령명 일부 입력 시 후보 목록 제안. 정확한 법령명을 모를 때 사용.",
      schema: SuggestLawNamesSchema,
      handler: suggestLawNames
    },
  • Import statement bringing suggestLawNames handler and SuggestLawNamesSchema into the tool registry.
    import { suggestLawNames, SuggestLawNamesSchema } from "./tools/autocomplete.js"
  • Error handling using formatToolError helper, which formats errors with error codes and suggestions.
    return formatToolError(error, "suggest_law_names")
Behavior2/5

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

No annotations are provided, and the description lacks details about behavioral traits such as how many candidates are returned, pagination, or API dependencies. It only states the basic auto-complete function.

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, using a single sentence in Korean. While concise, it earns its place, though it could be slightly more informative.

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

Completeness3/5

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

For a simple auto-complete tool with no output schema, the description covers purpose and usage. However, it does not explain what the agent can expect as output (e.g., list of names), leaving some ambiguity.

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. The description adds no extra meaning beyond what the schema already provides, which clearly describes the 'partial' parameter with examples.

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 it suggests law names when a partial input is given, using the Korean phrase '자동완성' (auto-complete). However, it does not differentiate from sibling suggestion tools like suggest_alio_regulation_names.

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 provides a use case: 'Use when you don't know the exact law name.' This implies when to use but does not specify when not to use or mention alternative tools.

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