mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 14:08:21 +00:00
* feat: add MCP Apps support
* fix: preserve MCP App results and enforce sandbox policy
* fix: bind persisted MCP Apps to their server configuration
* fix: complete MCP Apps runtime integration
* fix: type the optional MCP App binding codec explicitly
* test: provide MCP Apps policy in bridge mocks
* fix: pass admitted App policy to the tool call owner
* fix: align MCP Apps CI contracts
* test: preserve MCP abort reasons in recovery mocks
* fix: preserve MCP compatibility across policy profiles
* test: use profiled MCP catalog generations
* test: expect the standard MCP session profile
* fix: remove the unused MCP abort import
* test: expect profiled MCP fixture arguments
* test: seed profiled MCP manager fixtures
* Fix request-header bearer resolution after canary merge
* Preserve MCP App views across canary message updates
* Document message-owned MCP App placement
* ci: Recheck MCP Apps Against Canary Base
---------
Co-authored-by: Lia <lia@librechat.ai>
(cherry picked from commit a98d40f61c)
Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/13831
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
const mockCreateMCPAppRateLimiter = jest.fn((kind) => `${kind}-limiter`);
|
|
const mockCreateMCPAppAdmissionRateLimiter = jest.fn(() => 'admission-limiter');
|
|
const mockLimiterCache = jest.fn((key) => `${key}-store`);
|
|
const mockLogViolation = jest.fn();
|
|
const mockGetMCPAppsPolicy = jest.fn(() => ({ maxAdmissionRequestsPerMinute: 240 }));
|
|
|
|
jest.mock('@librechat/api', () => ({
|
|
createMCPAppRateLimiter: (...args) => mockCreateMCPAppRateLimiter(...args),
|
|
createMCPAppAdmissionRateLimiter: (...args) => mockCreateMCPAppAdmissionRateLimiter(...args),
|
|
limiterCache: (...args) => mockLimiterCache(...args),
|
|
}));
|
|
|
|
jest.mock('~/cache/logViolation', () => mockLogViolation);
|
|
jest.mock('~/config', () => ({
|
|
getMCPServersRegistry: () => ({ getMCPAppsPolicy: mockGetMCPAppsPolicy }),
|
|
}));
|
|
|
|
describe('MCP App limiter wiring', () => {
|
|
const previousScore = process.env.TOOL_CALL_VIOLATION_SCORE;
|
|
|
|
beforeAll(() => {
|
|
process.env.TOOL_CALL_VIOLATION_SCORE = '7';
|
|
});
|
|
|
|
afterAll(() => {
|
|
if (previousScore === undefined) {
|
|
delete process.env.TOOL_CALL_VIOLATION_SCORE;
|
|
} else {
|
|
process.env.TOOL_CALL_VIOLATION_SCORE = previousScore;
|
|
}
|
|
});
|
|
|
|
it.each([
|
|
['resource', './mcpAppResourceLimiter', 'mcp_app_resource_limiter'],
|
|
['toolCall', './mcpAppToolCallLimiter', 'mcp_app_tool_call_limiter'],
|
|
])('wires the %s limiter with its independent store', (kind, modulePath, cacheKey) => {
|
|
expect(require(modulePath)).toBe(`${kind}-limiter`);
|
|
expect(mockLimiterCache).toHaveBeenCalledWith(cacheKey);
|
|
expect(mockCreateMCPAppRateLimiter).toHaveBeenCalledWith(kind, {
|
|
store: `${cacheKey}-store`,
|
|
logViolation: mockLogViolation,
|
|
score: '7',
|
|
});
|
|
});
|
|
|
|
it('wires one shared pre-admission limiter to the registry base policy', () => {
|
|
expect(require('./mcpAppAdmissionLimiter')).toBe('admission-limiter');
|
|
expect(mockLimiterCache).toHaveBeenCalledWith('mcp_app_admission_limiter');
|
|
expect(mockCreateMCPAppAdmissionRateLimiter).toHaveBeenCalledWith({
|
|
store: 'mcp_app_admission_limiter-store',
|
|
getLimit: expect.any(Function),
|
|
logViolation: mockLogViolation,
|
|
score: '7',
|
|
});
|
|
|
|
const [[{ getLimit }]] = mockCreateMCPAppAdmissionRateLimiter.mock.calls;
|
|
expect(getLimit()).toBe(240);
|
|
expect(mockGetMCPAppsPolicy).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|