Files
aryx/tests/main/sessionToolingConfig.test.ts
T
David KayaandCopilot e5878ba9e8 feat: auto-discover MCP servers from project and user config files
Scan .vscode/mcp.json, .mcp.json, .copilot/mcp.json (project-level) and
~/.copilot/mcp.json (user-level) for MCP server definitions. Discovered
servers require explicit user acceptance before activation.

Backend:
- Add ConfigScannerRegistry with per-format scanners and  substitution
- Add discovered tooling domain model with fingerprint-based change detection
- Integrate scanning into workspace load, project add, and project selection
- Merge accepted discovered MCPs into effective runtime tooling
- Extend sidecar contracts with env/headers for real-world MCP configs
- Add IPC channels for accept/dismiss/rescan operations

Frontend:
- Add DiscoveredToolingModal for reviewing pending MCP servers
- Auto-show modal when pending discoveries exist on load or project switch
- Add amber badge on sidebar project headers for pending discoveries
- Add discovered MCP section in Settings panel with accept/dismiss/rescan
- Group InlinePills tool dropdown by Workspace MCP / User MCP / Project MCP
- Pass effective project tooling (including accepted discoveries) to ChatPane

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-25 21:54:06 +01:00

121 lines
3.2 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import {
buildRunTurnToolingConfig,
validateSessionToolingSelectionIds,
} from '@main/sessionToolingConfig';
import type { SessionToolingSelection, WorkspaceToolingSettings } from '@shared/domain/tooling';
const TIMESTAMP = '2026-03-25T00:00:00.000Z';
const TOOLING: WorkspaceToolingSettings = {
mcpServers: [
{
id: 'mcp-git',
name: 'Git MCP',
transport: 'local',
command: 'node',
args: ['server.js'],
cwd: 'C:\\workspace\\repo',
env: { DEBUG: 'true' },
tools: ['git.status'],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
},
{
id: 'mcp-remote',
name: 'Remote MCP',
transport: 'http',
url: 'https://example.com/mcp',
headers: { Authorization: 'Bearer token' },
tools: ['remote.tool'],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
},
],
lspProfiles: [
{
id: 'lsp-ts',
name: 'TypeScript',
command: 'typescript-language-server',
args: ['--stdio'],
languageId: 'typescript',
fileExtensions: ['.ts', '.tsx'],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
},
],
};
describe('session tooling config helpers', () => {
test('validates selected tooling ids against configured workspace tooling', () => {
const selection: SessionToolingSelection = {
enabledMcpServerIds: ['mcp-git'],
enabledLspProfileIds: ['lsp-ts'],
};
expect(() => validateSessionToolingSelectionIds(TOOLING, selection)).not.toThrow();
expect(() =>
validateSessionToolingSelectionIds(TOOLING, {
enabledMcpServerIds: ['missing-mcp'],
enabledLspProfileIds: [],
}),
).toThrow('Unknown MCP server "missing-mcp".');
expect(() =>
validateSessionToolingSelectionIds(TOOLING, {
enabledMcpServerIds: [],
enabledLspProfileIds: ['missing-lsp'],
}),
).toThrow('Unknown LSP profile "missing-lsp".');
});
test('builds a run-turn tooling config from selected MCP and LSP ids', () => {
expect(
buildRunTurnToolingConfig(TOOLING, {
enabledMcpServerIds: ['mcp-git', 'mcp-remote'],
enabledLspProfileIds: ['lsp-ts'],
}),
).toEqual({
mcpServers: [
{
id: 'mcp-git',
name: 'Git MCP',
transport: 'local',
tools: ['git.status'],
command: 'node',
args: ['server.js'],
cwd: 'C:\\workspace\\repo',
env: { DEBUG: 'true' },
},
{
id: 'mcp-remote',
name: 'Remote MCP',
transport: 'http',
tools: ['remote.tool'],
url: 'https://example.com/mcp',
headers: { Authorization: 'Bearer token' },
},
],
lspProfiles: [
{
id: 'lsp-ts',
name: 'TypeScript',
command: 'typescript-language-server',
args: ['--stdio'],
languageId: 'typescript',
fileExtensions: ['.ts', '.tsx'],
},
],
});
});
test('returns undefined when no session tooling is selected', () => {
expect(
buildRunTurnToolingConfig(TOOLING, {
enabledMcpServerIds: [],
enabledLspProfileIds: [],
}),
).toBeUndefined();
});
});