Skip to main content
Glama

get_admin_rule

Get the full text of an administrative rule by its ID. Use after searching for rules.

Instructions

[행정규칙] 행정규칙 전문 조회.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes행정규칙ID (search_admin_rule에서 획득)
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Main handler function for the get_admin_rule tool. Takes an API client and input (id, apiKey), fetches admin rule XML from the law API, parses it using DOMParser, and extracts the rule name, date, type, organization, article contents, addendums, and annexes for display.
    export async function getAdminRule(
      apiClient: LawApiClient,
      input: GetAdminRuleInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        const xmlText = await apiClient.getAdminRule(input.id, input.apiKey)
    
        const parser = new DOMParser()
        const doc = parser.parseFromString(xmlText, "text/xml")
    
        // 행정규칙 정보 추출
        const ruleName = doc.getElementsByTagName("행정규칙명")[0]?.textContent || "알 수 없음"
        const promDate = doc.getElementsByTagName("공포일자")[0]?.textContent || ""
        const orgName = doc.getElementsByTagName("소관부처")[0]?.textContent || ""
        const ruleType = doc.getElementsByTagName("행정규칙종류")[0]?.textContent || ""
    
        let resultText = `행정규칙명: ${ruleName}\n`
        if (promDate) resultText += `공포일: ${promDate}\n`
        if (ruleType) resultText += `종류: ${ruleType}\n`
        if (orgName) resultText += `소관부처: ${orgName}\n`
        resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n\n`
    
        // 조문 추출 - <조문내용> 태그 사용
        const joContents = doc.getElementsByTagName("조문내용")
    
        if (joContents.length === 0) {
          // 첨부파일 확인
          const attachments = doc.getElementsByTagName("첨부파일링크")
          if (attachments.length > 0) {
            resultText += "⚠️  이 행정규칙은 조문 형식이 아닌 첨부파일로 제공됩니다.\n\n"
            resultText += "📎 첨부파일:\n"
            for (let i = 0; i < attachments.length; i++) {
              const link = attachments[i].textContent || ""
              if (link) {
                resultText += `   ${i + 1}. ${link}\n`
              }
            }
            return {
              content: [{
                type: "text",
                text: truncateResponse(resultText)
              }]
            }
          }
    
          return {
            content: [{
              type: "text",
              text: "행정규칙 전문을 조회할 수 없습니다.\n\n" +
                    "⚠️  법제처 API 제한: 일부 행정규칙은 전문 조회가 지원되지 않습니다.\n" +
                    "💡 대안: search_admin_rule 결과의 '행정규칙상세링크'를 통해 웹에서 확인하세요."
            }],
            isError: true
          }
        }
    
        // 조문내용이 비어있는지 확인
        let hasContent = false
        for (let i = 0; i < joContents.length; i++) {
          const content = joContents[i].textContent?.trim() || ""
          if (content.length > 0) {
            hasContent = true
            break
          }
        }
    
        if (!hasContent) {
          // 첨부파일 확인
          const attachments = doc.getElementsByTagName("첨부파일링크")
          if (attachments.length > 0) {
            resultText += "⚠️  이 행정규칙은 조문 형식이 아닌 첨부파일로 제공됩니다.\n\n"
            resultText += "📎 첨부파일:\n"
            for (let i = 0; i < attachments.length; i++) {
              const link = attachments[i].textContent || ""
              if (link) {
                resultText += `   ${i + 1}. ${link}\n`
              }
            }
          } else {
            resultText += "⚠️  이 행정규칙은 조문 내용이 비어있습니다."
          }
          return {
            content: [{
              type: "text",
              text: truncateResponse(resultText)
            }]
          }
        }
    
        // 조문 내용 출력
        for (let i = 0; i < joContents.length; i++) {
          const joContent = joContents[i].textContent?.trim() || ""
    
          if (joContent.length > 0) {
            resultText += `${joContent}\n\n`
          }
        }
    
        // 부칙 추가
        const addendums = doc.getElementsByTagName("부칙내용")
        if (addendums.length > 0) {
          resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n부칙\n━━━━━━━━━━━━━━━━━━━━━━\n\n`
          for (let i = 0; i < addendums.length; i++) {
            const content = addendums[i].textContent?.trim() || ""
            if (content.length > 0) {
              resultText += `${content}\n\n`
            }
          }
        }
    
        // 별표 추가
        const annexes = doc.getElementsByTagName("별표내용")
        if (annexes.length > 0) {
          resultText += `\n━━━━━━━━━━━━━━━━━━━━━━\n별표\n━━━━━━━━━━━━━━━━━━━━━━\n\n`
          for (let i = 0; i < annexes.length; i++) {
            const title = doc.getElementsByTagName("별표제목")[i]?.textContent?.trim() || ""
            const content = annexes[i].textContent?.trim() || ""
    
            if (title) {
              resultText += `[${title}]\n`
            }
            if (content.length > 0) {
              resultText += `${content}\n\n`
            }
          }
        }
    
        return {
          content: [{
            type: "text",
            text: truncateResponse(resultText)
          }]
        }
      } catch (error) {
        return formatToolError(error, "get_admin_rule")
      }
    }
  • Zod schema for get_admin_rule input validation. Requires 'id' (admin rule ID from search) and optional 'apiKey'.
    export const GetAdminRuleSchema = z.object({
      id: z.string().describe("행정규칙ID (search_admin_rule에서 획득)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달")
    })
  • Registers the tool with name 'get_admin_rule' in the tool registry, linking it to GetAdminRuleSchema and getAdminRule handler.
    {
      name: "get_admin_rule",
      description: "[행정규칙] 행정규칙 전문 조회.",
      schema: GetAdminRuleSchema,
      handler: getAdminRule
    },
  • API client helper that makes the actual HTTP call to the law API's lawService.do endpoint with target=admrul and the given ID to fetch admin rule XML data.
    async getAdminRule(id: string, apiKey?: string): Promise<string> {
      const apiParams = new URLSearchParams({
        target: "admrul",
        OC: this.getApiKey(apiKey),
        type: "XML",
        ID: id,
      })
    
      const url = `${LAW_API_BASE}/lawService.do?${apiParams.toString()}`
      const text = await this.fetchText(url, "getAdminRule")
      this.checkHtmlError(text, "행정규칙을 찾을 수 없습니다. ID를 확인해주세요")
    
      return text
    }
  • Tool chain configuration linking search_admin_rule to get_admin_rule as the detail tool, with the detail parameter being 'id'.
    search_admin_rule: {
      detailTool: "get_admin_rule",
      detailParam: "id",
      idRegex: /행정규칙ID:\s*(\S+)/,  // 행정규칙은 [ID] 형식이 아님
    },
Behavior2/5

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

There are no annotations, and the description only says 'retrieve full text'. It does not disclose whether this is a read operation (implied), any authentication requirements beyond the API key, or error behavior for invalid IDs.

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

Conciseness3/5

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

The description is a single sentence with no waste, but it is under-specified. Conciseness is good but at the expense of necessary detail.

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?

Given no output schema and a simple retrieval tool, the description could mention the return format or any limitations. It fails to provide enough context for an agent to understand what the full text contains.

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% with clear parameter descriptions. The tool description adds no additional meaning beyond what the schema already provides, so baseline score of 3 is appropriate.

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

Purpose3/5

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

The description states the tool retrieves the full text of an administrative rule, which is clear but essentially restates the tool name. It does not differentiate from sibling tools like 'get_ordinance' or 'get_law_text', which also retrieve full texts of specific document types.

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 is provided on when to use this tool versus alternatives. There is no mention of prerequisites (e.g., needing an ID from search_admin_rule) or 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/workbookbulb863/korean-law-alio-mcp'

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