UNPKG

mcp-cisco-support

Version:

MCP server for Cisco Support APIs including Bug Search and future tools

127 lines 4.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiRegistry = exports.SUPPORTED_APIS = void 0; exports.getEnabledAPIs = getEnabledAPIs; exports.createApiRegistry = createApiRegistry; const base_api_js_1 = require("./base-api.js"); const bug_api_js_1 = require("./bug-api.js"); const case_api_js_1 = require("./case-api.js"); const eox_api_js_1 = require("./eox-api.js"); const psirt_api_js_1 = require("./psirt-api.js"); const product_api_js_1 = require("./product-api.js"); const software_api_js_1 = require("./software-api.js"); exports.SUPPORTED_APIS = ['psirt', 'bug', 'case', 'eox', 'product', 'serial', 'rma', 'software']; // Placeholder API class for unimplemented APIs class PlaceholderApi extends base_api_js_1.BaseApi { baseUrl = ''; apiName; constructor(apiName) { super(); this.apiName = apiName; } getTools() { return [ { name: `${this.apiName.toLowerCase()}_placeholder`, description: `⚠️ ${this.apiName} API not yet implemented. Please use Bug API tools instead for related searches.`, inputSchema: { type: 'object', properties: { message: { type: 'string', description: `This is a placeholder - ${this.apiName} API is not yet implemented` } }, required: [] } } ]; } async executeTool(name, args) { return { error: `${this.apiName} API Not Implemented`, message: `The Cisco ${this.apiName} API is not yet implemented in this MCP server. Currently, only the Bug and Case APIs are available.`, alternatives: [ 'Use search_bugs_by_keyword to find bugs related to your topic', 'Use search_bugs_by_product_id if you have a specific product ID', 'Use get_case_details if you have a case ID to investigate' ], example: `Try: "Search for bugs related to your ${this.apiName.toLowerCase()} topic with keyword search"`, available_apis: ['bug', 'case'], planned_apis: ['eox', 'product', 'serial', 'rma', 'software', 'asd'] }; } } // API registry class ApiRegistry { apis = new Map(); enabledApis = []; constructor(enabledApis) { this.enabledApis = enabledApis; this.initializeApis(); } initializeApis() { // Initialize implemented APIs this.apis.set('bug', new bug_api_js_1.BugApi()); this.apis.set('case', new case_api_js_1.CaseApi()); this.apis.set('eox', new eox_api_js_1.EoxApi()); this.apis.set('psirt', new psirt_api_js_1.PsirtApi()); this.apis.set('product', new product_api_js_1.ProductApi()); this.apis.set('software', new software_api_js_1.SoftwareApi()); // Initialize placeholder APIs for unimplemented ones only this.apis.set('serial', new PlaceholderApi('Serial')); this.apis.set('rma', new PlaceholderApi('RMA')); } // Get all tools from enabled APIs getAvailableTools() { const availableTools = []; for (const apiName of this.enabledApis) { const api = this.apis.get(apiName); if (api) { const apiTools = api.getTools(); availableTools.push(...apiTools); } } return availableTools; } // Execute a tool call async executeTool(name, args) { // Find which API owns this tool for (const apiName of this.enabledApis) { const api = this.apis.get(apiName); if (api) { const tools = api.getTools(); const tool = tools.find(t => t.name === name); if (tool) { const result = await api.executeTool(name, args); return { result, apiName }; } } } throw new Error(`Unknown tool: ${name}`); } // Get enabled API names getEnabledApis() { return [...this.enabledApis]; } // Check if an API is enabled isApiEnabled(apiName) { return this.enabledApis.includes(apiName); } } exports.ApiRegistry = ApiRegistry; // Get enabled APIs from environment function getEnabledAPIs() { const supportApiEnv = process.env.SUPPORT_API || 'bug'; if (supportApiEnv.toLowerCase() === 'all') { return exports.SUPPORTED_APIS; } const requestedAPIs = supportApiEnv.toLowerCase().split(',').map(api => api.trim()); return requestedAPIs.filter(api => exports.SUPPORTED_APIS.includes(api)); } // Create API registry instance function createApiRegistry() { const enabledApis = getEnabledAPIs(); return new ApiRegistry(enabledApis); } //# sourceMappingURL=index.js.map