Skip to main content
Glama
scvcoder

korean-privacy-law-mcp

by scvcoder

get_law_text

Retrieve the full text of Korean privacy laws by providing a law serial number (mst) or law ID. Optionally specify an effective date to get the law text at a specific point in time.

Instructions

법령 본문 조회 (법제처 lawService · target=law). mst(또는 lawId)로 법령 전체 본문 가져옴. 조문 단위로 정렬된 결과 반환. 시점 본문은 efYd=YYYYMMDD. 큰 법령은 12,000자에서 잘림 (특정 조문은 v1.1의 get_law_article 사용). 다음: get_related_laws(lawId)로 관계, get_law_history(lawId)로 개정 이력.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mstNo법령일련번호 (search_law 결과의 [브래킷] 안 숫자)
lawIdNo법령ID (mst와 택1)
efYdNo시행일자 YYYYMMDD (시점별 본문 조회용, 미지정 시 현행)

Implementation Reference

  • Main tool implementation: defines the 'get_law_text' tool with name, description, inputSchema (zod), and async handler. Handler fetches law text from lawService.do API, parses JSON response, extracts articles and metadata, formats output with up to 12,000 characters, and appends suggestions for related tools.
    export const getLawText: Tool<typeof inputSchema> = {
      name: "get_law_text",
      description:
        "법령 본문 조회 (법제처 lawService · target=law). mst(또는 lawId)로 법령 전체 본문 가져옴. " +
        "조문 단위로 정렬된 결과 반환. 시점 본문은 efYd=YYYYMMDD. " +
        "큰 법령은 12,000자에서 잘림 (특정 조문은 v1.1의 get_law_article 사용). " +
        "다음: get_related_laws(lawId)로 관계, get_law_history(lawId)로 개정 이력.",
      inputSchema,
    
      async handler(args, client) {
        try {
          if (!args.mst && !args.lawId) {
            throw new ValidationError("mst 또는 lawId 필수");
          }
    
          const extraParams: Record<string, string> = {};
          if (args.mst) extraParams.MST = args.mst;
          if (args.lawId) extraParams.ID = args.lawId;
          if (args.efYd) extraParams.efYd = args.efYd;
    
          const jsonText = await client.fetchApi({
            endpoint: "lawService.do",
            target: "law",
            type: "JSON",
            extraParams,
          });
    
          let parsed: { 법령?: LawData };
          try {
            parsed = JSON.parse(jsonText) as { 법령?: LawData };
          } catch {
            return notFoundResponse(
              `법령 본문 응답을 파싱할 수 없음 (mst=${args.mst ?? "-"}, lawId=${
                args.lawId ?? "-"
              })`,
              [`search_law(query="...") — 유효한 mst를 다시 확인`]
            );
          }
    
          const law = parsed.법령;
          if (!law) {
            return notFoundResponse(
              `법령 데이터 없음 (mst=${args.mst ?? "-"}, lawId=${args.lawId ?? "-"})`,
              [`search_law(query="...") — 유효한 mst 확인`]
            );
          }
    
          const info = law.기본정보 ?? {};
          const lawName =
            info.법령명_한글 ?? info.법령명한글 ?? "(법령명 없음)";
    
          let text = `=== ${lawName} ===\n`;
          if (info.공포일자) text += `공포: ${info.공포일자}\n`;
          if (info.시행일자 || info.최종시행일자)
            text += `시행: ${info.시행일자 ?? info.최종시행일자}\n`;
    
          const ministry =
            typeof info.소관부처 === "string"
              ? info.소관부처
              : info.소관부처?.content;
          if (ministry) text += `소관: ${ministry}\n`;
          text += "\n";
    
          const units = asArray(law.조문?.조문단위).filter(
            (u): u is ArticleUnit => u !== undefined && u !== null
          );
    
          const articles = units.filter((u) => u.조문여부 === "조문");
          if (articles.length === 0) {
            text += "(조문 데이터 없음 — 부칙·별표만 존재할 수 있음)\n";
          } else {
            text += `조문 ${articles.length}개:\n\n`;
            for (const article of articles) {
              const num = article.조문번호 ?? "?";
              const branch = article.조문가지번호 ? `의${article.조문가지번호}` : "";
              const title = article.조문제목 ? ` (${article.조문제목})` : "";
              text += `[제${num}조${branch}]${title}\n`;
              if (article.조문내용) {
                text += `${article.조문내용.trim()}\n`;
              }
              text += "\n";
              if (text.length > MAX_BODY_CHARS) {
                const remaining = articles.length - articles.indexOf(article) - 1;
                text +=
                  remaining > 0
                    ? `...\n⋯ ${remaining}개 조문 생략 (12,000자 한도) — v1.1의 get_law_article로 특정 조문 조회 ⋯\n`
                    : "";
                break;
              }
            }
          }
    
          const relatedArgs: { mst?: string; lawId?: string } = {};
          if (args.mst) relatedArgs.mst = args.mst;
          else if (args.lawId) relatedArgs.lawId = args.lawId;
    
          text = appendSuggestions(text, [
            {
              tool: "get_related_laws",
              args: relatedArgs,
              reason: `${lawName} 시행령·시행규칙·고시 등 하위 규칙`,
            },
            {
              tool: "get_annexes",
              args: { lawName },
              reason: "별표·서식 조회",
            },
          ]);
          text += `\n${formatLawAttribution(lawName)}`;
    
          return { content: [{ type: "text", text }] };
        } catch (err) {
          return formatToolError(err, "get_law_text");
        }
      },
    };
  • Input validation schema using zod: accepts optional mst (law serial number), lawId (alternative ID), efYd (effective date YYYYMMDD for point-in-time lookup). Uses refine to require at least one of mst or lawId.
    const inputSchema = z
      .object({
        mst: z
          .string()
          .optional()
          .describe("법령일련번호 (search_law 결과의 [브래킷] 안 숫자)"),
        lawId: z.string().optional().describe("법령ID (mst와 택1)"),
        efYd: z
          .string()
          .regex(/^\d{8}$/)
          .optional()
          .describe("시행일자 YYYYMMDD (시점별 본문 조회용, 미지정 시 현행)"),
      })
      .refine((d) => d.mst || d.lawId, {
        message: "mst 또는 lawId 중 하나는 필수입니다",
      });
  • TypeScript interfaces ArticleUnit and LawData used to type the parsed API response containing article units and basic law metadata.
    interface ArticleUnit {
      조문번호?: string;
      조문가지번호?: string;
      조문제목?: string;
      조문내용?: string;
      조문여부?: string;
      항?: unknown;
    }
    
    interface LawData {
      기본정보?: {
        법령명_한글?: string;
        법령명한글?: string;
        공포일자?: string;
        시행일자?: string;
        최종시행일자?: string;
        소관부처?: { content?: string } | string;
      };
      조문?: { 조문단위?: ArticleUnit | ArticleUnit[] };
      부칙?: unknown;
    }
  • Import of getLawText from primitives/get-law-text.js into the tool registry.
    import { getLawText } from "./primitives/get-law-text.js";
  • Registration of getLawText in the ALL_TOOLS array, making it available to the MCP server.
    getLawText,
Behavior4/5

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

With no annotations, the description carries full burden. It discloses truncation behavior at 12,000 characters and the efYd parameter for point-in-time queries. It does not mention authentication or rate limits, which are likely not needed for public data, so a 4 is appropriate.

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?

Three sentences: purpose, truncation note, and sibling tool references. No fluff, front-loaded with core functionality. Highly efficient.

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

Completeness4/5

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

Given no output schema, the description mentions return format (sorted by article unit) and truncation. It also provides next steps. Could mention if metadata like law name is included, but overall adequate.

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

Parameters5/5

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

Schema coverage is 100% with good parameter descriptions. The description adds value: clarifies that mst comes from search results (bracketed number), efYd format, and that mst and lawId are alternatives. This goes 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 retrieves the full text of a law using mst or lawId, and distinguishes itself from sibling tools like get_law_article for specific articles. The verb '조회' (retrieve) and resource '법령 본문' (law text) are specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states when to use this tool (full text) and when not (large laws truncated at 12,000 characters, suggesting get_law_article). Also provides alternatives: get_related_laws and get_law_history for related tasks.

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