mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 21:08:17 +00:00
🧪 test: Cover MCP App Operation Limits in Authenticated Startup Config (#16429)
(cherry picked from commit 626df3fa76)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16429
This commit is contained in:
parent
c92ea0a470
commit
f18db2e84e
3 changed files with 77 additions and 2 deletions
|
|
@ -440,6 +440,34 @@ describe('GET /api/config', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('publishes deployment-owned MCP App operation limits over the defaults', async () => {
|
||||
mockGetAppConfig.mockResolvedValue({
|
||||
...baseAppConfig,
|
||||
mcpSettings: { apps: true },
|
||||
mcpAppSandbox: { operationLimits: { timeoutMs: 45000, maxActive: 4 } },
|
||||
});
|
||||
const response = await request(createApp(mockUser)).get('/api/config');
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.mcpApps.operationLimits).toEqual({
|
||||
maxBytes: 4 * 1024 * 1024,
|
||||
timeoutMs: 45000,
|
||||
maxActive: 4,
|
||||
});
|
||||
});
|
||||
|
||||
it('publishes no operation limits override when the deployment sets none', async () => {
|
||||
mockGetAppConfig.mockResolvedValue({
|
||||
...baseAppConfig,
|
||||
mcpSettings: { apps: true },
|
||||
mcpAppSandbox: { maxActiveViews: 7 },
|
||||
});
|
||||
const response = await request(createApp(mockUser)).get('/api/config');
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.mcpApps).not.toHaveProperty('operationLimits');
|
||||
});
|
||||
|
||||
it('should include modelSpecs, balance, and webSearch', async () => {
|
||||
mockGetAppConfig.mockResolvedValue(baseAppConfig);
|
||||
process.env.CHECK_BALANCE = 'true';
|
||||
|
|
|
|||
|
|
@ -271,13 +271,20 @@ function writeRuntimeMockConfig() {
|
|||
].join('\n'),
|
||||
}
|
||||
: { allowedDomain: '', stdioEnv: '', networkServers: '' };
|
||||
/** Longer than the 30s default, so no fixture can time out sooner, and distinct from it, so the
|
||||
* startup config shows whether the deployment's operation limits reach the client. */
|
||||
const mcpAppOperationLimits = [' operationLimits:', ' timeoutMs: 45000'];
|
||||
const mcpAppsConfig = enableMcpApps
|
||||
? {
|
||||
setting:
|
||||
mcpAppsPolicy === 'omitted'
|
||||
? ''
|
||||
: `apps: ${mcpAppsPolicy === 'false' ? 'false' : 'true'}`,
|
||||
sandbox: ['mcpAppSandbox:', ` url: ${JSON.stringify(mcpSandboxUrl)}`].join('\n'),
|
||||
sandbox: [
|
||||
'mcpAppSandbox:',
|
||||
` url: ${JSON.stringify(mcpSandboxUrl)}`,
|
||||
...mcpAppOperationLimits,
|
||||
].join('\n'),
|
||||
allowedDomain: `- http://127.0.0.1:${MCP_APP_PORT}`,
|
||||
server: [
|
||||
'e2e-app:',
|
||||
|
|
@ -288,7 +295,12 @@ function writeRuntimeMockConfig() {
|
|||
' timeout: 30000',
|
||||
].join('\n '),
|
||||
}
|
||||
: { setting: '', sandbox: '', allowedDomain: '', server: '' };
|
||||
: {
|
||||
setting: '',
|
||||
sandbox: ['mcpAppSandbox:', ...mcpAppOperationLimits].join('\n'),
|
||||
allowedDomain: '',
|
||||
server: '',
|
||||
};
|
||||
const mcpAppsRateLimits =
|
||||
mcpAppResourceLimit != null && mcpAppToolCallLimit != null
|
||||
? [
|
||||
|
|
|
|||
35
e2e/specs/mock/scenarios/mcp-app-operation-limits.spec.ts
Normal file
35
e2e/specs/mock/scenarios/mcp-app-operation-limits.spec.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import { getPrimaryE2EUser } from '../../../setup/users.mock';
|
||||
|
||||
/**
|
||||
* The client bounds MCP App operations by what the authenticated startup config
|
||||
* publishes, so a deployment's `mcpAppSandbox.operationLimits` must reach it,
|
||||
* merged over the defaults for the fields the deployment leaves out. The harness
|
||||
* configures only `timeoutMs`, above its default, and the other two fields come
|
||||
* from the defaults.
|
||||
*/
|
||||
|
||||
test.describe('MCP App operation limits', () => {
|
||||
test('the startup config publishes the deployment operation limits @scenario:mcp-app-operation-limits-published', async ({
|
||||
request,
|
||||
}) => {
|
||||
const { email, password } = getPrimaryE2EUser();
|
||||
const login = await request.post('/api/auth/login', { data: { email, password } });
|
||||
expect(login.ok()).toBeTruthy();
|
||||
const { token } = (await login.json()) as { token: string };
|
||||
|
||||
const response = await request.get('/api/config', {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
expect(response.ok()).toBeTruthy();
|
||||
const config = (await response.json()) as {
|
||||
mcpApps?: { operationLimits?: { maxBytes: number; timeoutMs: number; maxActive: number } };
|
||||
};
|
||||
expect(config.mcpApps?.operationLimits).toEqual({
|
||||
maxBytes: 4 * 1024 * 1024,
|
||||
timeoutMs: 45000,
|
||||
maxActive: 16,
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue