search_nicepay_docs
Search NicePay developer documentation to find payment API guides, endpoint details, code samples, and SDK methods using keywords.
Instructions
나이스페이 개발자 가이드 문서를 검색합니다. 키워드로 관련 문서를 찾을 수 있습니다.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 검색할 키워드 (예: "결제창", "취소", "웹훅", "API" 등) |
Implementation Reference
- src/index.ts:234-313 (handler)Core handler function for 'search_nicepay_docs' tool. Validates query, calls docIndexer.searchDocuments, formats top 10 results with previews and sections into markdown text.private async searchDocs(query: string) { if (!query || query.trim().length === 0) { return { content: [ { type: 'text', text: '검색어를 입력해주세요.', }, ], isError: true, }; } try { const results = this.docIndexer.searchDocuments(query.trim()); if (results.length === 0) { return { content: [ { type: 'text', text: `"${query}"에 대한 검색 결과를 찾을 수 없습니다.\n\n다른 키워드로 검색해보세요.`, }, ], }; } // 최대 10개까지만 반환 const limitedResults = results.slice(0, 10); let resultText = `"${query}" 검색 결과 (${results.length}개 문서 중 상위 ${limitedResults.length}개)\n\n`; limitedResults.forEach((doc, index) => { resultText += `## ${index + 1}. ${doc.title}\n`; resultText += `📄 파일: ${doc.filePath}\n\n`; // 문서의 처음 200자 미리보기 const preview = doc.content.substring(0, 200).replace(/\n/g, ' ').trim(); if (preview.length > 0) { resultText += `${preview}${doc.content.length > 200 ? '...' : ''}\n\n`; } // 주요 섹션 제목 목록 (최대 5개) if (doc.sections.length > 0) { resultText += `**주요 섹션:**\n`; doc.sections.slice(0, 5).forEach(section => { resultText += `- ${' '.repeat(section.level - 1)}${section.title}\n`; }); resultText += '\n'; } resultText += '---\n\n'; }); if (results.length > 10) { resultText += `\n*총 ${results.length}개 문서 중 상위 10개만 표시됩니다.*\n`; } return { content: [ { type: 'text', text: resultText, }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error(`문서 검색 오류 (query: ${query}):`, errorMessage); return { content: [ { type: 'text', text: `검색 중 오류가 발생했습니다. 다시 시도해주세요.`, }, ], isError: true, }; } }
- src/utils/docIndexer.ts:211-246 (helper)Supporting search function in DocumentIndexer that implements keyword search with relevance scoring across title, filename, keywords, and content.searchDocuments(query: string): DocumentIndex[] { const lowerQuery = query.toLowerCase(); const results: Array<{ doc: DocumentIndex; score: number }> = []; for (const doc of this.index.values()) { let score = 0; // 제목 매치 (높은 점수) if (doc.title.toLowerCase().includes(lowerQuery)) { score += 10; } // 파일명 매치 if (doc.fileName.toLowerCase().includes(lowerQuery)) { score += 5; } // 키워드 매치 const keywordMatches = doc.keywords.filter(k => k.includes(lowerQuery)).length; score += keywordMatches; // 내용 매치 (낮은 점수) if (doc.content.toLowerCase().includes(lowerQuery)) { score += 1; } if (score > 0) { results.push({doc, score}); } } // 점수 순으로 정렬 results.sort((a, b) => b.score - a.score); return results.map(r => r.doc); }
- src/index.ts:46-59 (registration)Tool registration in ListToolsRequestSchema response, defining name, description, and input schema for search_nicepay_docs.{ name: 'search_nicepay_docs', description: '나이스페이 개발자 가이드 문서를 검색합니다. 키워드로 관련 문서를 찾을 수 있습니다.', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '검색할 키워드 (예: "결제창", "취소", "웹훅", "API" 등)', }, }, required: ['query'], }, },
- src/index.ts:119-133 (handler)Dispatch logic in CallToolRequestSchema handler: validates 'query' arg and calls searchDocs method.case 'search_nicepay_docs': if (!args?.query || typeof args.query !== 'string') { logger.warn(`잘못된 파라미터: search_nicepay_docs`, args); return { content: [ { type: 'text', text: 'query 파라미터가 필요합니다.', }, ], isError: true, }; } result = await this.searchDocs(args.query); break;