mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
🕒 feat: Add Configurable MCP Server Timeouts (#6199)
This commit is contained in:
parent
c8f7588164
commit
780fdf743a
4 changed files with 8 additions and 2 deletions
|
@ -113,12 +113,14 @@ mcpServers:
|
||||||
everything:
|
everything:
|
||||||
# type: sse # type can optionally be omitted
|
# type: sse # type can optionally be omitted
|
||||||
url: http://localhost:3001/sse
|
url: http://localhost:3001/sse
|
||||||
|
timeout: 60000 # 1 minute timeout for this server, this is the default timeout for MCP servers.
|
||||||
puppeteer:
|
puppeteer:
|
||||||
type: stdio
|
type: stdio
|
||||||
command: npx
|
command: npx
|
||||||
args:
|
args:
|
||||||
- -y
|
- -y
|
||||||
- "@modelcontextprotocol/server-puppeteer"
|
- "@modelcontextprotocol/server-puppeteer"
|
||||||
|
timeout: 300000 # 5 minutes timeout for this server
|
||||||
filesystem:
|
filesystem:
|
||||||
# type: stdio
|
# type: stdio
|
||||||
command: npx
|
command: npx
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { extractEnvVariable } from './utils';
|
||||||
|
|
||||||
const BaseOptionsSchema = z.object({
|
const BaseOptionsSchema = z.object({
|
||||||
iconPath: z.string().optional(),
|
iconPath: z.string().optional(),
|
||||||
|
timeout: z.number().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const StdioOptionsSchema = BaseOptionsSchema.extend({
|
export const StdioOptionsSchema = BaseOptionsSchema.extend({
|
||||||
|
|
|
@ -43,12 +43,14 @@ export class MCPConnection extends EventEmitter {
|
||||||
private isInitializing = false;
|
private isInitializing = false;
|
||||||
private reconnectAttempts = 0;
|
private reconnectAttempts = 0;
|
||||||
iconPath?: string;
|
iconPath?: string;
|
||||||
|
timeout?: number;
|
||||||
|
|
||||||
constructor(serverName: string, private readonly options: t.MCPOptions, private logger?: Logger) {
|
constructor(serverName: string, private readonly options: t.MCPOptions, private logger?: Logger) {
|
||||||
super();
|
super();
|
||||||
this.serverName = serverName;
|
this.serverName = serverName;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.iconPath = options.iconPath;
|
this.iconPath = options.iconPath;
|
||||||
|
this.timeout = options.timeout;
|
||||||
this.client = new Client(
|
this.client = new Client(
|
||||||
{
|
{
|
||||||
name: 'librechat-mcp-client',
|
name: 'librechat-mcp-client',
|
||||||
|
|
|
@ -159,7 +159,7 @@ export class MCPManager {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.warn(`[MCP][${serverName}] Not connected, skipping tool fetch`);
|
this.logger.warn(`[MCP][${serverName}] Error fetching tools:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ export class MCPManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`[MCP][${serverName}] Error fetching tools`, error);
|
this.logger.error(`[MCP][${serverName}] Error fetching tools:`, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,6 +209,7 @@ export class MCPManager {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CallToolResultSchema,
|
CallToolResultSchema,
|
||||||
|
{ timeout: connection.timeout },
|
||||||
);
|
);
|
||||||
return formatToolContent(result, provider);
|
return formatToolContent(result, provider);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue