mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-27 04:07:05 +00:00
🧹 chore: Type Agent MCP lean projection in ServerConfigsDB (#13171)
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<IAgent, 'mcpServerNames'> and let .lean<T[]>() 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.
This commit is contained in:
parent
77c523ea35
commit
6466263493
1 changed files with 3 additions and 8 deletions
|
|
@ -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<Pick<IAgent, 'mcpServerNames'>[]>();
|
||||
|
||||
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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue