huggingface-mcp-server
Version:
MCP Server for HuggingFace inference endpoints with custom LoRA and story generation
37 lines (36 loc) • 1.68 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.startStdioServer = exports.startHttpServer = void 0;
const server_1 = require("./server");
Object.defineProperty(exports, "startHttpServer", { enumerable: true, get: function () { return server_1.startHttpServer; } });
const stdio_server_1 = require("./stdio-server");
Object.defineProperty(exports, "startStdioServer", { enumerable: true, get: function () { return stdio_server_1.startStdioServer; } });
const dotenv_1 = __importDefault(require("dotenv"));
// Load environment variables
dotenv_1.default.config();
// Start the server if this file is executed directly (not through CLI)
if (require.main === module) {
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
const HUGGINGFACE_API_KEY = process.env.HUGGINGFACE_API_KEY;
const TRANSPORT = process.env.TRANSPORT || 'http';
if (!HUGGINGFACE_API_KEY) {
console.error('Error: HUGGINGFACE_API_KEY environment variable is not set');
process.exit(1);
}
// Start the appropriate server based on the transport
if (TRANSPORT === 'stdio') {
(0, stdio_server_1.startStdioServer)(HUGGINGFACE_API_KEY).catch(error => {
console.error('Failed to start stdio server:', error);
process.exit(1);
});
}
else {
(0, server_1.startHttpServer)(PORT, HUGGINGFACE_API_KEY).catch(error => {
console.error('Failed to start http server:', error);
process.exit(1);
});
}
}