mcp-cisco-support
Version:
MCP server for Cisco Support APIs including Bug Search and future tools
890 lines (889 loc) • 80 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BugApi = void 0;
const base_api_js_1 = require("./base-api.js");
const logger_js_1 = require("../utils/logger.js");
const web_search_js_1 = require("../utils/web-search.js");
class BugApi extends base_api_js_1.BaseApi {
baseUrl = 'https://apix.cisco.com/bug/v2.0';
apiName = 'Bug';
// Utility functions for enhanced search capabilities
/**
* Normalize a single version string to Cisco API format
* Converts "17.09.06" to "17.9.6" by removing leading zeros
*/
normalizeVersionString(version) {
if (!version)
return version;
// Remove leading zeros from each version segment: 17.09.06 -> 17.9.6
return version.replace(/\.0+(\d)/g, '.$1');
}
/**
* Generate multiple version variations for progressive search
* Returns array of normalized versions for fallback attempts
*/
normalizeVersion(version) {
const versions = [];
// Convert to Cisco API format first: 17.09.06 -> 17.9.6 (remove leading zeros)
const ciscoFormat = this.normalizeVersionString(version);
versions.push(ciscoFormat);
// Also keep original version in case it's already in correct format
if (ciscoFormat !== version) {
versions.push(version);
}
// Create abbreviated versions: 17.09.06 -> 17.09 -> 17.9
if (version.includes('.')) {
const parts = version.split('.');
if (parts.length >= 3) {
const shortVersion = parts.slice(0, 2).join('.');
const shortCiscoFormat = this.normalizeVersionString(shortVersion);
versions.push(shortCiscoFormat);
if (shortCiscoFormat !== shortVersion) {
versions.push(shortVersion);
}
}
if (parts.length >= 2) {
versions.push(parts[0]);
}
}
// Remove duplicates and return
return [...new Set(versions)];
}
normalizeProductId(productId) {
const products = [];
products.push(productId);
// Remove suffixes like /K9
if (productId.includes('/')) {
products.push(productId.split('/')[0]);
}
// Handle series mappings
if (productId.startsWith('ISR44')) {
products.push('ISR4400');
products.push('ISR');
}
else if (productId.startsWith('C92')) {
products.push('C9200');
}
else if (productId.startsWith('ASR9')) {
products.push('ASR9000');
}
return [...new Set(products)];
}
async searchMultipleSeverities(searchFunc, maxSeverity = 3, meta) {
const allBugs = [];
let totalResults = 0;
logger_js_1.logger.info('Starting multi-severity search', { maxSeverity });
for (let severity = 1; severity <= maxSeverity; severity++) {
try {
// Send progress notification before searching this severity
const { sendProgress } = await Promise.resolve().then(() => __importStar(require('../mcp-server.js')));
sendProgress(meta?.progressToken, severity - 1, maxSeverity);
logger_js_1.logger.info(`Searching severity ${severity}`);
const result = await searchFunc(severity.toString());
if (result.bugs && Array.isArray(result.bugs)) {
allBugs.push(...result.bugs);
totalResults += result.total_results || result.bugs.length;
logger_js_1.logger.info(`Found ${result.bugs.length} bugs at severity ${severity}`);
}
}
catch (error) {
logger_js_1.logger.warn(`Search failed for severity ${severity}`, { error: error instanceof Error ? error.message : error });
// Continue with other severities
}
}
// Remove duplicates by bug_id
const uniqueBugs = allBugs.filter((bug, index, self) => index === self.findIndex(b => b.bug_id === bug.bug_id));
logger_js_1.logger.info('Multi-severity search completed', {
totalFound: uniqueBugs.length,
searchedSeverities: maxSeverity
});
return {
bugs: uniqueBugs,
total_results: uniqueBugs.length,
page_index: 1
};
}
getTools() {
return [
{
name: 'get_bug_details',
title: 'Get Bug Details',
description: 'Get details for up to 5 specific bug IDs',
inputSchema: {
type: 'object',
properties: {
bug_ids: {
type: 'string',
description: 'Comma-separated list of bug IDs (max 5)'
}
},
required: ['bug_ids']
}
},
{
name: 'search_bugs_by_keyword',
title: 'Search Bugs by Keyword',
description: 'Search for bugs using keywords in descriptions and headlines. Use this when searching by general terms, symptoms, or when product-specific tools are not applicable. IMPORTANT: severity parameter returns ONLY that specific level. For "severity 3 or higher" searches, use multi_severity_search tool instead. NOTE: Do NOT use product IDs (like ISR4431/K9) as keywords - use search_bugs_by_product_id instead.',
inputSchema: {
type: 'object',
properties: {
keyword: {
type: 'string',
description: 'Keywords to search for (general terms, symptoms, error messages - NOT product IDs)'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['keyword']
}
},
{
name: 'search_bugs_by_product_id',
description: 'Search bugs by specific base product ID (e.g., C9200-24P). Use when you have an exact Cisco product ID. For general product searches by name, consider using keyword search instead.',
inputSchema: {
type: 'object',
properties: {
base_pid: {
type: 'string',
description: 'Base product ID'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['base_pid']
}
},
{
name: 'search_bugs_by_product_and_release',
description: 'Search bugs by specific product ID and software releases. CRITICAL: Use "software_releases" parameter with comma-separated values like "17.9.1,17.12.3" to search up to 75 versions in ONE API call. NEVER make multiple separate calls for different versions - the API supports multiple versions in a single request. Use this when you have an exact product ID and want to filter by specific software versions. For product series searches, use search_bugs_by_product_series_affected instead.',
inputSchema: {
type: 'object',
properties: {
base_pid: {
type: 'string',
description: 'Specific product ID (e.g., "C9300-24P", "ISR4431", "ASA5516-X") - NOT product series names'
},
software_releases: {
type: 'string',
description: 'Comma-separated software release versions (e.g., "17.9.1,17.12.3") - can search up to 75 versions in one call. Do NOT make separate API calls for each version.'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['base_pid', 'software_releases']
}
},
{
name: 'search_bugs_by_product_series_affected',
description: 'Search bugs by product series and affected releases. This endpoint accepts full product series names like "Cisco 4000 Series Integrated Services Routers". IMPORTANT: Use Cisco API version format without leading zeros (17.9.6 not 17.09.06).',
inputSchema: {
type: 'object',
properties: {
product_series: {
type: 'string',
description: 'Product series name (accepts full names like "Cisco 4000 Series Integrated Services Routers", "Cisco Catalyst 9200 Series", etc.)'
},
affected_releases: {
type: 'string',
description: 'Comma-separated affected release versions in Cisco API format (e.g., "17.9.6,17.12.3" not "17.09.06" - no leading zeros). Can search up to 75 versions in one call.'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['product_series', 'affected_releases']
}
},
{
name: 'search_bugs_by_product_series_fixed',
description: 'Search bugs by product series and fixed releases. This endpoint accepts full product series names like "Cisco 4000 Series Integrated Services Routers". IMPORTANT: Use Cisco API version format without leading zeros (17.9.6 not 17.09.06).',
inputSchema: {
type: 'object',
properties: {
product_series: {
type: 'string',
description: 'Product series name (accepts full names like "Cisco 4000 Series Integrated Services Routers", "Cisco Catalyst 9200 Series", etc.)'
},
fixed_releases: {
type: 'string',
description: 'Comma-separated fixed release versions in Cisco API format (e.g., "17.9.6,17.12.3" not "17.09.06" - no leading zeros). Can search up to 75 versions in one call.'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['product_series', 'fixed_releases']
}
},
{
name: 'search_bugs_by_product_name_affected',
description: 'Search bugs by full product name and affected releases. NOTE: Requires FULL descriptive product names (like "Cisco 4431 Integrated Services Router") not product IDs. Use search_bugs_by_product_id for product IDs like ISR4431.',
inputSchema: {
type: 'object',
properties: {
product_name: {
type: 'string',
description: 'Full descriptive product name (e.g., "Cisco 4431 Integrated Services Router", "Cisco 2504 Wireless Controller") - NOT product IDs like ISR4431'
},
affected_releases: {
type: 'string',
description: 'Comma-separated affected release versions (e.g., "12.5(1)SU5,14.0(1)SU2"). Can search up to 75 versions in one call.'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['product_name', 'affected_releases']
}
},
{
name: 'search_bugs_by_product_name_fixed',
description: 'Search bugs by full product name and fixed releases. NOTE: Requires FULL descriptive product names (like "Cisco 4431 Integrated Services Router") not product IDs. Use search_bugs_by_product_id for product IDs like ISR4431.',
inputSchema: {
type: 'object',
properties: {
product_name: {
type: 'string',
description: 'Full descriptive product name (e.g., "Cisco 4431 Integrated Services Router", "Cisco 2504 Wireless Controller") - NOT product IDs like ISR4431'
},
fixed_releases: {
type: 'string',
description: 'Comma-separated fixed release versions (e.g., "12.5(1)SU6,14.0(1)SU3"). Can search up to 75 versions in one call.'
},
page_index: {
type: 'integer',
default: 1,
description: 'Page number (10 results per page)'
},
status: {
type: 'string',
description: 'Bug status filter. IMPORTANT: Only ONE status allowed per search. Values: O=Open, F=Fixed, T=Terminated. Do NOT use comma-separated values like "O,F".',
enum: ['O', 'F', 'T']
},
severity: {
type: 'string',
description: 'Bug severity filter. Returns bugs with ONLY the specified severity level. Values: 1=Severity 1 (highest), 2=Severity 2, 3=Severity 3, 4=Severity 4, 5=Severity 5, 6=Severity 6 (lowest). For "severity 3 or higher" bugs, use multi_severity_search tool which handles multiple separate API calls.',
enum: ['1', '2', '3', '4', '5', '6']
},
modified_date: {
type: 'string',
description: 'Last modified date filter. Values: 1=Last Week, 2=Last 30 Days, 3=Last 6 Months, 4=Last Year, 5=All. Default: 5 (All)',
enum: ['1', '2', '3', '4', '5'],
default: '5'
},
sort_by: {
type: 'string',
description: 'Sort order for results. Default: modified_date (recent first)',
enum: ['status', 'modified_date', 'severity', 'support_case_count', 'modified_date_earliest']
},
},
required: ['product_name', 'fixed_releases']
}
},
// Enhanced search tools based on user analysis
{
name: 'smart_search_strategy',
title: 'Smart Search Strategy Advisor',
description: 'Analyzes search queries and suggests optimal search approaches based on input patterns. Provides strategic guidance for finding bugs effectively.',
inputSchema: {
type: 'object',
properties: {
query_description: {
type: 'string',
description: 'Describe what you want to search for (e.g., "ISR4431 version 17.09.06 high severity bugs")'
},
search_context: {
type: 'string',
description: 'Context for the search (incident, upgrade planning, maintenance, security review)',
enum: ['incident', 'upgrade_planning', 'maintenance', 'security_review', 'general']
}
},
required: ['query_description']
}
},
{
name: 'progressive_bug_search',
title: 'Progressive Bug Search',
description: 'Automatically tries multiple search strategies, starting specific and broadening scope if needed. Handles version normalization and product ID variations.',
inputSchema: {
type: 'object',
properties: {
primary_search_term: {
type: 'string',
description: 'Primary search term (product name, model, or keyword)'
},
version: {
type: 'string',
description: 'Software version (will try multiple formats: 17.09.06 -> 17.09 -> 17)'
},
severity_range: {
type: 'string',
description: 'Severity range to search (will search each level separately)',
enum: ['high', 'medium', 'all'],
default: 'high'
},
status: {
type: 'string',
description: 'Bug status filter',
enum: ['O', 'F', 'T']
}
},
required: ['primary_search_term']
}
},
{
name: 'multi_severity_search',
title: 'Multi-Severity Search',
description: 'RECOMMENDED for multi-severity searches: Automatically searches multiple severity levels and combines results. Use this when you need "severity 3 or higher", "high severity bugs", or any range of severities. Handles the API limitation that requires separate calls for each severity level. SMART FALLBACK: When product_id search with version returns no results, automatically falls back to keyword search for better coverage.',
inputSchema: {
type: 'object',
properties: {
search_term: {
type: 'string',
description: 'Search term (keyword or product identifier). For keyword searches, limited to 50 characters. Long product series names will be automatically shortened.'
},
search_type: {
type: 'string',
description: 'Type of search to perform. Use "product_series" for full product names like "Cisco 4000 Series Integrated Services Routers". For product IDs like "ISR4431", use "product_id" which will automatically fallback to keyword search if needed.',
enum: ['keyword', 'product_id', 'product_series']
},
max_severity: {
type: 'integer',
description: 'Maximum severity level to include (1=highest, 6=lowest)',
default: 3,
minimum: 1,
maximum: 6
},
version: {
type: 'string',
description: 'Software version to search for (e.g., "15.0", "14.0", "17.9.6"). Will be automatically included in search terms and used for product_series searches as affected_releases. For product_id searches, enables automatic keyword fallback if no results found.'
}
},
required: ['search_term', 'search_type']
}
},
{
name: 'comprehensive_analysis',
title: 'Comprehensive Bug and Lifecycle Analysis',
description: 'BEST FOR DETAILED ANALYSIS: Combines bug database search with web search guidance for EoL information. Provides complete product analysis including known issues, lifecycle status, and actionable recommendations. Ideal for failover issues, configuration problems, and product reliability concerns.',
inputSchema: {
type: 'object',
properties: {
product_identifier: {
type: 'string',
description: 'Product name, model, or ID to analyze (e.g., ISR4431/K9, Cisco ASR 1000)'
},
software_version: {
type: 'string',
description: 'Software version to analyze (e.g., 17.09.06, 15.1(4)M)'
},
analysis_focus: {
type: 'string',
description: 'Focus of the analysis',
enum: ['security', 'stability', 'lifecycle', 'upgrade_planning', 'incident_response', 'comprehensive'],
default: 'comprehensive'
},
include_web_search_guidance: {
type: 'boolean',
description: 'Include web search queries and strategies for additional research',
default: true
}
},
required: ['product_identifier']
}
},
{
name: 'compare_software_versions',
title: 'Compare Software Versions',
description: 'Compare bugs, CVEs, and recommendations between two software versions on the same product. Analyzes differences in known issues, security vulnerabilities, and provides upgrade recommendations.',
inputSchema: {
type: 'object',
properties: {
product_id: {
type: 'string',
description: 'Product ID or series name (e.g., C9300-24P, ISR4431/K9, "Cisco 4000 Series Integrated Services Routers")'
},
version_a: {
type: 'string',
description: 'First version to compare (e.g., 17.9.1, 15.1(4)M)'
},
version_b: {
type: 'string',
description: 'Second version to compare (e.g., 17.12.3, 15.2(4)M)'
},
include_cve_analysis: {
type: 'boolean',
description: 'Include CVE and security advisory analysis',
default: true
},
include_eol_status: {
type: 'boolean',
description: 'Include end-of-life status comparison',
default: true
},
include_recommendations: {
type: 'boolean',
description: 'Include software upgrade recommendations',
default: true
},
max_severity: {
type: 'integer',
description: 'Maximum bug severity level to include (1=highest, 6=lowest)',
default: 3,
minimum: 1,
maximum: 6
}
},
required: ['product_id', 'version_a', 'version_b']
}
},
{
name: 'product_name_resolver',
title: 'Product Name Resolver',
description: 'Resolves product IDs to full product names and provides web search strategies. Helps convert technical product codes to searchable terms.',
inputSchema: {
type: 'object',
properties: {
product_id: {
type: 'string',
description: 'Product ID to resolve (e.g., ISR4431/K9, WS-C2960-24TC-L)'
},
include_search_strategies: {
type: 'boolean',
description: 'Include recommended web search strategies',
default: true
}
},
required: ['product_id']
}
}
];
}
async executeTool(name, args, meta) {
const { processedArgs } = this.validateTool(name, args);
// Normalize version strings to remove leading zeros (17.09.06 -> 17.9.6)
// This ensures Cisco API compatibility across all tools
if (processedArgs.software_releases) {
processedArgs.software_releases = this.normalizeVersionString(processedArgs.software_releases);
}
if (processedArgs.affected_releases) {
processedArgs.affected_releases = this.normalizeVersionString(processedArgs.affected_releases);
}
if (processedArgs.fixed_releases) {
processedArgs.fixed_releases = this.normalizeVersionString(processedArgs.fixed_releases);
}
if (processedArgs.version) {
processedArgs.version = this.normalizeVersionString(processedArgs.version);
}
// Build API parameters
const apiParams = this.buildStandardParams(processedArgs);
let endpoint;
switch (name) {
case 'get_bug_details':
endpoint = `/bugs/bug_ids/${encodeURIComponent(processedArgs.bug_ids)}`;
break;
case 'search_bugs_by_keyword':
endpoint = `/bugs/keyword/${encodeURIComponent(processedArgs.keyword)}`;
break;
case 'search_bugs_by_product_id':
// Ensure forward slashes are properly encoded for product IDs like ISR4431-V/K9
const encodedBasePid = encodeURIComponent(processedArgs.base_pid).replace(/\//g, '%2F');
endpoint = `/bugs/products/product_id/${encodedBasePid}`;
break;
case 'search_bugs_by_product_and_release':
// Ensure forward slashes are properly encoded for product IDs like ISR4431-V/K9
const encodedBasePidForRelease = encodeURIComponent(processedArgs.base_pid).replace(/\//g, '%2F');
endpoint = `/bugs/products/product_id/${encodedBasePidForRelease}/software_releases/${encodeURIComponent(processedArgs.software_releases)}`;
break;
case 'search_bugs_by_product_series_affected':
endpoint = `/bugs/product_series/${encodeURIComponent(processedArgs.product_series)}/affected_releases/${encodeURIComponent(processedArgs.affected_releases)}`;
break;
case 'search_bugs_by_product_series_fixed':
endpoint = `/bugs/product_series/${encodeURIComponent(processedArgs.product_series)}/fixed_in_releases/${encodeURIComponent(processedArgs.fixed_releases)}`;
logger_js_1.logger.info('Product series fixed endpoint', {
product_series: processedArgs.product_series,
fixed_releases: processedArgs.fixed_releases,
endpoint,
fullUrl: `${this.baseUrl}${endpoint}`
});
break;
case 'search_bugs_by_product_name_affected':
endpoint = `/bugs/products/product_name/${encodeURIComponent(processedArgs.product_name)}/affected_releases/${encodeURIComponent(processedArgs.affected_releases)}`;
break;
case 'search_bugs_by_product_name_fixed':
endpoint = `/bugs/products/product_name/${encodeURIComponent(processedArgs.product_name)}/fixed_in_releases/${encodeURIComponent(processedArgs.fixed_releases)}`;
break;
// Enhanced search tools
case 'smart_search_strategy':
return this.generateSearchStrategy(processedArgs);
case 'progressive_bug_search':
return this.executeProgressiveSearch(processedArgs, meta);
case 'multi_severity_search':
return this.executeMultiSeveritySearch(processedArgs, meta);
case 'comprehensive_analysis':
return this.executeComprehensiveAnalysis(processedArgs, meta);
case 'compare_software_versions':
return this.executeCompareSoftwareVersions(processedArgs, meta);
case 'product_name_resolver':
return this.executeProductNameResolver(processedArgs);
default:
throw new Error(`Tool implementation not found: ${name}`);
}
return await this.makeApiCall(endpoint, apiParams);
}
// Enhanced tool implementations
async generateSearchStrategy(args) {
const queryDescription = args.query_description;
const searchContext = args.search_context || 'general';
// Analyze the query and generate strategy
const strategy = this.analyzeSearchQuery(queryDescription, searchContext);
return {
bugs: [],
total_results: 0,
page_index: 1,
search_strategy: strategy
};
}
analyzeSearchQuery(query, context) {
const strategy = {
recommended_approach: [],
search_parameters: {},
tips: [],
context_specific_advice: []
};
const lowerQuery = query.toLowerCase();
// Detect product patterns
if (lowerQuery.includes('isr44')) {
strategy.recommended_approach.push('Use progressive_bug_search with primary_search_term="ISR4400"');
strategy.search_parameters.product_variations = ['ISR4431/K9', 'ISR4431', 'ISR4400', 'ISR'];
strategy.tips.push('ISR4431 variations: Try ISR4400 series search if exact model fails');
}
// Detect version patterns
const versionMatch = query.match(/(\d+\.\d+\.\d+)/);
if (versionMatch) {
const fullVersion = versionMatch[1];
const shortVersion = fullVersion.split('.').slice(0, 2).join('.');
strategy.recommended_approach.push(`Try version variations: ${fullVersion} -> ${shortVersion}`);
strategy.search_parameters.version_variations = [fullVersion, shortVersion];
strategy.tips.push('Version searching: Start with full version, then try abbreviated (17.09.06 -> 17.09)');
}
// Detect severity patterns
if (lowerQuery.includes('high severity') || lowerQuery.includes('critical')) {
strategy.recommended_approach.push('Use multi_severity_search with max_severity=3');
strategy.search_parameters.severity_strategy = 'Search severities 1, 2, 3 separately and combine';
strategy.tips.push('Severity limitation: API only accepts single values - search each severity individually');
}
// Context-specific advice
switch (context) {
case 'incident':
strategy.context_specific_advice = [
'Focus on open bugs (status=O) with high severity',
'Search for specific error messages or symptoms',
'Check both current and recent software versions',
'Look for workarounds in bug descriptions'
];
break;
case 'upgrade_planning':
strategy.context_specific_advice = [
'Search fixed bugs in target version',
'Check for new bugs introduced in target version',
'Review upgrade-blocking issues',
'Consider end-of-life status of current version'
];
break;
case 'security_review':
strategy.context_specific_advice = [
'Focus on security-related keywords: CVE, DoS, authentication',
'Check recent security advisories',
'Review high-severity security bugs',
'Look for patches and mitigation strategies'
];
break;
}
// General search effectiveness tips
strategy.tips.push('Start specific, then broaden: exact model -> series -> general', 'Try partial version strings for better coverage', 'Use keyword search for symptoms, product search for hardware', 'Combine bug database with web search for complete picture');
return strategy;
}
async executeProgressiveSearch(args, meta) {
const primaryTerm = args.primary_search_term;
const version = args.version;
const severityRange = args.severity_range || 'high';
const status = args.status;
logger_js_1.logger.info('Starting progressive search', { primaryTerm, version, severityRange });
// Send initial progress
const { sendProgress } = await Promise.resolve().then(() => __importStar(require('../mcp-server.js')));
// Build search variations
const searchVariations = [];
// Try product ID approach first
const productVariations = this.normalizeProductId(primaryTerm);
for (const product of productVariations) {
if (version) {
const versionVariations = this.normalizeVersion(version);
for (const v of versionVariations) {
searchVariations.push({
type: 'keyword',
args: { keyword: `${product} ${v}`, status }
});
}
}
searchVariations.push({
type: 'product_id',
args: { base_pid: product, status }
});
searchVariations.push({
type: 'keyword',
args: { keyword: product, status }
});
}
// Try searches with different severity levels based on range
const severityLevels = severityRange === 'high' ? ['1', '2', '3'] :
severityRange === 'medium' ? ['3', '4'] :
['1', '2', '3', '4', '5', '6'];
const totalAttempts = searchVariations.length * severityLevels.length;
let currentAttempt = 0;
let bestResult = { bugs: [], total_results: 0, page_index: 1 };
sendProgress(meta?.progressToken, 0, totalAttempts);
for (const variation of searchVariations) {
for (const severity of severityLevels) {
currentAttempt++;
sendProgress(meta?.progressToken, currentAttempt, totalAttempts);
try {
const searchArgs = { ...variation.args, severity };
let result;
if (variation.type === 'keyword') {
result = await this.executeTool('search_bugs_by_keyword', searchArgs);
}
else {
result = await this.executeTool('search_bugs_by_product_id', searchArgs);
}
if (result.bugs && result.bugs.length > bestResult.bugs.length) {
bestResult = result;
logger_js_1.logger.info('Found better result in progressive search', {
variation: variation.type,
args: searchArgs,
resultCount: result.bugs.length
});
}
// If we found results, we can be less aggressive about continuing
if (result.bugs && result.bugs.length >= 5) {
break;
}
}
catch (error) {
logger_js_1.logger.warn('Progressive search variation failed', {
variation,
severity,
error: error instanceof Error ? error.message : error
});
}
}
if (bestResult.bugs && bestResult.bugs.length >= 10) {
// Send completion progress before breaking
sendProgress(meta?.progressToken, totalAttempts, totalAttempts);
break; // Good enough result found
}
}
// Ensure final progress is sent
sendProgress(meta?.progressToken, totalAttempts, totalAttempts);
return bestResult;
}
async executeMultiSeveritySearch(args, meta) {
const searchTerm = args.search_term;
const searchType = args.search_type;
const maxSeverity = args.max_severity || 3;
const version = args.version;
const additionalParams = args.additional_params || {};
// If version is provided, enhance search parameters
if (version) {
// For product_series searches, use version as affected_releases if not already specified
if (searchType === 'product_series' && !additionalParams.affected_releases && !additionalParams.fixed_releases) {
additionalParams.affected_releases = version;
}
}
logger_js_1.logger.info('Starting multi-severity search', { searchTerm, searchType, maxSeverity, version });
const searchFunc = async (severity) => {
const searchArgs = {
severity,
...additionalParams
};
switch (searchType) {
case 'keyword':
// Handle keyword length limitation (50 characters max)
let keywordTerm = searchTerm;
// Include version in keyword search if provided
if (version) {
keywordTerm = `${searchTerm} ${version}`;