UNPKG

@aashari/boilerplate-mcp-server

Version:

TypeScript Model Context Protocol (MCP) server boilerplate providing IP lookup tools/resources. Includes CLI support and extensible structure for connecting AI systems (LLMs) to external data sources like ip-api.com. Ideal template for creating new MCP in

47 lines (46 loc) 2.15 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 error_util_js_1 = require("../utils/error.util.js"); const ipaddress_controller_js_1 = __importDefault(require("../controllers/ipaddress.controller.js")); const logger = logger_util_js_1.Logger.forContext('cli/ipaddress.cli.ts'); /** * Register IP address CLI commands * @param program The Commander program instance */ function register(program) { const methodLogger = logger.forMethod('register'); methodLogger.debug('Registering IP address CLI commands...'); program .command('get-ip-details') .description('Gets geolocation and network details about an IP address or the current device.') .argument('[ipAddress]', 'IP address to lookup (omit for current IP)') .option('-e, --include-extended-data', 'Include extended data (ASN, host, org). Requires API token.') .option('--no-use-https', // commander creates a 'useHttps' boolean, defaulting to true 'Use HTTP instead of HTTPS for the API call.') .action(async (ipAddress, options) => { const actionLogger = logger.forMethod('action:get-ip-details'); try { actionLogger.debug(`CLI get-ip-details called`, { ipAddress, options, }); // Create a single args object to pass to the controller const args = { ipAddress, includeExtendedData: options.includeExtendedData || false, useHttps: options.useHttps, // commander handles the default via --no-use-https }; const result = await ipaddress_controller_js_1.default.get(args); console.log(result.content); } catch (error) { (0, error_util_js_1.handleCliError)(error); } }); methodLogger.debug('IP address CLI commands registered successfully'); } exports.default = { register };