redscv95
Initial deploy: korean-privacy-law-mcp v0.0.1 (37 tools, RAG 2,202 chunks)
3798d02
Raw
History Blame Contribute Delete
1.04 kB
import type { ToolResponse } from "./not-found.js";
/** ๋ฒ•์ œ์ฒ˜ API ํ˜ธ์ถœ ์‹คํŒจ ๋“ฑ ์™ธ๋ถ€ ์˜์กด ์—๋Ÿฌ */
export class LawApiError extends Error {
constructor(
message: string,
public readonly statusCode?: number,
public readonly cause?: unknown
) {
super(message);
this.name = "LawApiError";
}
}
/** ์ž…๋ ฅ ๊ฒ€์ฆ ์‹คํŒจ */
export class ValidationError extends Error {
constructor(message: string) {
super(message);
this.name = "ValidationError";
}
}
/** ๋ชจ๋“  ๋„๊ตฌ ์‘๋‹ต์— ๊ณตํ†ต ์ ์šฉ. API ํ‚ค ๋งˆ์Šคํ‚น ํฌํ•จ. */
export function formatToolError(error: unknown, toolName: string): ToolResponse {
const message = error instanceof Error ? error.message : String(error);
return {
content: [{ type: "text", text: `[ERROR] ${toolName}: ${maskApiKey(message)}` }],
isError: true,
};
}
/** ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ยท๋กœ๊ทธ์— OC API ํ‚ค๊ฐ€ ๋…ธ์ถœ๋˜์ง€ ์•Š๋„๋ก ๋งˆ์Šคํ‚น */
export function maskApiKey(text: string): string {
return text.replace(/OC=[^&\s]+/gi, "OC=***");
}