Skip to main content
Glama
scvcoder

korean-privacy-law-mcp

by scvcoder

get_three_tier

Check delegation and citation relationships between the Personal Information Protection Act, its enforcement decree, and enforcement rule. Input the law serial number to view three-tier comparisons.

Instructions

법률 → 시행령 → 시행규칙 3단 위임·인용 비교 (법제처 lawService · target=thdCmp). knd=2(위임, 기본): 본법 조문에서 시행령으로 위임된 관계. knd=1(인용): 법률·하위법령 간 인용 관계. PIPA §29(안전조치) → 시행령 §30 같은 위임 매핑 한 번에 확인. 다음: get_law_text(mst)로 시행령 본문, get_admin_rule_text로 PIPC 고시 (W2.4).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mstYes법령일련번호 (search_law·get_law_history 결과). 본법 mst (시행령·시행규칙 mst 아님).
kndNo비교 종류: 1=인용조문 (법률↔하위법령 인용 관계), 2=위임조문 (법률→시행령 위임 관계, 기본)2

Implementation Reference

  • The main tool definition and handler for 'get_three_tier'. It fetches 3-tier comparison data (law → enforcement decree → enforcement rule) via the lawService API (target=thdCmp). Parses JSON, extracts delegation/reference relationships between articles, formats them as an indented tree, and returns the result with suggestions.
    export const getThreeTier: Tool<typeof inputSchema> = {
      name: "get_three_tier",
      description:
        "법률 → 시행령 → 시행규칙 3단 위임·인용 비교 (법제처 lawService · target=thdCmp). " +
        "knd=2(위임, 기본): 본법 조문에서 시행령으로 위임된 관계. knd=1(인용): 법률·하위법령 간 인용 관계. " +
        "PIPA §29(안전조치) → 시행령 §30 같은 위임 매핑 한 번에 확인. " +
        "다음: get_law_text(mst)로 시행령 본문, get_admin_rule_text로 PIPC 고시 (W2.4).",
      inputSchema,
    
      async handler(args, client) {
        try {
          const jsonText = await client.fetchApi({
            endpoint: "lawService.do",
            target: "thdCmp",
            type: "JSON",
            extraParams: { MST: args.mst, knd: args.knd },
          });
    
          let parsed: Record<string, unknown>;
          try {
            parsed = JSON.parse(jsonText);
          } catch {
            return notFoundResponse(`3단비교 응답 파싱 실패 (mst=${args.mst})`, [
              `get_law_history(lawName="...") — 유효한 mst 확인`,
            ]);
          }
    
          // knd quirk — root key 분기
          const rootKey =
            args.knd === "1" ? "ThdCmpLawXService" : "LspttnThdCmpLawXService";
          const articlesKey =
            args.knd === "1" ? "인용조문삼단비교" : "위임조문삼단비교";
          const kindLabel = args.knd === "1" ? "인용조문" : "위임조문";
    
          const root = parsed[rootKey] as
            | { 기본정보?: BasicInfo; [k: string]: unknown }
            | undefined;
          if (!root) {
            return notFoundResponse(
              `3단비교 데이터 없음 (mst=${args.mst}, knd=${args.knd})`,
              [`get_law_history(lawName="...") — 유효한 mst 확인`]
            );
          }
    
          const basic = root.기본정보 ?? {};
          const lawName = basic.법령명 ?? "(법령명 없음)";
    
          if (basic.삼단비교존재여부 === "N") {
            return notFoundResponse(
              `${lawName} 3단비교 없음 (knd=${args.knd}, 삼단비교존재여부=N)`,
              [`get_three_tier(mst="${args.mst}", knd="${args.knd === "1" ? "2" : "1"}") — 다른 종류 시도`]
            );
          }
    
          const tier = root[articlesKey] as
            | { 법률조문?: ArticleNode | ArticleNode[] }
            | undefined;
          const articles = asArray(tier?.법률조문);
    
          let text = `=== ${lawName} — 3단비교 (${kindLabel}) ===\n`;
          text += `mst: ${basic.법령일련번호} / lawId: ${basic.법령ID}\n`;
          text += `시행: ${basic.시행일자} · 공포: ${basic.공포일자}\n\n`;
    
          if (articles.length === 0) {
            text += "(법률 조문 데이터 없음)\n";
          } else {
            // 위임/인용이 있는 조문만 (시행령조문/시행규칙조문 키 보유)
            const withDelegation = articles.filter(
              (a) => a.시행령조문 || a.시행규칙조문
            );
            text += `법률 조문 ${articles.length}개 중 ${kindLabel} 관계 ${withDelegation.length}개:\n\n`;
    
            for (let i = 0; i < withDelegation.length; i++) {
              if (text.length > MAX_BODY_CHARS) {
                text += `⋯ ${withDelegation.length - i}개 더 (12,000자 한도) ⋯\n`;
                break;
              }
              const law = withDelegation[i]!;
              text += formatNode(law, "");
    
              const decree = asArray(law.시행령조문);
              for (const d of decree) {
                text += formatNode(d, "  └─ ");
              }
              const rule = asArray(law.시행규칙조문);
              for (const r of rule) {
                text += formatNode(r, "    └─ ");
              }
              text += "\n";
            }
          }
    
          text = appendSuggestions(text, [
            {
              tool: "get_law_text",
              args: { mst: args.mst },
              reason: `${lawName} 본법 전문`,
            },
            {
              tool: "get_three_tier",
              args: { mst: args.mst, knd: args.knd === "1" ? "2" : "1" },
              reason: args.knd === "1" ? "위임조문 비교 (knd=2)" : "인용조문 비교 (knd=1)",
            },
          ]);
          text += `\n${formatLawAttribution(lawName)}`;
    
          return { content: [{ type: "text", text }] };
        } catch (err) {
          return formatToolError(err, "get_three_tier");
        }
      },
    };
  • Input schema (Zod) for get_three_tier: mst (required string, the law serial number) and knd (optional enum '1' or '2', default '2').
    const inputSchema = z.object({
      mst: z
        .string()
        .min(1)
        .describe(
          "법령일련번호 (search_law·get_law_history 결과). 본법 mst (시행령·시행규칙 mst 아님)."
        ),
      knd: z
        .enum(["1", "2"])
        .default("2")
        .describe(
          "비교 종류: 1=인용조문 (법률↔하위법령 인용 관계), 2=위임조문 (법률→시행령 위임 관계, 기본)"
        ),
    });
  • Tool registered in the ALL_TOOLS array in src/tools/registry.ts at line 76.
      getThreeTier,
      getArticleChangeHistory,
      getDelegatedLaws,
      getLawSystemTree,
      getIntelligentRelatedLaws,
      // W2 — terminology primitives
      getLegalTerm,
      getTermArticles,
      getLawAbbreviations,
      // W2.5 — navigation
      getLawTree,
      // W3 — Layer C RAG corpus (PIPC 가이드 + 상담사례, BM25 인덱스)
      searchPrivacyCorpus,
      searchPrivacyCases,
      searchPrivacyGuides,
      // W3 — Layer B+ hints (PIPC 공식 출처 인덱스화)
      getSectoralRelatedLaws,
      getPipcCuratedCorpus,
      // W4 — Validator
      verifyPipaCitation,
    ];
  • Import of getThreeTier from the get-three-tier.ts file.
    import { getThreeTier } from "./primitives/get-three-tier.js";
  • Helper functions normalizeJoNum (formats article number strings like '제3조') and formatNode (formats an article node with prefix indentation and content snippet).
    function normalizeJoNum(jo?: string, branch?: string): string {
      if (!jo) return "?";
      const num = String(parseInt(jo, 10) || jo);
      const br = branch && branch !== "00" ? `의${parseInt(branch, 10)}` : "";
      return `제${num}조${br}`;
    }
    
    function formatNode(node: ArticleNode, prefix: string): string {
      const num = normalizeJoNum(node.조번호, node.조가지번호);
      const title = node.조제목 ? ` ${node.조제목}` : "";
      const law = node.법령명 ? `[${node.법령명}] ` : "";
      let out = `${prefix}${law}${num}${title}\n`;
      const content = (node.조내용 || "").trim();
      if (content) {
        const snippet = content.length > 300 ? content.slice(0, 300) + "..." : content;
        out += `${prefix}  ${snippet}\n`;
      }
      return out;
    }
  • TypeScript interfaces ArticleNode and BasicInfo used for parsing the 3-tier comparison response data.
    interface ArticleNode {
      조번호?: string;
      조가지번호?: string;
      조제목?: string;
      조내용?: string;
      법령명?: string;
      시행령조문?: ArticleNode | ArticleNode[];
      시행규칙조문?: ArticleNode | ArticleNode[];
    }
    
    interface BasicInfo {
      법령일련번호?: string;
      법령ID?: string;
      법령명?: string;
      시행일자?: string;
      공포일자?: string;
      공포번호?: string;
      삼단비교존재여부?: string;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It fails to mention any behavioral traits such as required permissions, rate limits, side effects (e.g., no data modification), or the structure of the response. The example hints at output content but does not specify format or pagination.

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 relatively concise and front-loads the core purpose. It includes necessary parameter explanations and a usage example without unnecessary repetition. A minor improvement could be removing the workflow hint to focus solely on the tool's function.

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?

Given the tool's complexity and lack of output schema or annotations, the description is adequate but incomplete. It explains what the tool does and provides an example, but it does not describe the output format or how to interpret the results. The workflow hint partially compensates, but still leaves gaps for the agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already provides descriptions for both parameters (mst and knd). The description adds value by clarifying that mst should be the main law's serial number (not subordinate laws), and by explaining the meaning of knd values with an example (PIPA delegation). This goes beyond the schema's documentation.

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 the tool performs a three-tier (law, enforcement decree, enforcement regulation) delegation/reference comparison. It specifies the source (lawService) and gives an example (PIPA §29 → enforcement decree §30), which helps understand the resource. However, it does not explicitly differentiate from sibling tools like get_delegated_laws, which may have overlapping functionality.

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 implies that users should use this tool to check delegation/reference mappings, and then follow up with get_law_text and get_admin_rule_text. This provides a workflow hint, but there is no explicit guidance on when to use this tool versus alternatives, nor any mention of when not to use it.

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/scvcoder/korean-privacy-law-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server