From 646626349340808aa8b85c5399c4eb4247adc73f Mon Sep 17 00:00:00 2001 From: Gaurav Dubey Date: Tue, 19 May 2026 01:02:43 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20chore:=20Type=20Agent=20MCP=20le?= =?UTF-8?q?an=20projection=20in=20ServerConfigsDB=20(#13171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the (a: any) cast and its eslint-disable directive in ServerConfigsDB.getAll() with a precise lean-projection generic. The Mongoose query already projects only mcpServerNames, so we can use Pick and let .lean() carry the shape through without resorting to any. Switches the empty-array guard from || to ?? for clarity; both behave identically for string[] | undefined. Aligns with the project's "Never use any" rule (CLAUDE.md -> Type Safety). No runtime change. --- packages/api/src/mcp/registry/db/ServerConfigsDB.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/api/src/mcp/registry/db/ServerConfigsDB.ts b/packages/api/src/mcp/registry/db/ServerConfigsDB.ts index b1649c66ca..d027fc273e 100644 --- a/packages/api/src/mcp/registry/db/ServerConfigsDB.ts +++ b/packages/api/src/mcp/registry/db/ServerConfigsDB.ts @@ -6,7 +6,7 @@ import { PermissionBits, } from 'librechat-data-provider'; import { logger, encryptV2, decryptV2, createMethods } from '@librechat/data-schemas'; -import type { AllMethods, MCPServerDocument } from '@librechat/data-schemas'; +import type { AllMethods, IAgent, MCPServerDocument } from '@librechat/data-schemas'; import type { IServerConfigsRepositoryInterface } from '~/mcp/registry/ServerConfigsRepositoryInterface'; import type { ParsedServerConfig, AddServerResult } from '~/mcp/types'; import { AccessControlService } from '~/acl/accessControlService'; @@ -370,14 +370,9 @@ export class ServerConfigsDB implements IServerConfigsRepositoryInterface { mcpServerNames: { $exists: true, $not: { $size: 0 } }, }, { mcpServerNames: 1 }, - ).lean(); + ).lean[]>(); - agentMCPServerNames = [ - ...new Set( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - agentsWithMCP.flatMap((a: any) => a.mcpServerNames || []), - ), - ]; + agentMCPServerNames = [...new Set(agentsWithMCP.flatMap((a) => a.mcpServerNames ?? []))]; } const directResults = await this._dbMethods.getListMCPServersByIds({