call_taxlaw_action
Calls the Korean National Tax Service law information system action endpoint to retrieve tax law data such as interpretations, rulings, or forms using an actionId and referer path.
Instructions
국세법령정보시스템 action.do 원시 호출. list_taxlaw_site_menus의 actionId/defaultParamData 또는 브라우저에서 확인한 actionId를 사용할 수 있습니다.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| actionId | Yes | action.do actionId. 예: ASIPDM001MR01 | |
| paramData | No | action.do paramData JSON 객체. 미입력 시 {} | |
| refererPath | Yes | 같은 사이트 내 referer 경로. 예: /pd/USEPDM001M.do | |
| full | No | true면 JSON 응답을 더 길게 반환 |
Implementation Reference
- src/index.ts:519-533 (schema)Input schema definition for the 'call_taxlaw_action' tool. Defines actionId (required), paramData (optional object), refererPath (required string), and full (optional boolean).
{ name: "call_taxlaw_action", description: "국세법령정보시스템 action.do 원시 호출. list_taxlaw_site_menus의 actionId/defaultParamData 또는 브라우저에서 확인한 actionId를 사용할 수 있습니다.", inputSchema: { type: "object", properties: { actionId: { type: "string", description: "action.do actionId. 예: ASIPDM001MR01" }, paramData: { type: "object", description: "action.do paramData JSON 객체. 미입력 시 {}" }, refererPath: { type: "string", description: "같은 사이트 내 referer 경로. 예: /pd/USEPDM001M.do" }, full: { type: "boolean", default: false, description: "true면 JSON 응답을 더 길게 반환" }, }, required: ["actionId", "refererPath"], additionalProperties: false, }, }, - src/index.ts:1471-1501 (handler)Handler function 'callTaxlawAction' that executes the tool logic. Validates actionId (uppercase letters/digits), normalizes refererPath, posts the action via postTaxlawAction, checks for empty payload, and returns the raw JSON response.
async function callTaxlawAction(args: RawActionArgs): Promise<ToolResponse> { const actionId = requireString("actionId", args.actionId) if (!/^[A-Z0-9]+$/.test(actionId)) { throw new TaxlawMcpError("actionId must contain only uppercase letters and digits", ErrorCodes.INVALID_PARAM) } const refererPath = normalizeTaxlawPath(args.refererPath) const paramData = args.paramData && typeof args.paramData === "object" ? args.paramData : {} const data = await postTaxlawAction<unknown>(actionId, paramData, refererPath) if (isEmptyPayload(data)) { return notFoundResponse( `국세법령정보시스템 action.do(${actionId}) 응답에 표시 가능한 데이터가 없습니다.`, [ "paramData의 필수 필드(검색어/일자/페이지)를 점검하세요.", "list_taxlaw_site_menus로 메뉴별 defaultParamData를 확인 후 재시도하세요.", ], ) } const lines = [ "국세법령정보시스템 action.do 원시 응답", `출처: ${TAXLAW_BASE}/action.do`, `referer: ${TAXLAW_BASE}${refererPath}`, `actionId: ${actionId}`, `paramData: ${JSON.stringify(paramData)}`, "주의: 아래 JSON은 NTS action.do의 원시 응답입니다. 응답에 명시되지 않은 사실은 추론·생성하지 말고, 키 이름·값을 그대로 인용해 답변하세요.", "", stringifyJson(data, args.full === true), ] return textResponse(lines.join("\n")) } - src/index.ts:1898-1900 (registration)Registration of 'call_taxlaw_action' in the handleToolCall dispatch, mapping the tool name to the callTaxlawAction handler function.
if (name === "call_taxlaw_action") { return await callTaxlawAction(input as RawActionArgs) } - src/index.ts:811-869 (helper)Helper functions 'postTaxlawAction' and 'postTaxlawActionAttempt' that perform the actual HTTP POST to the taxlaw action.do endpoint with session management, cookie caching, retries, and JSON response parsing.
async function postTaxlawAction<T>(actionId: string, paramData: unknown, refererPath: string): Promise<T> { return postTaxlawActionAttempt<T>(actionId, paramData, refererPath, true) } async function postTaxlawActionAttempt<T>( actionId: string, paramData: unknown, refererPath: string, allowRefresh: boolean, ): Promise<T> { const cookie = await fetchTaxlawSession(refererPath) const form = new URLSearchParams() form.set("actionId", actionId) form.set("paramData", JSON.stringify(paramData)) const response = await fetchWithRetry(`${TAXLAW_BASE}/action.do`, { method: "POST", headers: { accept: "application/json, text/javascript, */*; q=0.01", "content-type": "application/x-www-form-urlencoded", origin: TAXLAW_BASE, referer: `${TAXLAW_BASE}${refererPath}`, cookie, "user-agent": userAgent(), }, body: form.toString(), }) if (!response.ok) { await consume(response) if (allowRefresh && (response.status === 401 || response.status === 403)) { cachedSession = null return postTaxlawActionAttempt<T>(actionId, paramData, refererPath, false) } throw new TaxlawMcpError(`Taxlaw action.do failed (${response.status})`, ErrorCodes.API_ERROR) } let payload: TaxlawActionResponse<T> try { payload = await response.json() as TaxlawActionResponse<T> } catch (error) { if (allowRefresh) { cachedSession = null return postTaxlawActionAttempt<T>(actionId, paramData, refererPath, false) } throw new TaxlawMcpError( `Taxlaw action.do JSON parse failed: ${error instanceof Error ? error.message : String(error)}`, ErrorCodes.PARSE_ERROR, ) } if (payload.status !== "SUCCESS" || !payload.data) { throw new TaxlawMcpError( `Taxlaw action.do returned ${payload.status}: ${payload.message || "no message"}`, ErrorCodes.API_ERROR, ) } return payload.data }