mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🔧 refactor: Clean up logging statements
This commit is contained in:
parent
cfb19175fb
commit
4b4741b1aa
3 changed files with 12 additions and 43 deletions
|
|
@ -202,28 +202,13 @@ const getAvailableTools = async (req, res) => {
|
|||
const serverName = parts[parts.length - 1];
|
||||
const serverConfig = customConfig?.mcpServers?.[serverName];
|
||||
|
||||
logger.warn(
|
||||
`[getAvailableTools] Processing MCP tool:`,
|
||||
JSON.stringify({
|
||||
pluginKey: plugin.pluginKey,
|
||||
serverName,
|
||||
hasServerConfig: !!serverConfig,
|
||||
hasCustomUserVars: !!serverConfig?.customUserVars,
|
||||
}),
|
||||
);
|
||||
|
||||
if (!serverConfig) {
|
||||
logger.warn(
|
||||
`[getAvailableTools] No server config found for ${serverName}, skipping auth check`,
|
||||
);
|
||||
toolsOutput.push(toolToAdd);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle MCP servers with customUserVars (user-level auth required)
|
||||
if (serverConfig.customUserVars) {
|
||||
logger.warn(`[getAvailableTools] Processing user-level MCP server: ${serverName}`);
|
||||
|
||||
// Build authConfig for MCP tools
|
||||
toolToAdd.authConfig = Object.entries(serverConfig.customUserVars).map(([key, value]) => ({
|
||||
authField: key,
|
||||
|
|
@ -237,10 +222,6 @@ const getAvailableTools = async (req, res) => {
|
|||
const mcpManager = getMCPManager(userId);
|
||||
const connectionStatus = await mcpManager.getUserConnectionStatus(userId, serverName);
|
||||
toolToAdd.authenticated = connectionStatus.connected;
|
||||
logger.warn(`[getAvailableTools] User-level connection status for ${serverName}:`, {
|
||||
connected: connectionStatus.connected,
|
||||
hasConnection: connectionStatus.hasConnection,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`[getAvailableTools] Error checking connection status for ${serverName}:`,
|
||||
|
|
@ -254,38 +235,21 @@ const getAvailableTools = async (req, res) => {
|
|||
}
|
||||
} else {
|
||||
// Handle app-level MCP servers (no auth required)
|
||||
logger.warn(`[getAvailableTools] Processing app-level MCP server: ${serverName}`);
|
||||
toolToAdd.authConfig = [];
|
||||
|
||||
// Check if the app-level connection is active
|
||||
try {
|
||||
const mcpManager = getMCPManager();
|
||||
const allConnections = mcpManager.getAllConnections();
|
||||
logger.warn(`[getAvailableTools] All app-level connections:`, {
|
||||
connectionNames: Array.from(allConnections.keys()),
|
||||
serverName,
|
||||
});
|
||||
|
||||
const appConnection = mcpManager.getConnection(serverName);
|
||||
logger.warn(`[getAvailableTools] Checking app-level connection for ${serverName}:`, {
|
||||
hasConnection: !!appConnection,
|
||||
connectionState: appConnection?.getConnectionState?.(),
|
||||
});
|
||||
|
||||
if (appConnection) {
|
||||
const connectionState = appConnection.getConnectionState();
|
||||
logger.warn(`[getAvailableTools] App-level connection status for ${serverName}:`, {
|
||||
connectionState,
|
||||
hasConnection: !!appConnection,
|
||||
});
|
||||
|
||||
// For app-level connections, consider them authenticated if they're in 'connected' state
|
||||
// This is more reliable than isConnected() which does network calls
|
||||
toolToAdd.authenticated = connectionState === 'connected';
|
||||
logger.warn(`[getAvailableTools] Final authenticated status for ${serverName}:`, {
|
||||
authenticated: toolToAdd.authenticated,
|
||||
connectionState,
|
||||
});
|
||||
} else {
|
||||
logger.warn(`[getAvailableTools] No app-level connection found for ${serverName}`);
|
||||
toolToAdd.authenticated = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue