mcp: make discovery good

- There's an mcpDiscoveryRegistry that allows components to register in
  how they discover MCP servers.
- Config discovery is one of these. Figured out all the bits for a
  standalone file config shebang. Duplication there that could be
  cleaned up but it works.
- The others are remote and local filesystem discovery. I ended up
  making another message channel for the main process/remote server to
  get a couple environment variables we need since I didn't see anything
  generic for this already(?)

![](https://memes.peet.io/img/25-03-29927218-daa9-4206-8cef-29992850d9ba.mp4)
This commit is contained in:
Connor Peet
2025-03-10 23:06:29 -07:00
parent 1418a96b8e
commit 81775e7ade
30 changed files with 803 additions and 133 deletions

View File

@@ -118,6 +118,8 @@ import { IAuxiliaryWindowsMainService } from '../../platform/auxiliaryWindow/ele
import { AuxiliaryWindowsMainService } from '../../platform/auxiliaryWindow/electron-main/auxiliaryWindowsMainService.js';
import { normalizeNFC } from '../../base/common/normalization.js';
import { ICSSDevelopmentService, CSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
import { NativeMcpDiscoveryHelperChannelName } from '../../platform/mcp/common/nativeMcpDiscoveryHelper.js';
import { NativeMcpDiscoveryHelperChannel } from '../../platform/mcp/node/nativeMcpDiscoveryHelperChannel.js';
/**
* The main VS Code application. There will only ever be one instance,
@@ -1222,6 +1224,9 @@ export class CodeApplication extends Disposable {
const externalTerminalChannel = ProxyChannel.fromService(accessor.get(IExternalTerminalMainService), disposables);
mainProcessElectronServer.registerChannel('externalTerminal', externalTerminalChannel);
// MCP
mainProcessElectronServer.registerChannel(NativeMcpDiscoveryHelperChannelName, new NativeMcpDiscoveryHelperChannel(undefined));
// Logger
const loggerChannel = new LoggerChannel(accessor.get(ILoggerMainService),);
mainProcessElectronServer.registerChannel('logger', loggerChannel);