Skip to main content
Glama

search_treaties

Search bilateral and multilateral treaties using keywords, country code, conclusion date, and effective date filters.

Instructions

[조약] 조약(양자/다자) 검색. 국가코드·체결일·발효일 필터 가능.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNo검색 키워드 (예: '투자보장', '범죄인인도')
clsNo조약구분 (1=양자조약, 2=다자조약)
natCdNo국가코드 (예: 'US', 'JP')
eftYdNo발효일 (YYYYMMDD)
concYdNo체결일 (YYYYMMDD)
displayYes결과 수 (기본:20, 최대:100)
pageYes페이지 번호 (기본:1)
sortNo정렬: lasc/ldes(조약명), dasc/ddes(날짜)
apiKeyNo법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달

Implementation Reference

  • Main handler function for the search_treaties tool. Calls the LawApiClient to search treaties (lawSearch.do endpoint with target='trty'), parses the XML response via parseTreatyXML, and formats results into a text response including treaty serial number, name, number, conclusion date, effective date, type, and detail link.
    export async function searchTreaties(
      apiClient: LawApiClient,
      args: SearchTreatiesInput
    ): Promise<{ content: Array<{ type: string, text: string }>, isError?: boolean }> {
      try {
        const extraParams: Record<string, string> = {
          display: String(args.display || 20),
          page: String(args.page || 1),
        }
        if (args.query) extraParams.query = args.query
        if (args.cls) extraParams.cls = args.cls
        if (args.natCd) extraParams.natCd = args.natCd
        if (args.eftYd) extraParams.eftYd = args.eftYd
        if (args.concYd) extraParams.concYd = args.concYd
        if (args.sort) extraParams.sort = args.sort
    
        const xmlText = await apiClient.fetchApi({
          endpoint: "lawSearch.do",
          target: "trty",
          extraParams,
          apiKey: args.apiKey,
        })
    
        const result = parseTreatyXML(xmlText)
        const treaties = result.items
    
        if (result.totalCnt === 0) {
          const kw = args.query || "관련 키워드"
          const hint = [
            "검색 결과가 없습니다.\n\n개선 방법:",
            `  1. 단순 키워드: search_treaties(query="${kw.split(/\s+/)[0]}")`,
            `  2. 법령 검색: search_law(query="${kw}")`,
          ].join("\n")
          return { content: [{ type: "text", text: hint }], isError: true }
        }
    
        let output = `조약 검색 결과 (총 ${result.totalCnt}건, ${result.page}페이지):\n\n`
    
        for (const t of treaties) {
          output += `[${t.조약일련번호}] ${t.조약명}\n`
          output += `  조약번호: ${t.조약번호 || "N/A"}\n`
          output += `  체결일: ${t.체결일자 || "N/A"}\n`
          output += `  발효일: ${t.발효일자 || "N/A"}\n`
          output += `  구분: ${t.조약구분 || "N/A"}\n`
          if (t.조약상세링크) {
            output += `  링크: ${t.조약상세링크}\n`
          }
          output += `\n`
        }
    
        output += `\n전문을 조회하려면 get_treaty_text Tool을 사용하세요.\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 }
      }
    }
  • Zod validation schema for search_treaties input. Fields: query (keyword), cls (treaty type: 1=bilateral, 2=multilateral), natCd (country code), eftYd (effective date YYYYMMDD), concYd (conclusion date YYYYMMDD), display (1-100, default 20), page (default 1), sort (by name or date), and optional apiKey.
    export const searchTreatiesSchema = z.object({
      query: z.string().optional().describe("검색 키워드 (예: '투자보장', '범죄인인도')"),
      cls: z.enum(["1", "2"]).optional().describe("조약구분 (1=양자조약, 2=다자조약)"),
      natCd: z.string().optional().describe("국가코드 (예: 'US', 'JP')"),
      eftYd: z.string().optional().describe("발효일 (YYYYMMDD)"),
      concYd: z.string().optional().describe("체결일 (YYYYMMDD)"),
      display: z.number().min(1).max(100).default(20).describe("결과 수 (기본:20, 최대:100)"),
      page: z.number().min(1).default(1).describe("페이지 번호 (기본:1)"),
      sort: z.enum(["lasc", "ldes", "dasc", "ddes"]).optional()
        .describe("정렬: lasc/ldes(조약명), dasc/ddes(날짜)"),
      apiKey: z.string().optional().describe("법제처 Open API 인증키(OC). 사용자가 제공한 경우 전달"),
    })
  • Registration of search_treaties in the tool registry. Maps the name 'search_treaties' to its schema (searchTreatiesSchema) and handler (searchTreaties) within the treaties section of the allTools array.
    // === 조약 ===
    {
      name: "search_treaties",
      description: "[조약] 조약(양자/다자) 검색. 국가코드·체결일·발효일 필터 가능.",
      schema: searchTreatiesSchema,
      handler: searchTreaties
    },
  • Helper type (TreatyItem) and XML parser (parseTreatyXML) used by the search_treaties handler. Parses the 'TrtySearch' root tag with 'Trty' item tags, extracting treaty serial number, name, number, signature date (mapped as 체결일자), effective date, type, and detail link.
     * 조약 검색 결과 파싱
     */
    export interface TreatyItem {
      조약일련번호: string
      조약명: string
      조약번호: string
      체결일자: string
      발효일자: string
      조약구분: string
      조약상세링크: string
    }
    
    export function parseTreatyXML(xml: string) {
      return parseSearchXML<TreatyItem>(xml, "TrtySearch", "Trty", (content) => ({
        조약일련번호: extractTag(content, "조약일련번호"),
        조약명: extractTag(content, "조약명"),
        조약번호: extractTag(content, "조약번호"),
        체결일자: extractTag(content, "서명일자"),
        발효일자: extractTag(content, "발효일자"),
        조약구분: extractTag(content, "조약구분명"),
        조약상세링크: extractTag(content, "조약상세링크")
      }))
    }
Behavior2/5

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

No annotations are provided, so the description is the sole source of behavioral info. It mentions filters but does not disclose pagination behavior, sorting details, empty result handling, or authentication requirements (apiKey parameter exists but not explained).

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 a single, efficient sentence. It conveys the core idea without fluff, though it could benefit from listing filter options more clearly.

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 9 parameters and no output schema or annotations, the description is too brief. It fails to cover return format, pagination behavior (hints from schema but not explained), and does not contextualize how this fits into the broader tool ecosystem.

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 description coverage is 100%; the description adds a high-level filter context but does not deepen understanding beyond what the schema already provides for each parameter.

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 it searches treaties (bilateral/multilateral) and lists specific filters (country code, conclusion date, effective date). The purpose is specific and aligned with the tool name, but it does not explicitly differentiate from sibling search tools like search_law.

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 on when to use this tool versus alternatives (e.g., search_law, search_precedents). It does not mention prerequisites, context, 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