UNPKG

@cequenceai/mcp-cli

Version:

Cequence MCP CLI - Command-line tool for setting up Cequence MCP servers with AI clients

44 lines (43 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateMcpUrl = validateMcpUrl; exports.validateServerName = validateServerName; exports.sanitizeServerName = sanitizeServerName; const url_1 = require("url"); /** * Validates if a string is a valid Cequence MCP server URL */ function validateMcpUrl(url) { try { const parsedUrl = new url_1.URL(url); // Check if it's HTTP or HTTPS if (!['http:', 'https:'].includes(parsedUrl.protocol)) { return false; } // Check if URL has a valid host if (!parsedUrl.hostname) { return false; } return true; } catch (error) { return false; } } /** * Validates server name (basic validation) */ function validateServerName(name) { if (!name || typeof name !== 'string') { return false; } // Name should be 1-50 characters, alphanumeric with spaces, hyphens, underscores const nameRegex = /^[a-zA-Z0-9\s\-_]{1,50}$/; return nameRegex.test(name.trim()); } /** * Sanitizes server name for use in configuration files */ function sanitizeServerName(name) { return name.trim().replace(/[^a-zA-Z0-9\s\-_]/g, '').substring(0, 50); }