LibreChat/config/migrate-mcp-reservations.js
Danny Avila 62fd38813e
📒 fix: Restore Scoped MCP Name Allocation and Deletion (#18238)
* fix: Scope durable MCP name reservations by tenant

* refactor: Read legacy reservations in explicit system scope

* feat: Add targeted online MCP reservation index migration
2026-11-16 20:39:53 -05:00

27 lines
931 B
JavaScript

require('dotenv').config();
process.env.MONGO_AUTO_INDEX = 'false';
process.env.MONGO_AUTO_CREATE = 'false';
const mongoose = require('mongoose');
const { migrateMCPReservationIndex } = require('@librechat/data-schemas');
(async () => {
const dryRun = process.argv.includes('--dry-run');
if (!dryRun && !process.argv.includes('--writers-upgraded')) {
console.error(
'Refusing migration: first upgrade every writer to tenant-aware MCP reservations, then pass --writers-upgraded. See UPGRADING.md.',
);
process.exitCode = 1;
return;
}
try {
const connect = require('./connect');
await connect();
const result = await migrateMCPReservationIndex(mongoose.connection, { dryRun });
console.log({ dryRun, ...result });
} catch (error) {
console.error('MCP reservation index migration failed:', error);
process.exitCode = 1;
} finally {
await mongoose.disconnect();
}
})();