🐛 fix: Improve Error Handling when Adding MCP Server Fails (#10823)

* 🐛 fix: Improve error handling when adding MCP server fails

* Update api/server/controllers/mcp.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update api/server/controllers/mcp.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
Co-authored-by: Danny Avila <danny@librechat.ai>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Atef Bellaaj 2025-12-10 02:12:50 +01:00 committed by Danny Avila
parent 885508fc74
commit d08f7c2c8a
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
4 changed files with 30 additions and 3 deletions

View file

@ -175,6 +175,12 @@ const createMCPServerController = async (req, res) => {
});
} catch (error) {
logger.error('[createMCPServer]', error);
if (error.message?.startsWith('MCP_INSPECTION_FAILED')) {
return res.status(400).json({
error: 'MCP_INSPECTION_FAILED',
message: error.message,
});
}
res.status(500).json({ message: error.message });
}
};
@ -229,6 +235,12 @@ const updateMCPServerController = async (req, res) => {
res.status(200).json(parsedConfig);
} catch (error) {
logger.error('[updateMCPServer]', error);
if (error.message?.startsWith('MCP_INSPECTION_FAILED:')) {
return res.status(400).json({
error: 'MCP_INSPECTION_FAILED',
message: error.message,
});
}
res.status(500).json({ message: error.message });
}
};