Skip to main content
Glama

get_legal_to_daily

Map Korean legal terms to everyday expressions for accessible understanding of laws.

Instructions

[지식베이스] 법령용어→일상용어 매핑.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
legalTermYes법령용어 (예: '임대차' → '월세', '전세')
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Main handler function for get_legal_to_daily. Calls lawSearch.do API with target 'lstrmRel' and relType 'LD' to map legal terms to everyday terms, with fallback to term search if no results or API fails.
    export async function getLegalToDaily(
      apiClient: LawApiClient,
      args: GetLegalToDailyInput
    ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> {
      try {
        let xmlText: string;
        try {
          xmlText = await apiClient.fetchApi({
            endpoint: "lawSearch.do",
            target: "lstrmRel",
            extraParams: { query: args.legalTerm, relType: "LD" },
            apiKey: args.apiKey,
          });
        } catch {
          return await fallbackTermSearch(apiClient, args.legalTerm, "법령용어");
        }
        const result = parseKBXML(xmlText, "LsTrmRelSearch");
    
        const items = result.data || [];
    
        if (items.length === 0) {
          return await fallbackTermSearch(apiClient, args.legalTerm, "법령용어");
        }
    
        let output = `🔗 법령용어 → 일상용어 연계\n\n`;
        output += `📝 입력: ${args.legalTerm}\n\n`;
        output += `🗣️ 관련 일상용어:\n`;
    
        for (const item of items) {
          output += `   • ${item.일상용어명 || item.연계용어명}\n`;
        }
    
        return { content: [{ type: "text", text: output }] };
      } catch (error) {
        return formatToolError(error, "get_legal_to_daily");
      }
    }
  • Zod schema for get_legal_to_daily input validation. Accepts legalTerm (string) and optional apiKey.
    export const getLegalToDailySchema = z.object({
      legalTerm: z.string().describe("법령용어 (예: '임대차' → '월세', '전세')"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"),
    });
  • Tool registration entry mapping the name 'get_legal_to_daily' to its schema and handler function.
    {
      name: "get_legal_to_daily",
      description: "[지식베이스] 법령용어→일상용어 매핑.",
      schema: getLegalToDailySchema,
      handler: getLegalToDaily
    },
  • XML parser used by getLegalToDaily to parse the API response. Extracts items like 일상용어명 from KB XML.
    export function parseKBXML(xml: string, _rootTag: string): KBParseResult {
      const result: KBParseResult = { totalCnt: "0", data: [] }
    
      // totalCnt 추출
      const totalCntMatch = xml.match(/<totalCnt>(\d+)<\/totalCnt>/i) || xml.match(/<검색결과개수>(\d+)<\/검색결과개수>/i)
      result.totalCnt = totalCntMatch ? totalCntMatch[1] : "0"
    
      // 아이템 추출 (다양한 태그명 지원)
      const itemTags = ["lstrm", "lstrmAI", "law", "jo", "rel", "item"]
    
      for (const itemTag of itemTags) {
        const itemRegex = new RegExp(`<${itemTag}[^>]*>([\\s\\S]*?)<\\/${itemTag}>`, "gi")
        const matches = xml.matchAll(itemRegex)
    
        for (const match of matches) {
          const itemContent = match[1]
          const item: KBItem = {}
    
          // 공통 필드 추출
          item.법령용어명 = extractTag(itemContent, "법령용어명") || extractTag(itemContent, "용어명")
          item.법령용어ID = extractTag(itemContent, "법령용어ID") || extractTag(itemContent, "용어ID")
          item.동음이의어 = extractTag(itemContent, "동음이의어존재여부") === "Y"
          item.용어간관계링크 = extractTag(itemContent, "용어간관계링크") || extractTag(itemContent, "용어관계")
          item.조문간관계링크 = extractTag(itemContent, "조문간관계링크") || extractTag(itemContent, "조문관계")
          item.법령명 = extractTag(itemContent, "법령명")
          item.법령ID = extractTag(itemContent, "법령ID") || extractTag(itemContent, "법령일련번호")
          item.조문번호 = extractTag(itemContent, "조문번호") || extractTag(itemContent, "조번호")
          item.조문제목 = extractTag(itemContent, "조문제목")
          item.관계유형 = extractTag(itemContent, "관계유형") || extractTag(itemContent, "연계유형")
          item.법령종류 = extractTag(itemContent, "법령종류") || extractTag(itemContent, "법종류")
          item.연계용어명 = extractTag(itemContent, "연계용어명") || extractTag(itemContent, "관련용어")
          item.일상용어명 = extractTag(itemContent, "일상용어명") || extractTag(itemContent, "일상용어")
    
          // 빈 객체가 아닌 경우만 추가
          if (item.법령용어명 || item.법령명 || item.연계용어명) {
            result.data.push(item)
          }
        }
    
        if (result.data.length > 0) break
      }
    
      return result
    }
  • Fallback search function used when the primary legal-to-daily API call fails or returns empty results.
    export async function fallbackTermSearch(
      apiClient: Pick<import("../lib/api-client.js").LawApiClient, "fetchApi">,
      term: string,
      termType: string
    ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean }> {
      try {
        const xmlText = await apiClient.fetchApi({
          endpoint: "lawSearch.do",
          target: "lstrm",
          extraParams: { query: term, display: "10" },
        })
    
        const result = parseKBXML(xmlText, "LsTrmSearch")
        const items = result.data || []
    
        if (items.length === 0) {
          return {
            content: [{
              type: "text",
              text: `'${term}' ${termType} 연계 정보를 찾을 수 없습니다.`,
            }],
            isError: true,
          }
        }
    
        let output = `📚 '${term}' 관련 용어 (폴백 검색):\n\n`
        for (const item of items) {
          if (item.법령용어명) {
            output += `   • ${item.법령용어명}\n`
          }
        }
    
        return { content: [{ type: "text", text: output }] }
      } catch {
        return {
          content: [{
            type: "text",
            text: `'${term}' ${termType} 연계 정보를 찾을 수 없습니다.\n\n💡 search_legal_terms(query="${term}")로 기본 검색을 시도해보세요.`,
          }],
          isError: true,
Behavior2/5

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

No annotations provided, so description must disclose behavior. It only states the mapping purpose, with no details about side effects, authentication needs, rate limits, or whether it uses an external API (though apiKey param hints at this). Minimal transparency.

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

Conciseness5/5

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

Extremely concise: one short sentence with a contextual prefix. No redundant information, well front-loaded.

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?

No output schema, so description should clarify return behavior (e.g., single mapping or multiple). It does not specify what the tool returns, how ambiguous terms are handled, or any pagination/formatting. Incomplete for a tool with a required parameter.

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 description adds limited value. The description does not elaborate on parameters beyond what the schema already provides (e.g., example for legalTerm is in schema). Baseline 3 applies.

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 maps legal terms to everyday terms, using '[지식베이스]' to indicate a knowledge base. It implicitly distinguishes from siblings like 'get_daily_to_legal' (reverse mapping) by focusing on legal-to-daily direction.

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?

Usage is implied: use when you have a legal term and need a daily equivalent. However, there is no explicit guidance on when not to use it or mention of alternatives like 'get_legal_term_detail' or 'get_daily_to_legal'.

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