diff --git a/packages/components/nodes/tools/MCP/AnswerAgent/AnswerAgentMCP.ts b/packages/components/nodes/tools/MCP/AnswerAgent/AnswerAgentMCP.ts index 8a709360ed6..5b9664f06c2 100644 --- a/packages/components/nodes/tools/MCP/AnswerAgent/AnswerAgentMCP.ts +++ b/packages/components/nodes/tools/MCP/AnswerAgent/AnswerAgentMCP.ts @@ -132,7 +132,9 @@ class AnswerAgent_MCP implements INode { args: [packagePath], env: { ANSWERAGENT_AI_API_BASE_URL: apiHost, - ANSWERAGENT_AI_API_TOKEN: apiKey + ANSWERAGENT_AI_API_TOKEN: apiKey, + // Subprocess does not inherit process.env; without this the axios client defaults to a 5s timeout + API_TIMEOUT: process.env.ANSWERAGENT_MCP_API_TIMEOUT || '30000' } } diff --git a/packages/server/src/services/documentstore/index.ts b/packages/server/src/services/documentstore/index.ts index 994a1b5ddd6..a0c1c5a18ce 100644 --- a/packages/server/src/services/documentstore/index.ts +++ b/packages/server/src/services/documentstore/index.ts @@ -1989,12 +1989,18 @@ const queryVectorStore = async (data: ICommonObject, workspaceId: string) => { id: uuidv4() } }) - // query our document store chunk with the storeId and pageContent - for (const doc of docs) { - const documentStoreChunk = await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).findOneBy({ - storeId: data.storeId, - pageContent: doc.pageContent + // Backfill chunk id/chunkNo with a single batched query instead of one lookup per doc + const chunkByContent = new Map() + if (docs.length > 0) { + const documentStoreChunks = await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).find({ + where: { storeId: data.storeId, pageContent: In(docs.map((doc: any) => doc.pageContent)) } }) + for (const chunk of documentStoreChunks) { + if (!chunkByContent.has(chunk.pageContent)) chunkByContent.set(chunk.pageContent, chunk) + } + } + for (const doc of docs) { + const documentStoreChunk = chunkByContent.get(doc.pageContent) if (documentStoreChunk) { doc.id = documentStoreChunk.id doc.chunkNo = documentStoreChunk.chunkNo