get_taxlaw_basic_ruling_text
Retrieve the full text of a basic tax ruling from the Korean National Tax Service database. Uses a law ID from a previous list result; optionally filter by year or search within the text.
Instructions
국세법령정보시스템 기본통칙 본문 조회. list_taxlaw_basic_ruling_laws 결과의 lawId 사용.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lawId | Yes | 기본통칙 법령 ID(ntstBscId) | |
| year | No | 연도. 미입력 시 최신 연도 | |
| query | No | 통칙 제목/본문 내 필터 | |
| display | No | ||
| full | No |
Implementation Reference
- src/index.ts:77-83 (schema)Input schema (BasicRulingTextArgs) for get_taxlaw_basic_ruling_text with lawId, year, query, display, full parameters.
interface BasicRulingTextArgs { lawId?: string year?: string query?: string display?: number full?: boolean } - src/index.ts:591-606 (registration)Tool registration in the tools array with name 'get_taxlaw_basic_ruling_text', description, and inputSchema definition.
{ name: "get_taxlaw_basic_ruling_text", description: "국세법령정보시스템 기본통칙 본문 조회. list_taxlaw_basic_ruling_laws 결과의 lawId 사용.", inputSchema: { type: "object", properties: { lawId: { type: "string", description: "기본통칙 법령 ID(ntstBscId)" }, year: { type: "string", pattern: "^\\d{4}$", description: "연도. 미입력 시 최신 연도" }, query: { type: "string", description: "통칙 제목/본문 내 필터" }, display: { type: "number", minimum: 1, maximum: 200, default: 30 }, full: { type: "boolean", default: false }, }, required: ["lawId"], additionalProperties: false, }, }, - src/index.ts:1584-1633 (handler)The async function getTaxlawBasicRulingText that executes the tool logic: fetches basic ruling text from the NTS API using actionId ASISTD001MR02, filters by query, and formats results.
async function getTaxlawBasicRulingText(args: BasicRulingTextArgs): Promise<ToolResponse> { const lawId = requireString("lawId", args.lawId) validateYear(args.year) const year = args.year || await getLatestBasicRulingYear(lawId) const display = asPositiveInt(args.display, 30, 200) const data = await postTaxlawAction<BasicRulingData>( "ASISTD001MR02", { ntstBscId: lawId, rgtYr: year }, `/st/USESTD002M.do?ntstBscId=${encodeURIComponent(lawId)}`, ) const query = cleanText(args.query).toLowerCase() const allItems = [ ...(data.ASISTD001MR02?.bscExrDVOList || []), ...(data.ASISTD001MR02?.bscExrDVOArList || []), ] const textItems = allItems .filter((item) => item.lawClCd === "5" || cleanText(htmlToText(item.ntstTextCntn || ""))) .filter((item) => { if (!query) return true return `${cleanText(item.ntstTextNm)} ${cleanText(htmlToText(item.ntstTextCntn || ""))}`.toLowerCase().includes(query) }) if (textItems.length === 0) { return notFoundResponse(`기본통칙 ${lawId}/${year}에서 '${args.query || "(전체)"}' 항목을 찾을 수 없습니다.`, [ "list_taxlaw_basic_ruling_laws로 lawId를 확인하세요.", "year를 비우면 최신 연도로 조회합니다.", ]) } const shown = args.full ? textItems : textItems.slice(0, display) const lines = [ `국세법령정보시스템 기본통칙 본문`, `출처: ${TAXLAW_BASE}/st/USESTD002M.do?ntstBscId=${encodeURIComponent(lawId)}`, `lawId: ${lawId} / year: ${year} / 검색어: ${args.query || "(전체)"}`, `총 ${textItems.length.toLocaleString()}개 중 ${shown.length.toLocaleString()}개 표시`, "", ] for (const item of shown) { const body = htmlToText(item.ntstTextCntn || "") lines.push(`[${item.ntstExrBaseSn || "N/A"}] ${cleanText(item.ntstTextNm) || "N/A"}`) if (body) lines.push(truncate(body, args.full ? 3000 : 1200)) lines.push("") } if (!args.full && textItems.length > shown.length) { lines.push(`더 많은 항목이 있습니다. display를 늘리거나 full=true로 재조회하세요.`) } return textResponse(truncate(lines.join("\n"), args.full ? 50000 : 30000)) } - src/index.ts:1573-1582 (handler)Helper function getLatestBasicRulingYear that fetches the latest year for a given lawId using actionId ASISTD001MR03.
async function getLatestBasicRulingYear(lawId: string): Promise<string> { const data = await postTaxlawAction<BasicRulingData>( "ASISTD001MR03", { ntstBscId: lawId }, `/st/USESTD002M.do?ntstBscId=${encodeURIComponent(lawId)}`, ) const year = data.ASISTD001MR03?.bscExrDVOList?.map((item) => item.rgtYr).find(Boolean) if (!year) throw new TaxlawMcpError(`기본통칙 연도 목록을 찾을 수 없습니다: ${lawId}`, ErrorCodes.NOT_FOUND) return year } - src/index.ts:1913-1915 (registration)Dispatcher call in handleToolCall that routes 'get_taxlaw_basic_ruling_text' to getTaxlawBasicRulingText.
if (name === "get_taxlaw_basic_ruling_text") { return await getTaxlawBasicRulingText(input as BasicRulingTextArgs) }