UNPKG

@minjunkwon/localgovernment-welfare-mcp-server

Version:

MCP server for Korean Local Government Welfare Services - provides intelligent search and information retrieval for local government social welfare programs

856 lines (785 loc) โ€ข 27.4 kB
#!/usr/bin/env node import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; const server = new Server({ name: "localgovernment-welfare-mcp-server", version: "1.0.0" }, { capabilities: { tools: {}, }, }); server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "search_local_welfare_services", description: `Search local government welfare services in Korea with structured filtering options. WHEN TO USE: When user asks for specific welfare services with clear criteria (region, target group, topic, etc.) PARAMETER INFERENCE GUIDE: ๐Ÿข Region (ctpvNm/sggNm): - User says "์„œ์šธ ์€ํ‰๊ตฌ" โ†’ ctpvNm: "์„œ์šธํŠน๋ณ„์‹œ", sggNm: "์€ํ‰๊ตฌ" - User says "๊ฒฝ๊ธฐ๋„ ์„ฑ๋‚จ์‹œ" โ†’ ctpvNm: "๊ฒฝ๊ธฐ๋„", sggNm: "์„ฑ๋‚จ์‹œ" - User says "๋ถ€์‚ฐ" โ†’ ctpvNm: "๋ถ€์‚ฐ๊ด‘์—ญ์‹œ" ๐Ÿ‘ฅ Target Group (trgterIndvdlArray): - "์ €์†Œ๋“์ธต", "๊ธฐ์ดˆ์ƒํ™œ์ˆ˜๊ธ‰์ž" โ†’ "050" - "์žฅ์• ์ธ" โ†’ "040" - "ํ•œ๋ถ€๋ชจ๊ฐ€์ •", "์กฐ์†๊ฐ€์ •" โ†’ "060" - "๋‹ค์ž๋…€๊ฐ€์ •" โ†’ "020" - "๋ณดํ›ˆ๋Œ€์ƒ์ž" โ†’ "030" ๐ŸŽฏ Life Stage (lifeArray): - "์ž„์‹ ", "์ถœ์‚ฐ", "์‚ฐ๋ชจ" โ†’ "007" - "์˜์œ ์•„", "์‹ ์ƒ์•„" โ†’ "001" - "์•„๋™", "์–ด๋ฆฐ์ด" โ†’ "002" - "์ฒญ์†Œ๋…„" โ†’ "003" - "์ฒญ๋…„", "๋Œ€ํ•™์ƒ" โ†’ "004" - "์ค‘์žฅ๋…„" โ†’ "005" - "๋…ธ์ธ", "์–ด๋ฅด์‹ " โ†’ "006" ๐Ÿ“‹ Interest Theme (intrsThemaArray): - "์ผ์ž๋ฆฌ", "์ทจ์—…", "๊ณ ์šฉ" โ†’ "050" - "์ฃผ๊ฑฐ", "์ฃผํƒ" โ†’ "040" - "๋ณด์œก", "์–ด๋ฆฐ์ด์ง‘" โ†’ "090" - "๊ต์œก" โ†’ "100" - "์˜๋ฃŒ", "๊ฑด๊ฐ•" โ†’ "010" - "์„œ๋ฏผ๊ธˆ์œต", "์ง€์›๊ธˆ" โ†’ "130" ๐Ÿ” Search Parameters: - srchKeyCode: "001" for service name, "002" for organization, "003" for region - searchWrd: keyword to search for - age: specific age number for filtering EXAMPLES: 1. "์„œ์šธ ์€ํ‰๊ตฌ ์ €์†Œ๋“์ธต ๋ณต์ง€์„œ๋น„์Šค" โ†’ {"ctpvNm": "์„œ์šธํŠน๋ณ„์‹œ", "sggNm": "์€ํ‰๊ตฌ", "trgterIndvdlArray": "050"} 2. "๋ถ€์‚ฐ ์ฒญ๋…„ ์ผ์ž๋ฆฌ ์ง€์›" โ†’ {"ctpvNm": "๋ถ€์‚ฐ๊ด‘์—ญ์‹œ", "lifeArray": "004", "intrsThemaArray": "050"} 3. "๊ฒฝ๊ธฐ๋„ ์žฅ์• ์ธ ์ฃผ๊ฑฐ ์„œ๋น„์Šค" โ†’ {"ctpvNm": "๊ฒฝ๊ธฐ๋„", "trgterIndvdlArray": "040", "intrsThemaArray": "040"} 4. "์ž„์‹  ์ง€์› ๊ฒ€์ƒ‰" โ†’ {"srchKeyCode": "001", "searchWrd": "์ž„์‹ "} 5. "30์„ธ ์ฒญ๋…„ ์ง€์›" โ†’ {"age": 30, "lifeArray": "004"}`, inputSchema: { type: "object", properties: { serviceKey: { type: "string", description: "์„œ๋น„์Šคํ‚ค (์„ ํƒ์‚ฌํ•ญ)" }, pageNo: { type: "integer", minimum: 1, maximum: 1000, description: "ํŽ˜์ด์ง€ ๋ฒˆํ˜ธ (๊ธฐ๋ณธ๊ฐ’: 1)" }, numOfRows: { type: "integer", minimum: 1, maximum: 100, description: "์ถœ๋ ฅ ๊ฑด์ˆ˜ (๊ธฐ๋ณธ๊ฐ’: 10)" }, lifeArray: { type: "string", enum: ["001", "002", "003", "004", "005", "006", "007"], description: "์ƒ์• ์ฃผ๊ธฐ๋ณ„ ํ•„ํ„ฐ๋ง (001: ์˜์œ ์•„, 002: ์•„๋™, 003: ์ฒญ์†Œ๋…„, 004: ์ฒญ๋…„, 005: ์ค‘์žฅ๋…„, 006: ๋…ธ๋…„, 007: ์ž„์‹ ยท์ถœ์‚ฐ)" }, trgterIndvdlArray: { type: "string", enum: ["010", "020", "030", "040", "050", "060"], description: "๊ฐ€๊ตฌ์ƒํ™ฉ๋ณ„ ํ•„ํ„ฐ๋ง (010: ๋‹ค๋ฌธํ™”ยทํƒˆ๋ถ๋ฏผ, 020: ๋‹ค์ž๋…€, 030: ๋ณดํ›ˆ๋Œ€์ƒ์ž, 040: ์žฅ์• ์ธ, 050: ์ €์†Œ๋“, 060: ํ•œ๋ถ€๋ชจยท์กฐ์†)" }, intrsThemaArray: { type: "string", enum: ["010", "020", "030", "040", "050", "060", "070", "080", "090", "100", "110", "120", "130", "140"], description: "๊ด€์‹ฌ์ฃผ์ œ๋ณ„ ํ•„ํ„ฐ๋ง (010: ์‹ ์ฒด๊ฑด๊ฐ•, 020: ์ •์‹ ๊ฑด๊ฐ•, 030: ์ƒํ™œ์ง€์›, 040: ์ฃผ๊ฑฐ, 050: ์ผ์ž๋ฆฌ, 060: ๋ฌธํ™”ยท์—ฌ๊ฐ€, 070: ์•ˆ์ „ยท์œ„๊ธฐ, 080: ์ž„์‹ ยท์ถœ์‚ฐ, 090: ๋ณด์œก, 100: ๊ต์œก, 110: ์ž…์–‘ยท์œ„ํƒ, 120: ๋ณดํ˜ธยท๋Œ๋ด„, 130: ์„œ๋ฏผ๊ธˆ์œต, 140: ๋ฒ•๋ฅ )" }, age: { type: "integer", minimum: 0, maximum: 150, description: "์—ฐ๋ น (์„ ํƒ์‚ฌํ•ญ)" }, ctpvNm: { type: "string", description: "์‹œ๋„๋ช… (์˜ˆ: '์„œ์šธํŠน๋ณ„์‹œ', '๊ฒฝ๊ธฐ๋„', '๋ถ€์‚ฐ๊ด‘์—ญ์‹œ' ๋“ฑ)" }, sggNm: { type: "string", description: "์‹œ๊ตฐ๊ตฌ๋ช… (์˜ˆ: '์€ํ‰๊ตฌ', '์„ฑ๋‚จ์‹œ', '๋ถ€์‚ฐ์ง„๊ตฌ' ๋“ฑ)" }, srchKeyCode: { type: "string", enum: ["001", "002", "003"], description: "๊ฒ€์ƒ‰ํ‚ค์ฝ”๋“œ (001: ์„œ๋น„์Šค๋ช…, 002: ๊ธฐ๊ด€๋ช…, 003: ์ง€์—ญ๋ช…)" }, searchWrd: { type: "string", description: "๊ฒ€์ƒ‰์–ด (์„ ํƒ์‚ฌํ•ญ)" }, arrgOrd: { type: "string", enum: ["001", "002"], description: "์ •๋ ฌ์ˆœ์„œ (001: ์ตœ์‹ ์ˆœ, 002: ์ธ๊ธฐ์ˆœ)" } } } }, { name: "get_local_welfare_codes", description: `Get code definitions used in the local welfare services API. WHEN TO USE: When you need to understand what codes mean or show users available options. PARAMETER: codeType (OPTIONAL): Type of codes to retrieve - "all" (default): All code types - "lifeCycle": Life stage codes (์˜์œ ์•„, ์•„๋™, ์ฒญ์†Œ๋…„, etc.) - "householdType": Household situation codes (์ €์†Œ๋“, ์žฅ์• ์ธ, ํ•œ๋ถ€๋ชจ, etc.) - "interestTheme": Interest theme codes (์ผ์ž๋ฆฌ, ์ฃผ๊ฑฐ, ๊ต์œก, etc.) - "sortOrder": Sort order options (์ตœ์‹ ์ˆœ, ์ธ๊ธฐ์ˆœ) USAGE: Call this when user asks about available options or code meanings.`, inputSchema: { type: "object", properties: { codeType: { type: "string", enum: ["lifeCycle", "householdType", "interestTheme", "sortOrder", "all"], description: "Type of codes to retrieve (default: all)" } } } }, WHEN, TO, USE, When, you, want, to, search ], for: services, and, immediately, get their() { }, detailed, information, without, multiple, API, calls, : . PARAMETERS, Same, as, search_local_welfare_services, plus: -includeDetails(boolean), Whether, to, fetch, detailed, information, for: each } - maxDetails(number); Maximum; number; of; services; to; get; details; for (; ; ) ; 10, max; 20; }); USAGE: This; combines; search; and; batch; detail; fetching; to; provide; complete; information; efficiently. `, inputSchema: { type: "object", properties: { pageNo: { type: "number", description: "Page number (default: 1)" }, numOfRows: { type: "number", description: "Number of results per page (default: 10, max: 100)" }, ctpvNm: { type: "string", description: "Province/City name (e.g., '์„œ์šธํŠน๋ณ„์‹œ')" }, sggNm: { type: "string", description: "District name (e.g., '์€ํ‰๊ตฌ')" }, lifeArray: { type: "string", description: "Life stage code (001-007)" }, trgterIndvdlArray: { type: "string", description: "Target individual code (001-010)" }, intrsThemaArray: { type: "string", description: "Interest theme code (001-012)" }, age: { type: "number", description: "Age" }, searchWrd: { type: "string", description: "Search keyword" }, includeDetails: { type: "boolean", description: "Whether to fetch detailed information (default: false)" }, maxDetails: { type: "number", description: "Maximum number of services to get details for (default: 10, max: 20)" } } } }, { name: "get_local_welfare_codes", description: `; Get; code; definitions; used in the; local; welfare; services; API. ; WHEN; TO; USE: When; you; need; to; understand; what; codes; mean; or; show; users; available; options. PARAMETER; codeType(OPTIONAL); Type; of; codes; to; retrieve - "all"(); All; code; types - "lifeCycle"; Life; stage; codes(์˜์œ ์•„, ์•„๋™, ์ฒญ์†Œ๋…„, etc.) - "householdType"; Household; situation; codes(์ €์†Œ๋“, ์žฅ์• ์ธ, ํ•œ๋ถ€๋ชจ, etc.) - "interestTheme"; Interest; theme; codes(์ผ์ž๋ฆฌ, ์ฃผ๊ฑฐ, ๊ต์œก, etc.) - "sortOrder"; Sort; order; options(์ตœ์‹ ์ˆœ, ์ธ๊ธฐ์ˆœ); USAGE: Call; this; when; user; asks; about; available; options; or; code; meanings. `, inputSchema: { type: "object", properties: { codeType: { type: "string", enum: ["lifeCycle", "householdType", "interestTheme", "sortOrder", "all"], description: "Type of codes to retrieve (default: all)" } } } } ], }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { try { console.error('CallToolRequest received:', JSON.stringify(request)); const { name, arguments: args } = request.params; // arguments๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ๋” ์ƒ์„ธํ•œ ๋กœ๊น… if (!args) { console.error('No arguments provided in request.params:', request.params); throw new McpError(ErrorCode.InvalidParams, "No arguments provided"); } switch (name) { case "search_local_welfare_services": { console.error('search_local_welfare_services called with args:', JSON.stringify(args)); if (!args || typeof args !== 'object') { throw new McpError(ErrorCode.InvalidParams, "Invalid arguments provided"); } const searchParams: LocalWelfareListRequest = { pageNo: args && 'pageNo' in args ? Number(args.pageNo) || 1 : 1, numOfRows: args && 'numOfRows' in args ? Number(args.numOfRows) || 10 : 10 }; // ๋ชจ๋“  ๋งค๊ฐœ๋ณ€์ˆ˜ ์ฒ˜๋ฆฌ if (args && 'serviceKey' in args && typeof args.serviceKey === 'string' && args.serviceKey.trim()) { searchParams.serviceKey = args.serviceKey; } if ((args as any).lifeArray && (args as any).lifeArray.trim()) { searchParams.lifeArray = (args as any).lifeArray; } if ((args as any).trgterIndvdlArray && (args as any).trgterIndvdlArray.trim()) { searchParams.trgterIndvdlArray = (args as any).trgterIndvdlArray; } if ((args as any).intrsThemaArray && (args as any).intrsThemaArray.trim()) { searchParams.intrsThemaArray = (args as any).intrsThemaArray; } if ((args as any).age !== undefined && (args as any).age !== null) { searchParams.age = (args as any).age; } if ((args as any).ctpvNm && (args as any).ctpvNm.trim()) { searchParams.ctpvNm = (args as any).ctpvNm; } if ((args as any).sggNm && (args as any).sggNm.trim()) { searchParams.sggNm = (args as any).sggNm; } if ((args as any).srchKeyCode && ['001', '002', '003'].includes((args as any).srchKeyCode)) { searchParams.srchKeyCode = (args as any).srchKeyCode; } if ((args as any).searchWrd && (args as any).searchWrd.trim()) { searchParams.searchWrd = (args as any).searchWrd; } if ((args as any).arrgOrd && ['001', '002'].includes((args as any).arrgOrd)) { searchParams.arrgOrd = (args as any).arrgOrd; } // ์ƒ์„ธ์กฐํšŒ ์˜ต์…˜ (ํ•ญ์ƒ ํ™œ์„ฑํ™”) const maxDetails = args && 'maxDetails' in args ? Math.min(Number(args.maxDetails) || 15, 20) : 15; try { // 1๋‹จ๊ณ„: ๋ชฉ๋ก ์กฐํšŒ const localWelfareAPI = new LocalWelfareAPI(); const searchResult = await localWelfareAPI.getLocalWelfareList(searchParams); // 2๋‹จ๊ณ„: ์ž๋™ ์ƒ์„ธ์กฐํšŒ const servList = (searchResult as any).wantedList?.servList; if (!servList || servList.length === 0) { return { content: [ { type: "text", text: JSON.stringify({ searchParams: searchParams, searchResult: searchResult, details: [], message: "No services found" }, null, 2) } ] }; } // ์ƒ์„ธ์กฐํšŒํ•  ์„œ๋น„์Šค ID ๋ชฉ๋ก ์ƒ์„ฑ (์ตœ๋Œ€ maxDetails๊ฐœ) const servIds = (Array.isArray(servList) ? servList : [servList]) .slice(0, maxDetails) .map(service => service.servId) .filter(id => id); console.error(`; Auto - fetching; details; for ($; { servIds, : .length }; services) ; `); const detailResults: any[] = []; for (let i = 0; i < servIds.length; i++) { const servId = servIds[i]; try { console.error(`; Fetching; details; for ($; { servId }($, { i } + 1, /${servIds.length}) `); const detailAPI = new LocalWelfareAPI(); const detailResult = await detailAPI.getLocalWelfareDetail({ servId }); detailResults.push({ servId, success: true, data: detailResult.wantedDtl }); // API ํ˜ธ์ถœ ๊ฐ„ 500ms ์ง€์—ฐ (๋งˆ์ง€๋ง‰ ํ˜ธ์ถœ ์ œ์™ธ) if (i < servIds.length - 1) { await new Promise(resolve => setTimeout(resolve, 500)); } } catch (error) { console.error(`; Error) fetching; details; for ($; { servId }; ) : `, error); detailResults.push({ servId, success: false, error: error instanceof Error ? error.message : String(error) }); } } return { content: [ { type: "text", text: JSON.stringify({ searchParams: searchParams, searchResult: searchResult, detailsSummary: { total: servIds.length, successful: detailResults.filter(r => r.success).length, failed: detailResults.filter(r => !r.success).length }, details: detailResults }, null, 2) } ] }; } catch (error) { console.error('Error in search_local_welfare_services:', error); throw new McpError( ErrorCode.InternalError, `; Failed; to; search; welfare; services; with (details) : $; { error instanceof Error ? error.message : String(error); } ` ); } } case "get_local_welfare_detail": { console.error('get_local_welfare_detail called with args:', JSON.stringify(args)); if (!args || typeof args !== 'object') { throw new McpError(ErrorCode.InvalidParams, "Invalid arguments provided"); } const servId = args && 'servId' in args ? String(args.servId) : null; if (!servId) { throw new McpError(ErrorCode.InvalidParams, "servId is required"); } const detailParams: LocalWelfareDetailRequest = { servId: servId }; try { const localWelfareAPI = new LocalWelfareAPI(); const result = await localWelfareAPI.getLocalWelfareDetail(detailParams); return { content: [ { type: "text", text: JSON.stringify(result, null, 2) } ] }; } catch (error) { console.error('Error in get_local_welfare_detail:', error); throw new McpError( ErrorCode.InternalError, `; Failed; to; get; welfare; detail: $; { error instanceof Error ? error.message : String(error); } ` ); } } case "get_multiple_welfare_details": { console.error('get_multiple_welfare_details called with args:', JSON.stringify(args)); if (!args || typeof args !== 'object') { throw new McpError(ErrorCode.InvalidParams, "Invalid arguments provided"); } const servIdsString = args && 'servIds' in args ? String(args.servIds) : ''; if (!servIdsString) { throw new McpError(ErrorCode.InvalidParams, "servIds is required"); } const servIds = servIdsString.split(',').map(id => id.trim()).filter(id => id); if (servIds.length === 0) { throw new McpError(ErrorCode.InvalidParams, "At least one valid service ID is required"); } const results: any[] = []; const errors: string[] = []; for (let i = 0; i < servIds.length; i++) { const servId = servIds[i]; try { console.error(`; Fetching; details; for ($; { servId }($, { i } + 1, /${servIds.length}) `); const localWelfareAPI = new LocalWelfareAPI(); const result = await localWelfareAPI.getLocalWelfareDetail({ servId }); results.push({ servId, success: true, data: result.wantedDtl }); // API ํ˜ธ์ถœ ๊ฐ„ 500ms ์ง€์—ฐ (๋งˆ์ง€๋ง‰ ํ˜ธ์ถœ ์ œ์™ธ) if (i < servIds.length - 1) { await new Promise(resolve => setTimeout(resolve, 500)); } } catch (error) { console.error(`; Error) fetching; $; { servId; } `, error); errors.push(`; $; { servId; } $; { error instanceof Error ? error.message : String(error); } `); results.push({ servId, success: false, error: error instanceof Error ? error.message : String(error) }); } } const summary = { total: servIds.length, successful: results.filter(r => r.success).length, failed: results.filter(r => !r.success).length, results: results }; return { content: [ { type: "text", text: JSON.stringify(summary, null, 2) } ] }; } case "search_welfare_with_details": { console.error('search_welfare_with_details called with args:', JSON.stringify(args)); if (!args || typeof args !== 'object') { throw new McpError(ErrorCode.InvalidParams, "Invalid arguments provided"); } // ๊ฒ€์ƒ‰ ํŒŒ๋ผ๋ฏธํ„ฐ ๊ตฌ์„ฑ const searchParams: LocalWelfareListRequest = { pageNo: args && 'pageNo' in args ? Number(args.pageNo) || 1 : 1, numOfRows: args && 'numOfRows' in args ? Number(args.numOfRows) || 10 : 10 }; // ๋ชจ๋“  ๊ฒ€์ƒ‰ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ฒ˜๋ฆฌ (๊ธฐ์กด search_local_welfare_services์™€ ๋™์ผ) if (args && 'ctpvNm' in args && typeof args.ctpvNm === 'string' && args.ctpvNm.trim()) { searchParams.ctpvNm = args.ctpvNm; } if (args && 'sggNm' in args && typeof args.sggNm === 'string' && args.sggNm.trim()) { searchParams.sggNm = args.sggNm; } if (args && 'lifeArray' in args && typeof args.lifeArray === 'string' && args.lifeArray.trim()) { searchParams.lifeArray = args.lifeArray as any; } if (args && 'trgterIndvdlArray' in args && typeof args.trgterIndvdlArray === 'string' && args.trgterIndvdlArray.trim()) { searchParams.trgterIndvdlArray = args.trgterIndvdlArray as any; } if (args && 'intrsThemaArray' in args && typeof args.intrsThemaArray === 'string' && args.intrsThemaArray.trim()) { searchParams.intrsThemaArray = args.intrsThemaArray as any; } if (args && 'age' in args && typeof args.age === 'number') { searchParams.age = args.age; } if (args && 'searchWrd' in args && typeof args.searchWrd === 'string' && args.searchWrd.trim()) { searchParams.searchWrd = args.searchWrd; } // ์ƒ์„ธ์กฐํšŒ ์˜ต์…˜ const includeDetails = args && 'includeDetails' in args ? Boolean(args.includeDetails) : false; const maxDetails = args && 'maxDetails' in args ? Math.min(Number(args.maxDetails) || 10, 20) : 10; try { // 1๋‹จ๊ณ„: ๋ชฉ๋ก ์กฐํšŒ const localWelfareAPI = new LocalWelfareAPI(); const searchResult = await localWelfareAPI.getLocalWelfareList(searchParams); if (!includeDetails) { // ์ƒ์„ธ์กฐํšŒ ์—†์ด ๋ชฉ๋ก๋งŒ ๋ฐ˜ํ™˜ return { content: [ { type: "text", text: JSON.stringify({ searchParams: searchParams, result: searchResult }, null, 2) } ] }; } // 2๋‹จ๊ณ„: ์ƒ์„ธ์กฐํšŒ ์ˆ˜ํ–‰ const servList = (searchResult as any).wantedList?.servList; if (!servList || servList.length === 0) { return { content: [ { type: "text", text: JSON.stringify({ searchParams: searchParams, searchResult: searchResult, details: [], message: "No services found to get details for" }, null, 2) } ] }; } // ์ƒ์„ธ์กฐํšŒํ•  ์„œ๋น„์Šค ID ๋ชฉ๋ก ์ƒ์„ฑ (์ตœ๋Œ€ maxDetails๊ฐœ) const servIds = (Array.isArray(servList) ? servList : [servList]) .slice(0, maxDetails) .map(service => service.servId) .filter(id => id); console.error(`; Fetching; details; for ($; { servIds, : .length }; services) ; `); const detailResults: any[] = []; for (let i = 0; i < servIds.length; i++) { const servId = servIds[i]; try { console.error(`; Fetching; details; for ($; { servId }($, { i } + 1, /${servIds.length}) `); const detailAPI = new LocalWelfareAPI(); const detailResult = await detailAPI.getLocalWelfareDetail({ servId }); detailResults.push({ servId, success: true, data: detailResult.wantedDtl }); // API ํ˜ธ์ถœ ๊ฐ„ 500ms ์ง€์—ฐ (๋งˆ์ง€๋ง‰ ํ˜ธ์ถœ ์ œ์™ธ) if (i < servIds.length - 1) { await new Promise(resolve => setTimeout(resolve, 500)); } } catch (error) { console.error(`; Error) fetching; details; for ($; { servId }; ) : `, error); detailResults.push({ servId, success: false, error: error instanceof Error ? error.message : String(error) }); } } return { content: [ { type: "text", text: JSON.stringify({ searchParams: searchParams, searchResult: searchResult, detailsSummary: { total: servIds.length, successful: detailResults.filter(r => r.success).length, failed: detailResults.filter(r => !r.success).length }, details: detailResults }, null, 2) } ] }; } catch (error) { console.error('Error in search_welfare_with_details:', error); throw new McpError( ErrorCode.InternalError, `; Failed; to; search; welfare; services; with (details) : $; { error instanceof Error ? error.message : String(error); } ` ); } } case "get_local_welfare_codes": { const codeType = (args as any).codeType || "all"; let codes: any = {}; switch (codeType) { case "lifeCycle": codes = { lifeCycle: LifeCycleCode }; break; case "householdType": codes = { householdType: HouseholdTypeCode }; break; case "interestTheme": codes = { interestTheme: InterestThemeCode }; break; case "sortOrder": codes = { sortOrder: SortOrderCode }; break; case "all": default: codes = { lifeCycle: LifeCycleCode, householdType: HouseholdTypeCode, interestTheme: InterestThemeCode, sortOrder: SortOrderCode }; break; } return { content: [ { type: "text", text: JSON.stringify(codes, null, 2) } ] }; } default: throw new McpError(ErrorCode.MethodNotFound, `; Unknown; tool: $; { name; } `); } } catch (error) { if (error instanceof McpError) { throw error; } throw new McpError( ErrorCode.InternalError, `; Tool; execution; failed: $; { error instanceof Error ? error.message : String(error); } ` ); } }); async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.error("Local Government Welfare MCP Server running on stdio"); } main().catch((error) => { console.error("Server failed to start:", error); process.exit(1); });; //# sourceMappingURL=index-old.js.map