Skip to main content
Glama

search_alio_regulation_text

Search full text of Korean regulations and institution internal rules by keyword. Filter by institution code and get relevant snippets from matching regulations.

Instructions

[ALIO] 전체 수집된 규정 본문에서 키워드 전문검색. institutions 로 기관 제한 가능. 히트 라인/스니펫 반환.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes검색 키워드(2자 이상)
institutionsNo대상 기관코드(또는 기관명) 목록. 생략 시 전체 기관
maxPerRegulationYes규정당 최대 스니펫 수
maxResultsYes전체 최대 결과 수

Implementation Reference

  • Main handler function for search_alio_regulation_text. Takes query string, optional institutions filter, maxPerRegulation, and maxResults. Loads the regulation index, filters by institutions, searches each regulation's markdown for the query string, collects snippets with line numbers, and returns formatted results.
    export async function searchAlioRegulationText(
      _api: LawApiClient,
      input: SearchAlioRegulationTextInput
    ): Promise<ToolResponse> {
      try {
        const idx = await loadIndex()
        const needle = input.query.trim()
        if (!needle) {
          return { content: [{ type: "text", text: "검색어가 비어 있습니다." }], isError: true }
        }
    
        // 대상 기관 필터
        const allowedApbaIds: Set<string> | null = input.institutions
          ? new Set(
              input.institutions
                .map((s) => findInstitution(idx, s)?.apbaId)
                .filter((x): x is string => !!x)
            )
          : null
    
        const targets = idx.flatRegulations.filter(
          (r) => !allowedApbaIds || allowedApbaIds.has(r.inst.apbaId)
        )
    
        const results: Array<{
          instName: string
          apbaId: string
          title: string
          regId: string
          fallbackParser?: string
          snippets: Array<{ lineNo: number; text: string }>
        }> = []
    
        for (const { inst, entry } of targets) {
          if (results.length >= input.maxResults) break
          if (!entry.mdPath) continue
          const md = await readRegulationMd(inst.apbaId, entry.regId)
          if (!md) continue
          if (!md.includes(needle)) continue
          const snippets = findSnippets(md, needle, input.maxPerRegulation)
          if (snippets.length === 0) continue
          results.push({
            instName: inst.apbaNa,
            apbaId: inst.apbaId,
            title: entry.title,
            regId: entry.regId,
            fallbackParser: entry.fallbackParser,
            snippets,
          })
        }
    
        if (results.length === 0) {
          return { content: [{ type: "text", text: `'${needle}' 히트 없음` }] }
        }
    
        const lines: string[] = []
        lines.push(`'${needle}' — ${results.length}개 규정에서 히트`)
        lines.push("")
        for (const r of results) {
          const ocrBadge = r.fallbackParser ? ` [OCR:${r.fallbackParser}]` : ""
          lines.push(`▶ [${r.apbaId}] ${r.instName} — ${r.title} (regId=${r.regId})${ocrBadge}`)
          for (const s of r.snippets) {
            lines.push(`  L${s.lineNo}: ${s.text.slice(0, 180)}`)
          }
          lines.push("")
        }
        const ocrCount = results.filter((r) => r.fallbackParser).length
        if (ocrCount > 0) {
          lines.push(`ℹ️ ${ocrCount}건은 OCR 변환 본문이므로 정확한 인용이 필요하면 원본 PDF 참조 권장.`)
        }
        return { content: [{ type: "text", text: truncateResponse(lines.join("\n")) }] }
      } catch (err) {
        return formatToolError(err, "search_alio_regulation_text")
      }
  • Zod schema for search_alio_regulation_text input validation. Defines: query (string, min 2 chars), institutions (optional array of strings), maxPerRegulation (number 1-5, default 2), maxResults (number 1-50, default 20).
    export const SearchAlioRegulationTextSchema = z.object({
      query: z.string().min(2).describe("검색 키워드(2자 이상)"),
      institutions: z
        .array(z.string())
        .optional()
        .describe("대상 기관코드(또는 기관명) 목록. 생략 시 전체 기관"),
      maxPerRegulation: z.number().min(1).max(5).default(2).describe("규정당 최대 스니펫 수"),
      maxResults: z.number().min(1).max(50).default(20).describe("전체 최대 결과 수"),
    })
  • Tool registration in the tool registry. Maps name 'search_alio_regulation_text' to its schema (SearchAlioRegulationTextSchema) and handler (searchAlioRegulationText) with a description.
    {
      name: "search_alio_regulation_text",
      description: "[ALIO] 전체 수집된 규정 본문에서 키워드 전문검색. institutions 로 기관 제한 가능. 히트 라인/스니펫 반환.",
      schema: SearchAlioRegulationTextSchema,
      handler: searchAlioRegulationText
    },
  • Import of the searchAlioRegulationText handler and SearchAlioRegulationTextSchema from the implementation file into the tool registry.
    import { searchAlioRegulationText, SearchAlioRegulationTextSchema } from "./tools/alio/search-regulation-text.js"
  • Helper function findSnippets that scans through markdown lines and collects snippet lines containing the search keyword, up to maxPerRegulation snippets.
    function findSnippets(
      md: string,
      needle: string,
      max: number
    ): Array<{ lineNo: number; text: string }> {
      const out: Array<{ lineNo: number; text: string }> = []
      const lines = md.split(/\r?\n/)
      for (let i = 0; i < lines.length && out.length < max; i++) {
        if (lines[i].includes(needle)) {
          out.push({ lineNo: i + 1, text: lines[i] })
        }
      }
      return out
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It mentions the return format (hit lines/snippets) but lacks details on authorization, rate limits, or potential side effects. The description adds some value beyond the schema but is not fully transparent.

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?

The description is a single concise sentence that front-loads the main action and key features. No unnecessary words.

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 the complexity and the presence of sibling tools, the description covers the essential aspects: what it searches (regulation text), how to filter (institutions), and what it returns (snippets). It lacks explicit mention of pagination or ordering, but the schema parameters imply that. Overall, it is adequate but could include more about result handling.

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?

The input schema has 100% description coverage, so the baseline is 3. The description adds context about searching regulation full text and snippet return, but does not significantly enhance understanding of the parameters 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 it searches the full text of collected regulations by keyword, can be limited by institutions, and returns hit lines/snippets. This is specific and distinct from sibling tools like 'search_law' or 'search_precedents'.

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

Usage Guidelines4/5

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

The description provides context on how to use the tool (keyword search, institutional filter) but does not explicitly say when to use it over alternatives or when not to use it. Given the diverse siblings, some guidance would help but the purpose is clear.

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