mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-22 11:20:15 +01:00
fix: correct improper handling of failure state in reinitialize endpoint
This commit is contained in:
parent
084de9a912
commit
37701d3e9b
2 changed files with 18 additions and 4 deletions
|
|
@ -452,11 +452,19 @@ router.post('/:serverName/reinitialize', requireJwtAuth, async (req, res) => {
|
||||||
`[MCP Reinitialize] Sending response for ${serverName} - oauthRequired: ${oauthRequired}, oauthUrl: ${oauthUrl ? 'present' : 'null'}`,
|
`[MCP Reinitialize] Sending response for ${serverName} - oauthRequired: ${oauthRequired}, oauthUrl: ${oauthUrl ? 'present' : 'null'}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const getResponseMessage = () => {
|
||||||
|
if (oauthRequired) {
|
||||||
|
return `MCP server '${serverName}' ready for OAuth authentication`;
|
||||||
|
}
|
||||||
|
if (userConnection) {
|
||||||
|
return `MCP server '${serverName}' reinitialized successfully`;
|
||||||
|
}
|
||||||
|
return `Failed to reinitialize MCP server '${serverName}'`;
|
||||||
|
};
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: userConnection && !oauthRequired,
|
||||||
message: oauthRequired
|
message: getResponseMessage(),
|
||||||
? `MCP server '${serverName}' ready for OAuth authentication`
|
|
||||||
: `MCP server '${serverName}' reinitialized successfully`,
|
|
||||||
serverName,
|
serverName,
|
||||||
oauthRequired,
|
oauthRequired,
|
||||||
oauthUrl,
|
oauthUrl,
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,12 @@ export function useMCPServerManager() {
|
||||||
|
|
||||||
cleanupServerState(serverName);
|
cleanupServerState(serverName);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
showToast({
|
||||||
|
message: localize('com_ui_mcp_init_failed', { 0: serverName }),
|
||||||
|
status: 'error',
|
||||||
|
});
|
||||||
|
cleanupServerState(serverName);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[MCP Manager] Failed to initialize ${serverName}:`, error);
|
console.error(`[MCP Manager] Failed to initialize ${serverName}:`, error);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue