Skip to main content
Glama

Nessus MCP Server

nessus-api.ts3.68 kB
/** * Nessus API client * This file provides an interface to the Nessus API with fallback to mock data */ import { scanTemplates, createMockScan, getMockScanStatus, getMockScanResults, getMockVulnerabilityDetails, mockScans } from './mock-data.js'; // Configuration for Nessus API interface NessusConfig { url?: string; accessKey?: string; secretKey?: string; useMock: boolean; } // Default configuration const defaultConfig: NessusConfig = { useMock: true }; // Current configuration let config: NessusConfig = { ...defaultConfig }; /** * Initialize the Nessus API client * @param newConfig Configuration options */ export const initializeNessusApi = (newConfig: Partial<NessusConfig> = {}) => { config = { ...defaultConfig, ...newConfig }; // Check if we have API credentials if (config.url && config.accessKey && config.secretKey) { config.useMock = false; console.log("Nessus API client initialized with real API credentials"); } else { config.useMock = true; console.log("Nessus API client initialized in mock mode"); } return config; }; /** * Get available scan templates */ export const getScanTemplates = async () => { if (config.useMock) { return { templates: scanTemplates }; } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * Start a new scan * @param target Target IP or hostname * @param scanType Type of scan to run */ export const startScan = async (target: string, scanType: string) => { if (config.useMock) { const scanId = createMockScan(target, scanType); return { scan_id: scanId, status: "queued", message: "Scan queued successfully" }; } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * Get scan status * @param scanId ID of the scan */ export const getScanStatus = async (scanId: string) => { if (config.useMock) { return getMockScanStatus(scanId); } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * Get scan results * @param scanId ID of the scan */ export const getScanResults = async (scanId: string) => { if (config.useMock) { return getMockScanResults(scanId); } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * List all scans */ export const listScans = async () => { if (config.useMock) { const scans = Array.from(mockScans.values()).map(scan => ({ id: scan.id, target: scan.target, type: scan.type, status: scan.status, created: scan.created })); return { scans }; } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * Get vulnerability details * @param vulnId Vulnerability ID (e.g., CVE number) */ export const getVulnerabilityDetails = async (vulnId: string) => { if (config.useMock) { return getMockVulnerabilityDetails(vulnId); } // Real API implementation would go here throw new Error("Real API not implemented"); }; /** * Check if the Nessus API is available */ export const checkApiStatus = async () => { if (config.useMock) { return { status: "ok", mode: "mock", message: "Using mock Nessus API" }; } try { // Real API implementation would go here // For now, just return a placeholder return { status: "ok", mode: "real", message: "Connected to Nessus API" }; } catch (error) { return { status: "error", mode: "real", message: `Failed to connect to Nessus API: ${error}` }; } };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Cyreslab-AI/nessus-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server