@ldavis9000aws/swarmui-generator
Version:
A Model Context Protocol server for SwarmUI image generation with TypeScript
56 lines • 1.93 kB
JavaScript
/**
* Server Configuration Module
*
* This module handles loading and validating the server configuration.
*/
import dotenv from 'dotenv';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
/**
* Load environment variables from .env file
*/
export function loadEnvironment() {
dotenv.config();
// Check for required environment variables
const SWARMUI_API_URL = process.env.SWARMUI_API_URL;
if (!SWARMUI_API_URL) {
console.error('❌ ERROR: SWARMUI_API_URL environment variable is not set.');
console.error('Please set SWARMUI_API_URL in your .env file or environment variables.');
console.error('Example: SWARMUI_API_URL=http://your-swarmui-server:port');
process.exit(1);
}
console.error(`Environment loaded, SwarmUI API URL: ${SWARMUI_API_URL}`); // Changed to console.error
}
/**
* Get package version from package.json
* @returns Package version
*/
export function getPackageVersion() {
try {
// Get the directory name of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Go up two levels to find the package.json
const packageJsonPath = path.join(__dirname, '../../package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
return packageJson.version || '1.0.0';
}
catch (error) {
console.warn('Failed to read package.json:', error); // console.warn is fine (goes to stderr)
return '1.0.0';
}
}
/**
* Get server configuration
* @returns Server configuration object
*/
export function getServerConfig() {
const version = getPackageVersion();
return {
name: "swarmui-mcp-server",
description: "MCP server for SwarmUI image generation",
version: version
};
}
//# sourceMappingURL=server-config.js.map