get_taxlaw_page_text
Retrieve any HTML or text page from the Korean National Tax Service's law information system by its path, and convert it to plain text for content analysis.
Instructions
국세법령정보시스템 HTML/텍스트 페이지를 같은 사이트 경로로 조회해 텍스트로 변환합니다. 정적 자료(예: 세목별요약정보 /html/U_0101.html) 확인용입니다.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | 같은 사이트 내 경로. 예: /bg/USEBGG001M.do, /html/U_0101.html | |
| full | No |
Implementation Reference
- src/index.ts:100-103 (schema)Interface TaxlawPageTextArgs defines the input schema for the get_taxlaw_page_text tool: path (string, required) and full (boolean, optional).
interface TaxlawPageTextArgs { path?: string full?: boolean } - src/index.ts:534-546 (registration)Tool registration in the tools array. Defines name 'get_taxlaw_page_text', description, and inputSchema with required 'path' parameter and optional 'full' parameter.
{ name: "get_taxlaw_page_text", description: "국세법령정보시스템 HTML/텍스트 페이지를 같은 사이트 경로로 조회해 텍스트로 변환합니다. 정적 자료(예: 세목별요약정보 /html/U_0101.html) 확인용입니다.", inputSchema: { type: "object", properties: { path: { type: "string", description: "같은 사이트 내 경로. 예: /bg/USEBGG001M.do, /html/U_0101.html" }, full: { type: "boolean", default: false }, }, required: ["path"], additionalProperties: false, }, }, - src/index.ts:1515-1551 (handler)The getTaxlawPageText function is the actual handler/implementation. It fetches a page from TAXLAW_BASE + path, converts HTML to text, and returns the content. Throws if response is not OK or if extracted text is under 40 characters.
async function getTaxlawPageText(args: TaxlawPageTextArgs): Promise<ToolResponse> { const path = normalizeTaxlawPath(args.path) const response = await fetchWithRetry(`${TAXLAW_BASE}${path}`, { headers: { accept: "text/html,application/xhtml+xml,application/xml;q=0.9,text/plain;q=0.8,*/*;q=0.5", "user-agent": userAgent(), }, }) if (!response.ok) { await consume(response) throw new TaxlawMcpError(`Taxlaw page fetch failed (${response.status})`, ErrorCodes.API_ERROR) } const contentType = response.headers.get("content-type") || "N/A" const raw = await response.text() const body = /html|xml/i.test(contentType) || /<[^>]+>/.test(raw) ? htmlToText(raw) : decodeHtml(raw) const trimmedLength = body.trim().length if (trimmedLength < 40) { return notFoundResponse( `경로 ${path}의 본문이 비어 있거나 의미 있는 텍스트(${trimmedLength}자)를 포함하지 않습니다.`, [ "동적으로 채워지는 페이지일 가능성이 높습니다. call_taxlaw_action으로 해당 메뉴의 actionId를 호출하세요.", "list_taxlaw_site_menus의 note에 정적/동적 여부 안내가 있으니 확인하세요.", ], ) } const lines = [ "국세법령정보시스템 페이지 텍스트", `출처: ${TAXLAW_BASE}${path}`, `content-type: ${contentType}`, "주의: 아래 텍스트는 HTML 변환 결과이며, 표·이미지·동적 데이터(JS로 채워지는 목록 등)는 누락될 수 있습니다. 본문에 명시되지 않은 내용은 추론·생성하지 마세요.", "", truncate(body, args.full === true ? 50000 : 15000), ] return textResponse(lines.join("\n")) } - src/index.ts:1901-1903 (registration)Routing in handleToolCall: when name === 'get_taxlaw_page_text', calls getTaxlawPageText with input as TaxlawPageTextArgs.
if (name === "get_taxlaw_page_text") { return await getTaxlawPageText(input as TaxlawPageTextArgs) }