From d404297a4d0b64b726bca00f9ff740ca9cee57d6 Mon Sep 17 00:00:00 2001 From: Inferencebot Date: Tue, 27 Oct 2026 22:39:55 +0000 Subject: [PATCH] =?UTF-8?q?sync-keys.js:=20write=20pluginauths.userId=20as?= =?UTF-8?q?=20a=20STRING=20=E2=80=94=20image=20generation=20was=20broken?= =?UTF-8?q?=20for=20every=20member?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LibreChat's PluginAuth schema keys on a string userId; Key (the chat key collection) is ObjectId-typed and Mongoose casts for it. The seeder used `user._id` (an ObjectId) for BOTH, so every MCP auth row it wrote was invisible to PluginService.getUserPluginAuthValue(): string lookup -> 0 rows (what the app does) ObjectId lookup-> 1 row Consequence: userMCPAuthMap['mcp_inference-image'] was empty for every member, ToolService skipped the server ("missing user configuration"), and any agent expecting MCP tools failed with AgentToolInitializationError: "The agent is configured to use MCP tools, but none are available" — 7 times since Oct 19, most recently 2026-10-27 22:29. The image-generation MCP server (generate_image) was unavailable to everyone. The docs server was unaffected (it declares no customUserVars). Fix: String(uid) in the two pluginauths upserts only. The keys[] upserts are deliberately left as ObjectId — chat key lookup works and changing it would break the working half. Verified: 54 existing rows migrated ObjectId -> string (backup at /app/data/backup-pluginauths-userid-2026-10-27T2239Z.json), all 55 image rows now string-typed, the app-style string lookup returns a row, and a full seeder run passes its own decrypt guard and encrypt/decrypt round-trip check (54 seeded, 17 skipped). --- sync-keys.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sync-keys.js b/sync-keys.js index 46ae51f..2df580e 100644 --- a/sync-keys.js +++ b/sync-keys.js @@ -162,8 +162,8 @@ const mongoose = require("/app/code/librechat/node_modules/mongoose"); // image MCP credential const encImage = await encrypt(sk); await auths.updateOne( - { userId: uid, pluginKey: MCP_PLUGIN_KEY, authField: MCP_AUTH_FIELD }, - { $set: { userId: uid, pluginKey: MCP_PLUGIN_KEY, authField: MCP_AUTH_FIELD, value: encImage } }, + { userId: String(uid), pluginKey: MCP_PLUGIN_KEY, authField: MCP_AUTH_FIELD }, + { $set: { userId: String(uid), pluginKey: MCP_PLUGIN_KEY, authField: MCP_AUTH_FIELD, value: encImage } }, { upsert: true } ); seeded++;