get_taxlaw_document_text
Retrieve full text of Korean tax law documents using a document ID. Optionally specify document type and include extended content.
Instructions
국세법령정보시스템 문서 상세 조회. search_taxlaw_documents/search_taxlaw_all 결과의 DOC_ID/id를 사용.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 검색 결과의 DOC_ID 또는 DOCID. 예: 001_200000000000019482 또는 200000000000019482 | |
| docType | No | 알고 있는 경우 문서유형. 미입력 시 질의/판례 상세를 순차 시도 | |
| full | No | true면 HTML 원문 변환 텍스트를 더 길게 포함 |
Implementation Reference
- src/index.ts:1309-1344 (handler)The main handler function `getTaxlawDocumentText` that executes the tool logic. It takes a `DocumentDetailArgs` (id, docType, full), normalizes the ID, attempts to fetch document detail via `postTaxlawAction('ASIQTB002PR01', ...)`, and formats the response.
async function getTaxlawDocumentText(args: DocumentDetailArgs): Promise<ToolResponse> { const rawId = requireString("id", args.id) const id = normalizeDetailId(rawId) const knownCode = docCodeFromType(args.docType) const attempts = knownCode ? [refererForDoc(knownCode, id)] : [`/qt/USEQTA002P.do?ntstDcmId=${encodeURIComponent(id)}`, `/pd/USEPDA002P.do?ntstDcmId=${encodeURIComponent(id)}`] let lastError: unknown for (const referer of attempts) { try { const data = await postTaxlawAction<TaxlawDetailData>( "ASIQTB002PR01", { dcmDVO: { ntstDcmId: id } }, referer, ) const detail = data.ASIQTB002PR01 const dcm = detail.dcmDVO if (!dcm) continue return textResponse(formatDocumentDetail(id, dcm, detail, args.full === true, referer)) } catch (error) { lastError = error } } if (lastError instanceof TaxlawMcpError) { if (attempts.length === 1) throw lastError if (lastError.code !== ErrorCodes.NOT_FOUND && lastError.code !== ErrorCodes.PARSE_ERROR) { throw lastError } } return notFoundResponse(`국세법령정보시스템 문서 상세를 찾을 수 없습니다: ${rawId}`, [ "search_taxlaw_documents로 DOC_ID를 다시 확인하세요.", "docType을 알고 있으면 함께 입력하세요.", ]) } - src/index.ts:481-494 (registration)Tool registration in the `tools` array. Defines name 'get_taxlaw_document_text', description, and inputSchema with parameters: id (required), docType, full.
{ name: "get_taxlaw_document_text", description: "국세법령정보시스템 문서 상세 조회. search_taxlaw_documents/search_taxlaw_all 결과의 DOC_ID/id를 사용.", inputSchema: { type: "object", properties: { id: { type: "string", description: "검색 결과의 DOC_ID 또는 DOCID. 예: 001_200000000000019482 또는 200000000000019482" }, docType: { type: "string", enum: ["advance", "reply", "tax_standard", "written", "tax_pre_review", "objection", "review", "tribunal", "precedent", "constitutional", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10"], description: "알고 있는 경우 문서유형. 미입력 시 질의/판례 상세를 순차 시도" }, full: { type: "boolean", default: false, description: "true면 HTML 원문 변환 텍스트를 더 길게 포함" }, }, required: ["id"], additionalProperties: false, }, }, - src/index.ts:1346-1391 (handler)The `formatDocumentDetail` helper function that formats the document detail response into human-readable text, including ID, type, date, related laws, gist, body text, and precedents.
function formatDocumentDetail(id: string, dcm: TaxlawDcm, detail: TaxlawDetailData["ASIQTB002PR01"], full: boolean, referer: string): string { const relatedLaws = (detail.dcmRltnStttList || []) .map((item) => cleanText(item.ntstTextNm)) .filter(Boolean) .join(", ") const referencePrecedents = (detail.dcmRfrnPrtsList || []) .map((item) => [cleanText(item.ntstDcmDscmCntn), cleanText(item.ntstDcmTtl)].filter(Boolean).join(" ")) .filter(Boolean) const quotedPrecedents = (detail.dcmQutPrtsList || []) .map((item) => [cleanText(item.ntstDcmDscmCntn), cleanText(item.ntstDcmTtl)].filter(Boolean).join(" ")) .filter(Boolean) const bodyText = detailTextFromHtmlList(detail.dcmHwpEditorDVOList) const code = dcm.ntstDcmClCd || dcm.NTST_DCM_CL_CD const type = dcm.ntstDcmClNm || dcm.NTST_DCM_CL_NM || docLabel(code) const title = cleanText(dcm.ntstDcmTtl || dcm.TTL) const lines = [ `=== ${title || "(제목 없음)"} ===`, "", "기본 정보:", ` ID: ${dcm.ntstDcmId || id}`, ` 구분: ${type}`, ` 세목코드: ${dcm.ntstTlawClCd || "N/A"}`, ` 문서번호: ${cleanText(dcm.ntstDcmDscmCntn || dcm.NTST_DCM_DSCM_CNTN) || "N/A"}`, ` 회신번호: ${cleanText(dcm.ntstDcmRplyCntn || dcm.NTST_DCM_RPLY_CNTN) || "N/A"}`, ` 결정: ${cleanText(dcm.ntstDcmDcsClNm || dcm.NTST_DCM_DCS_CL_NM) || "N/A"}`, ` 생산일자: ${normalizeDate(dcm.ntstDcmRgtDt || dcm.DCM_RGT_DTM)} / 등록일자: ${normalizeDate(dcm.frsRgtDtm || dcm.FRS_RGT_DTM)}`, ` 출처: ${TAXLAW_BASE}${referer}`, ] if (relatedLaws) lines.push(` 관련법령: ${relatedLaws}`) lines.push("") const gist = cleanText(dcm.ntstDcmGistCntn || dcm.GIST_CNTN) const answer = cleanText(dcm.ntstDcmCntn || dcm.CNTN) if (gist) lines.push("요지:", gist, "") if (answer) lines.push("본문/회신/결정내용:", answer, "") if (bodyText) lines.push(full ? "원문 변환 텍스트:" : "원문 요약 텍스트:", compactBodyText(bodyText, full), "") if (referencePrecedents.length > 0) { lines.push("참조 판례:", ...referencePrecedents.slice(0, 20).map((item) => ` - ${item}`), "") } if (quotedPrecedents.length > 0) { lines.push("인용 판례:", ...quotedPrecedents.slice(0, 20).map((item) => ` - ${item}`), "") } return truncate(lines.join("\n"), full ? 50000 : 30000) } - src/index.ts:67-71 (schema)The `DocumentDetailArgs` interface defining the input schema for get_taxlaw_document_text: id (string), docType (string), full (boolean).
interface DocumentDetailArgs { id?: string docType?: string full?: boolean } - src/index.ts:1889-1891 (registration)Dispatch in `handleToolCall` routing the 'get_taxlaw_document_text' name to `getTaxlawDocumentText`.
if (name === "get_taxlaw_document_text") { return await getTaxlawDocumentText(input as DocumentDetailArgs) }