Skip to main content
Glama

get_treaty_text

Get the full text of a Korean treaty in Korean or English by providing its serial number from a treaty search.

Instructions

[조약] 조약 본문 조회. 한글/영문 선택 가능.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes조약일련번호 (search_treaties 결과에서 획득)
chrClsCdYes언어 (010202=한글, 010203=영문, 기본:한글)010202
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Zod schema for get_treaty_text: validates 'id' (treaty serial number), 'chrClsCd' (language code, default Korean), and optional 'apiKey'.
    export const getTreatyTextSchema = z.object({
      id: z.string().describe("조약일련번호 (search_treaties 결과에서 획득)"),
      chrClsCd: z.enum(["010202", "010203"]).default("010202")
        .describe("언어 (010202=한글, 010203=영문, 기본:한글)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"),
    })
  • Main handler function for get_treaty_text. Fetches treaty text via LawApiClient, parses JSON response, extracts treaty info and body text, returns formatted output.
    export async function getTreatyText(
      apiClient: LawApiClient,
      args: GetTreatyTextInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        const extraParams: Record<string, string> = {
          ID: String(args.id),
          chrClsCd: String(args.chrClsCd || "010202"),
        }
    
        const responseText = await apiClient.fetchApi({
          endpoint: "lawService.do",
          target: "trty",
          type: "JSON",
          extraParams,
          apiKey: args.apiKey,
        })
    
        let data: any
        try {
          data = JSON.parse(responseText)
        } catch {
          throw new Error("Failed to parse JSON response from API")
        }
    
        // API는 BothTrtyService 또는 TrtyService로 응답
        const trty = data.BothTrtyService || data.TrtyService
        if (!trty) {
          throw new Error("Treaty not found or invalid response format")
        }
    
        // 조약내용이 중첩 객체일 수 있음
        const bodyObj = trty.조약내용 || {}
        const bodyText = typeof bodyObj === "string" ? bodyObj : bodyObj.조약내용 || ""
    
        const basic = {
          조약명: trty.조약명,
          조약번호: trty.조약번호,
          체결일자: trty.체결일자,
          발효일자: trty.발효일자,
          조약구분: trty.조약구분명,
          체결상대국: trty.체결상대국,
        }
    
        let output = `=== ${basic.조약명 || "조약"} ===\n\n`
    
        output += `기본 정보:\n`
        output += `  조약번호: ${basic.조약번호 || "N/A"}\n`
        output += `  체결일: ${basic.체결일자 || "N/A"}\n`
        output += `  발효일: ${basic.발효일자 || "N/A"}\n`
        output += `  구분: ${basic.조약구분 || "N/A"}\n`
        output += `  체결상대국: ${basic.체결상대국 || "N/A"}\n\n`
    
        if (bodyText) {
          output += `조약 본문:\n${bodyText}\n`
        }
    
        return {
          content: [{
            type: "text",
            text: truncateResponse(output)
          }]
        }
      } catch (error) {
        const msg = error instanceof Error ? error.message : String(error)
        return { content: [{ type: "text", text: `Error: ${msg}` }], isError: true }
      }
    }
  • Registration of the 'get_treaty_text' tool in the tool registry with name, description, schema, and handler.
    {
      name: "get_treaty_text",
      description: "[조약] 조약 본문 조회. 한글/영문 선택 가능.",
      schema: getTreatyTextSchema,
      handler: getTreatyText
    },
  • Import of getTreatyText and getTreatyTextSchema from the treaties module.
    import { searchTreaties, searchTreatiesSchema, getTreatyText, getTreatyTextSchema } from "./tools/treaties.js"
Behavior2/5

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

No annotations are provided, and the description lacks disclosure of behavioral traits such as idempotency, required permissions (beyond the apiKey parameter), rate limits, or side effects. It is a read operation, but this is not explicitly stated.

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 extremely concise with no redundant information. It front-loads the core action. However, it could be slightly more structured (e.g., separate sentences for parameters).

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 schema describes all 3 parameters fully and no output schema exists, the description adequately covers the input context. However, it lacks information about output format, error conditions, or usage examples, which could help in complex scenarios.

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 description adds meaning beyond the schema: it explains that 'id' comes from search_treaties, 'chrClsCd' enum values map to Korean/English with a Korean default, and 'apiKey' is an authentication key. This enriches the schema definitions, which are already present.

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 it retrieves treaty text and allows language selection (Korean/English). It distinguishes itself from sibling tools like get_law_text and get_ordinance_text by specifying the resource type (treaty).

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?

The description provides no guidance on when to use this tool versus alternatives. It does not mention when not to use it or list related tools for different document types.

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