@aashari/boilerplate-mcp-server
Version:
TypeScript MCP server boilerplate with STDIO and HTTP transport support, CLI tools, and extensible architecture
51 lines (50 loc) • 2.45 kB
JavaScript
;
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.')
.option('--jq <expression>', 'JMESPath expression to filter/transform the response.')
.option('-o, --output-format <format>', 'Output format: "toon" (default, token-efficient) or "json".', 'toon')
.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
jq: options.jq,
outputFormat: options.outputFormat,
};
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 };