mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-19 22:43:38 +00:00
fix: Honor HTTP MCP Fixture Port Overrides (#18446)
This commit is contained in:
parent
43f2c3cea8
commit
130307f04e
2 changed files with 52 additions and 0 deletions
48
e2e/mock-config.test.mjs
Normal file
48
e2e/mock-config.test.mjs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const yaml = createRequire(new URL('../packages/api/package.json', import.meta.url))('js-yaml');
|
||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||
|
||||
// Listing tests loads the real config and writes its runtime YAML without starting services.
|
||||
test('mock config keeps the HTTP MCP URL aligned with its fixture port', () => {
|
||||
for (const overrides of [
|
||||
{ E2E_MCP_HTTP_PORT: '', E2E_MCP_OAUTH_PORT: '' },
|
||||
{ E2E_MCP_HTTP_PORT: '24005', E2E_MCP_OAUTH_PORT: '' },
|
||||
{ E2E_MCP_HTTP_PORT: '8767', E2E_MCP_OAUTH_PORT: '24007' },
|
||||
]) {
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
[
|
||||
require.resolve('@playwright/test/cli'),
|
||||
'test',
|
||||
'--config=e2e/playwright.config.mock.ts',
|
||||
'--list',
|
||||
'mcp-allowlist-override.spec.ts',
|
||||
],
|
||||
{
|
||||
cwd: root,
|
||||
env: { ...process.env, ...overrides },
|
||||
encoding: 'utf8',
|
||||
timeout: 30000,
|
||||
},
|
||||
);
|
||||
assert.equal(result.status, 0, result.stderr || result.stdout);
|
||||
const config = yaml.load(
|
||||
readFileSync(new URL('.generated/librechat.e2e.yaml', import.meta.url), 'utf8'),
|
||||
);
|
||||
assert.equal(
|
||||
config.mcpServers['e2e-http'].url,
|
||||
`http://127.0.0.1:${overrides.E2E_MCP_HTTP_PORT || '8765'}/mcp`,
|
||||
);
|
||||
assert.equal(
|
||||
config.mcpServers['e2e-oauth'].url,
|
||||
`http://127.0.0.1:${overrides.E2E_MCP_OAUTH_PORT || '8767'}/mcp`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
@ -260,10 +260,13 @@ const preservedCredentialEnvKeys = new Set([
|
|||
*/
|
||||
function writeRuntimeMockConfig() {
|
||||
const template = fs.readFileSync(configTemplatePath, 'utf8');
|
||||
// Keep this URL out of the other substitutions when the override uses another fixture's default port.
|
||||
const httpMcpPlaceholder = '__E2E_HTTP_MCP_URL__';
|
||||
let config =
|
||||
process.env.E2E_MODEL_SPECS_ENFORCE === 'true'
|
||||
? template.replace('\n enforce: false\n', '\n enforce: true\n')
|
||||
: template;
|
||||
config = config.replace('http://127.0.0.1:8765/mcp', httpMcpPlaceholder);
|
||||
config = config.replace(
|
||||
' agents:\n',
|
||||
` agents:\n managementApi: ${JSON.stringify({ auth: managementAuth })}\n`,
|
||||
|
|
@ -408,6 +411,7 @@ function writeRuntimeMockConfig() {
|
|||
if (MCP_OAUTH_PORT !== '8767') {
|
||||
config = config.split('127.0.0.1:8767').join(`127.0.0.1:${MCP_OAUTH_PORT}`);
|
||||
}
|
||||
config = config.replace(httpMcpPlaceholder, `http://127.0.0.1:${MCP_HTTP_PORT}/mcp`);
|
||||
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
||||
fs.writeFileSync(configPath, config);
|
||||
if (enableDynamicMcp) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue