UNPKG

whodis-mcp-server

Version:

Whodis MCP Server for checking the availability of domain names using WHOIS lookups.

75 lines (74 loc) 3.58 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")); /** * Register IP lookup resources with the MCP server * @param server The MCP server instance */ function registerResources(server) { const methodLogger = logger_util_js_1.Logger.forContext('resources/ipaddress.resource.ts', 'registerResources'); methodLogger.debug(`Registering IP lookup resources...`); // Register resource for current IP details server.resource('Current Device IP', 'ip://current', { description: 'Details about your current public IP address including geolocation and network information', }, async (_uri, _extra) => { const resourceMethodLogger = logger_util_js_1.Logger.forContext('resources/ipaddress.resource.ts', 'resourceHandler'); try { resourceMethodLogger.debug('Handling request for current IP details'); // Include extended data for resource queries by default const controllerOptions = { includeExtendedData: true, }; const resourceContent = await ipaddress_controller_js_1.default.get(undefined, // No IP specified = current device controllerOptions); resourceMethodLogger.debug('Successfully retrieved IP details'); return { contents: [ { uri: 'ip://current', text: resourceContent.content, mimeType: 'text/plain', description: 'Details about your current public IP address including geolocation and network information', }, ], }; } catch (error) { resourceMethodLogger.error(`Error getting IP details`, error); return (0, error_util_js_1.formatErrorForMcpResource)(error, 'ip://current'); } }); // Register resource for Google DNS IP details as an example server.resource('Google DNS IP', 'ip://8.8.8.8', { description: "Details about Google's public DNS server IP", }, async (_uri, _extra) => { const resourceMethodLogger = logger_util_js_1.Logger.forContext('resources/ipaddress.resource.ts', 'googleDnsHandler'); try { resourceMethodLogger.debug('Handling request for Google DNS IP details'); const resourceContent = await ipaddress_controller_js_1.default.get('8.8.8.8', { includeExtendedData: true, }); resourceMethodLogger.debug('Successfully retrieved Google DNS IP details'); return { contents: [ { uri: 'ip://8.8.8.8', text: resourceContent.content, mimeType: 'text/plain', description: "Details about Google's public DNS server IP", }, ], }; } catch (error) { resourceMethodLogger.error(`Error getting Google DNS IP details`, error); return (0, error_util_js_1.formatErrorForMcpResource)(error, 'ip://8.8.8.8'); } }); } exports.default = { registerResources };