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>
This commit is contained in:
David Kaya
2026-03-25 21:54:06 +01:00
co-authored by Copilot
parent 08a1132d86
commit e5878ba9e8
27 changed files with 2466 additions and 45 deletions
+90
View File
@@ -3,6 +3,8 @@ import { describe, expect, test } from 'bun:test';
import {
listApprovalToolDefinitions,
normalizeWorkspaceSettings,
resolveProjectToolingSettings,
resolveWorkspaceToolingSettings,
validateLspProfileDefinition,
validateMcpServerDefinition,
type LspProfileDefinition,
@@ -23,6 +25,7 @@ describe('tooling settings helpers', () => {
command: ' node ',
args: [' --stdio ', ' --stdio ', ''],
cwd: ' C:\\workspace\\repo ',
env: { ' DEBUG ': ' true ', EMPTY: ' ' },
tools: [' git.status ', '', ' git.status '],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
@@ -32,6 +35,7 @@ describe('tooling settings helpers', () => {
name: ' Remote MCP ',
transport: 'http',
url: ' https://example.com/mcp ',
headers: { ' Authorization ': ' Bearer token ', Empty: ' ' },
tools: [],
timeoutMs: 1000,
createdAt: TIMESTAMP,
@@ -64,6 +68,7 @@ describe('tooling settings helpers', () => {
command: 'node',
args: ['--stdio'],
cwd: 'C:\\workspace\\repo',
env: { DEBUG: 'true' },
tools: ['git.status'],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
@@ -73,6 +78,7 @@ describe('tooling settings helpers', () => {
name: 'Remote MCP',
transport: 'http',
url: 'https://example.com/mcp',
headers: { Authorization: 'Bearer token' },
tools: [],
timeoutMs: 1000,
createdAt: TIMESTAMP,
@@ -92,6 +98,9 @@ describe('tooling settings helpers', () => {
},
],
},
discoveredUserTooling: {
mcpServers: [],
},
});
});
@@ -241,4 +250,85 @@ describe('tooling settings helpers', () => {
});
expect(tools.some((tool) => tool.id === 'web_fetch')).toBe(false);
});
test('resolves workspace and project tooling with accepted discovered MCP servers', () => {
const workspaceTooling = resolveWorkspaceToolingSettings(normalizeWorkspaceSettings({
tooling: {
mcpServers: [
{
id: 'manual',
name: 'Manual MCP',
transport: 'local',
command: 'node',
args: ['manual.js'],
tools: ['manual.tool'],
createdAt: TIMESTAMP,
updatedAt: TIMESTAMP,
},
],
lspProfiles: [],
},
discoveredUserTooling: {
mcpServers: [
{
id: 'user-discovered',
name: 'User MCP',
transport: 'local',
command: 'node',
args: ['user.js'],
tools: ['user.tool'],
scope: 'user',
scannerId: 'copilot-user-mcp',
sourcePath: 'C:\\Users\\tester\\.copilot\\mcp.json',
sourceLabel: '~\\.copilot\\mcp.json',
fingerprint: 'fp-user',
status: 'accepted',
},
],
},
}));
expect(workspaceTooling.mcpServers.map((server) => server.id)).toEqual(['manual', 'user-discovered']);
const projectTooling = resolveProjectToolingSettings(
normalizeWorkspaceSettings({
tooling: {
mcpServers: [],
lspProfiles: [],
},
discoveredUserTooling: {
mcpServers: [],
},
}),
{
mcpServers: [
{
id: 'project-discovered',
name: 'Project MCP',
transport: 'http',
url: 'https://example.com/project',
headers: { Authorization: 'Bearer token' },
tools: ['project.tool'],
scope: 'project',
scannerId: 'vscode-mcp',
sourcePath: 'C:\\workspace\\repo\\.vscode\\mcp.json',
sourceLabel: '.vscode\\mcp.json',
fingerprint: 'fp-project',
status: 'accepted',
},
],
},
);
expect(projectTooling.mcpServers).toContainEqual({
id: 'project-discovered',
name: 'Project MCP',
transport: 'http',
url: 'https://example.com/project',
headers: { Authorization: 'Bearer token' },
tools: ['project.tool'],
createdAt: expect.any(String),
updatedAt: expect.any(String),
});
});
});