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

44 lines (43 loc) 1.89 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runCli = runCli; const commander_1 = require("commander"); const logger_util_js_1 = require("../utils/logger.util.js"); const constants_util_js_1 = require("../utils/constants.util.js"); const ipaddress_cli_js_1 = __importDefault(require("./ipaddress.cli.js")); /** * CLI entry point for the Boilerplate MCP Server * Handles command registration, parsing, and execution */ // Package description const DESCRIPTION = 'A boilerplate Model Context Protocol (MCP) server implementation using TypeScript'; /** * Run the CLI with the provided arguments * * @param args Command line arguments to process * @returns Promise that resolves when CLI command execution completes */ async function runCli(args) { const cliLogger = logger_util_js_1.Logger.forContext('cli/index.ts', 'runCli'); cliLogger.debug('Initializing CLI with arguments', args); const program = new commander_1.Command(); program.name(constants_util_js_1.CLI_NAME).description(DESCRIPTION).version(constants_util_js_1.VERSION); // Register CLI commands cliLogger.debug('Registering CLI commands...'); ipaddress_cli_js_1.default.register(program); cliLogger.debug('CLI commands registered successfully'); // Handle unknown commands program.on('command:*', (operands) => { cliLogger.error(`Unknown command: ${operands[0]}`); console.log(''); program.help(); process.exit(1); }); // Parse arguments; default to help if no command provided cliLogger.debug('Parsing CLI arguments'); await program.parseAsync(args.length ? args : ['--help'], { from: 'user' }); cliLogger.debug('CLI command execution completed'); }