search_knowledge_base
Find relevant knowledge base articles by querying keywords or error messages. Supports multiple ITSM systems including Jira, ServiceNow, and Zendesk.
Instructions
Search the knowledge base for articles related to an issue
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query — keywords, error messages, or topic | |
| limit | No | Max articles to return | |
| system | No | ITSM system to use | jira |
Implementation Reference
- index.js:159-165 (handler)The business logic handler function for search_knowledge_base. Filters in-memory knowledgeBaseArticles array by matching the query against title, summary, or tags, and returns up to `limit` results.
function searchKnowledgeBase({ query, limit = 5 }) { const q = query.toLowerCase(); const results = knowledgeBaseArticles .filter(a => a.title.toLowerCase().includes(q) || a.summary.toLowerCase().includes(q) || a.tags.some(t => t.includes(q))) .slice(0, limit); return { success: true, articles: results, total: results.length }; } - index.js:312-331 (registration)MCP tool registration for 'search_knowledge_base' using server.tool(). Defines the schema (query, limit, optional system), annotations (read-only, idempotent), and the async handler that calls searchKnowledgeBase().
server.tool( 'search_knowledge_base', 'Search the knowledge base for articles related to an issue', { query: z.string().describe('Search query — keywords, error messages, or topic'), limit: z.number().int().min(1).max(20).default(5).describe('Max articles to return'), system: systemSchema.optional(), }, { title: 'Search Knowledge Base', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, async ({ query, limit }) => { const result = searchKnowledgeBase({ query, limit }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; }, ); - index.js:315-319 (schema)Zod input schema for the search_knowledge_base tool: query (string), limit (int 1-20, default 5), optional system.
{ query: z.string().describe('Search query — keywords, error messages, or topic'), limit: z.number().int().min(1).max(20).default(5).describe('Max articles to return'), system: systemSchema.optional(), }, - index.js:25-61 (helper)The in-memory knowledge base data store used by searchKnowledgeBase(). Contains 5 hardcoded KB articles with id, title, summary, url, and tags.
const knowledgeBaseArticles = [ { id: 'KB-001', title: 'How to reset your password', summary: 'Step-by-step guide to reset your password', url: 'https://example.com/kb/password-reset', tags: ['password', 'authentication', 'login'], }, { id: 'KB-002', title: 'Common login issues', summary: 'Troubleshooting common login problems', url: 'https://example.com/kb/login-issues', tags: ['login', 'authentication', 'troubleshooting'], }, { id: 'KB-003', title: 'Setting up email on mobile devices', summary: 'How to configure email on iOS and Android', url: 'https://example.com/kb/email-setup', tags: ['email', 'mobile', 'configuration'], }, { id: 'KB-004', title: 'VPN connection troubleshooting', summary: 'Fixing common VPN connection problems', url: 'https://example.com/kb/vpn-issues', tags: ['vpn', 'network', 'troubleshooting'], }, { id: 'KB-005', title: 'Printer setup guide', summary: 'How to install and configure network printers', url: 'https://example.com/kb/printer-setup', tags: ['printer', 'hardware', 'configuration'], }, ];