UNPKG

@aashari/boilerplate-mcp-server

Version:

TypeScript MCP server boilerplate with STDIO and HTTP transport support, CLI tools, and extensible architecture

135 lines (126 loc) 4.78 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const logger_util_js_1 = require("../utils/logger.util.js"); const zod_1 = require("zod"); const ipaddress_controller_js_1 = __importDefault(require("../controllers/ipaddress.controller.js")); const logger = logger_util_js_1.Logger.forContext('prompts/analysis.prompt.ts'); /** * Register analysis prompts with the MCP server * Prompts provide pre-structured messages for AI interactions * * @param server The MCP server instance */ function registerPrompts(server) { const registerLogger = logger.forMethod('registerPrompts'); registerLogger.debug('Registering analysis prompts...'); // IP Analysis Prompt - generates structured IP analysis request server.registerPrompt('ip-analysis', { title: 'IP Address Analysis', description: 'Generate a structured analysis request for IP address geolocation and network information', argsSchema: { ipAddress: zod_1.z .string() .optional() .describe('IP address to analyze (omit for current IP)'), focus: zod_1.z .enum([ 'security', 'geolocation', 'network', 'comprehensive', ]) .optional() .describe('Analysis focus: security, geolocation, network, or comprehensive'), }, }, async (variables) => { const methodLogger = logger.forMethod('ipAnalysisPrompt'); try { const ipAddress = variables.ipAddress || undefined; const focus = variables.focus || 'comprehensive'; methodLogger.debug('Generating IP analysis prompt', { ipAddress, focus, }); // Fetch IP details const result = await ipaddress_controller_js_1.default.get({ ipAddress, includeExtendedData: true, useHttps: true, }); // Generate focused prompt based on analysis type let promptText = ''; switch (focus) { case 'security': promptText = `Analyze the security profile of this IP address. Focus on: - Whether it's associated with known threats or malicious activity - Proxy/VPN detection indicators - ASN reputation and ownership - Geographic risk factors IP Data: ${result.content} Provide a security risk assessment and recommendations.`; break; case 'geolocation': promptText = `Analyze the geographic location of this IP address. Focus on: - Precise location accuracy - Timezone and regional context - ISP and connectivity patterns - Distance from major data centers IP Data: ${result.content} Provide geographic insights and potential use cases.`; break; case 'network': promptText = `Analyze the network characteristics of this IP address. Focus on: - ISP and network provider details - ASN and routing information - Connection type and infrastructure - Network performance indicators IP Data: ${result.content} Provide network analysis and technical insights.`; break; default: promptText = `Provide a comprehensive analysis of this IP address covering: - Geolocation and regional context - Network and ISP information - Security and reputation assessment - Potential use cases and considerations IP Data: ${result.content} Deliver a detailed, actionable analysis.`; } return { messages: [ { role: 'user', content: { type: 'text', text: promptText, }, }, ], }; } catch (error) { methodLogger.error('Failed to generate IP analysis prompt', error); // Return error as prompt return { messages: [ { role: 'user', content: { type: 'text', text: `Error generating IP analysis: ${error instanceof Error ? error.message : String(error)}`, }, }, ], }; } }); registerLogger.debug('Analysis prompts registered successfully'); } exports.default = { registerPrompts };