add progress notification feature

This commit is contained in:
Artyom Bogachenko 2026-04-03 00:56:34 +03:00
parent b4d97bd888
commit be0619755d
18 changed files with 1311 additions and 57 deletions

View file

@ -8,6 +8,7 @@ const {
} = require('@librechat/agents');
const {
sendEvent,
sendProgress,
MCPOAuthHandler,
isMCPDomainAllowed,
normalizeServerName,
@ -648,6 +649,30 @@ function createToolInstance({
oauthStart,
oauthEnd,
graphTokenResolver: getGraphApiToken,
onProgress: async (progressData) => {
logger.debug(
`[MCP][${serverName}][${toolName}] Sending progress to client:`,
progressData,
);
const eventData = {
progress: progressData.progress,
total: progressData.total,
message: progressData.message,
toolCallId: toolCall.id,
};
try {
if (streamId) {
await GenerationJobManager.emitTransientEvent(streamId, {
event: 'progress',
data: eventData,
});
} else {
sendProgress(res, eventData);
}
} catch (err) {
logger.error(`[MCP][${serverName}][${toolName}] Failed to emit progress:`, err);
}
},
});
if (isAssistantsEndpoint(provider) && Array.isArray(result)) {