Skip to content

Commit d0d5885

Browse files
authored
remove unused code (microsoft#264342)
1 parent c938341 commit d0d5885

File tree

5 files changed

+2
-186
lines changed

5 files changed

+2
-186
lines changed

src/vs/code/electron-utility/sharedProcess/sharedProcessMain.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ import { ExtensionGalleryManifestIPCService } from '../../../platform/extensionM
125125
import { ISharedWebContentExtractorService } from '../../../platform/webContentExtractor/common/webContentExtractor.js';
126126
import { SharedWebContentExtractorService } from '../../../platform/webContentExtractor/node/sharedWebContentExtractorService.js';
127127
import { McpManagementService } from '../../../platform/mcp/node/mcpManagementService.js';
128-
import { INpmPackageManagementService, NpmPackageService } from '../../../platform/mcp/node/npmPackageService.js';
129128
import { IAllowedMcpServersService, IMcpGalleryService, IMcpManagementService } from '../../../platform/mcp/common/mcpManagement.js';
130129
import { IMcpResourceScannerService, McpResourceScannerService } from '../../../platform/mcp/common/mcpResourceScannerService.js';
131130
import { McpGalleryService } from '../../../platform/mcp/common/mcpGalleryService.js';
@@ -348,7 +347,6 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
348347
services.set(IMcpGalleryManifestService, new McpGalleryManifestIPCService(this.server));
349348
services.set(IMcpGalleryService, new SyncDescriptor(McpGalleryService, undefined, true));
350349
services.set(IMcpResourceScannerService, new SyncDescriptor(McpResourceScannerService, undefined, true));
351-
services.set(INpmPackageManagementService, new SyncDescriptor(NpmPackageService, undefined, true));
352350
services.set(IMcpManagementService, new SyncDescriptor(McpManagementService, undefined, true));
353351

354352
// Extension Gallery

src/vs/code/node/cliProcessMain.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import { IExtensionGalleryManifestService } from '../../platform/extensionManage
7070
import { ExtensionGalleryManifestService } from '../../platform/extensionManagement/common/extensionGalleryManifestService.js';
7171
import { IAllowedMcpServersService, IMcpGalleryService, IMcpManagementService } from '../../platform/mcp/common/mcpManagement.js';
7272
import { McpManagementService } from '../../platform/mcp/node/mcpManagementService.js';
73-
import { INpmPackageManagementService, NpmPackageService } from '../../platform/mcp/node/npmPackageService.js';
7473
import { IMcpResourceScannerService, McpResourceScannerService } from '../../platform/mcp/common/mcpResourceScannerService.js';
7574
import { McpGalleryService } from '../../platform/mcp/common/mcpGalleryService.js';
7675
import { AllowedMcpServersService } from '../../platform/mcp/common/allowedMcpServersService.js';
@@ -237,7 +236,6 @@ class CliMain extends Disposable {
237236
services.set(IMcpResourceScannerService, new SyncDescriptor(McpResourceScannerService, undefined, true));
238237
services.set(IMcpGalleryManifestService, new SyncDescriptor(McpGalleryManifestService, undefined, true));
239238
services.set(IMcpGalleryService, new SyncDescriptor(McpGalleryService, undefined, true));
240-
services.set(INpmPackageManagementService, new SyncDescriptor(NpmPackageService, undefined, true));
241239
services.set(IMcpManagementService, new SyncDescriptor(McpManagementService, undefined, true));
242240

243241
// Telemetry

src/vs/platform/mcp/node/mcpManagementService.ts

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ import { IEnvironmentService } from '../../environment/common/environment.js';
88
import { IFileService } from '../../files/common/files.js';
99
import { ILogService } from '../../log/common/log.js';
1010
import { IUriIdentityService } from '../../uriIdentity/common/uriIdentity.js';
11-
import { IGalleryMcpServer, IMcpGalleryService, IMcpManagementService, InstallOptions, ILocalMcpServer, RegistryType, IInstallableMcpServer, IGalleryMcpServerConfiguration } from '../common/mcpManagement.js';
11+
import { IGalleryMcpServer, IMcpGalleryService, IMcpManagementService, InstallOptions, ILocalMcpServer, RegistryType, IInstallableMcpServer } from '../common/mcpManagement.js';
1212
import { McpUserResourceManagementService as CommonMcpUserResourceManagementService, McpManagementService as CommonMcpManagementService } from '../common/mcpManagementService.js';
1313
import { IMcpResourceScannerService } from '../common/mcpResourceScannerService.js';
14-
import { McpServerType } from '../common/mcpPlatformTypes.js';
15-
import { INpmPackageManagementService } from './npmPackageService.js';
16-
import { Schemas } from '../../../base/common/network.js';
17-
import { IConfigurationService } from '../../configuration/common/configuration.js';
18-
1914

2015
export class McpUserResourceManagementService extends CommonMcpUserResourceManagementService {
2116
constructor(
@@ -26,8 +21,6 @@ export class McpUserResourceManagementService extends CommonMcpUserResourceManag
2621
@ILogService logService: ILogService,
2722
@IMcpResourceScannerService mcpResourceScannerService: IMcpResourceScannerService,
2823
@IEnvironmentService environmentService: IEnvironmentService,
29-
@IConfigurationService private readonly configurationService: IConfigurationService,
30-
@INpmPackageManagementService private readonly npmPackageService: INpmPackageManagementService,
3124
) {
3225
super(mcpResource, mcpGalleryService, fileService, uriIdentityService, logService, mcpResourceScannerService, environmentService);
3326
}
@@ -41,9 +34,7 @@ export class McpUserResourceManagementService extends CommonMcpUserResourceManag
4134
const manifest = await this.updateMetadataFromGallery(server);
4235
const packageType = options?.packageType ?? manifest.packages?.[0]?.registry_type ?? RegistryType.REMOTE;
4336

44-
const { config, inputs } = packageType === RegistryType.NODE
45-
? await this.getNodePackageMcpServerConfiguration(server, manifest)
46-
: this.getMcpServerConfigurationFromManifest(manifest, packageType);
37+
const { config, inputs } = this.getMcpServerConfigurationFromManifest(manifest, packageType);
4738

4839
const installable: IInstallableMcpServer = {
4940
name: server.name,
@@ -69,73 +60,6 @@ export class McpUserResourceManagementService extends CommonMcpUserResourceManag
6960
}
7061
}
7162

72-
private async getNodePackageMcpServerConfiguration(server: IGalleryMcpServer, manifest: IGalleryMcpServerConfiguration): Promise<Omit<IInstallableMcpServer, 'name'>> {
73-
if (this.configurationService.getValue('chat.mcp.enableNpmInstall') !== true) {
74-
return this.getMcpServerConfigurationFromManifest(manifest, RegistryType.NODE);
75-
}
76-
77-
const nodePackage = manifest.packages?.find(p => p.registry_type === RegistryType.NODE);
78-
if (!nodePackage) {
79-
throw new Error('No npm package found in manifest');
80-
}
81-
82-
const location = this.getLocation(server.name, server.version);
83-
if (!(await this.fileService.exists(location))) {
84-
await this.fileService.createFolder(location);
85-
}
86-
87-
const packageVersion = !nodePackage.version || nodePackage.version === 'latest' ? await this.npmPackageService.getLatestPackageVersion(nodePackage.identifier) : nodePackage.version;
88-
await this.npmPackageService.installPackage(nodePackage.identifier, packageVersion, location.with({ scheme: Schemas.file }).fsPath);
89-
90-
const entryPoint = await this.findPackageEntryPoint(nodePackage.identifier, location);
91-
const result = this.getMcpServerConfigurationFromManifest(manifest, RegistryType.NODE);
92-
if (result.config.type === McpServerType.LOCAL && result.config.args) {
93-
const newArgs = [...result.config.args];
94-
newArgs[0] = entryPoint.with({ scheme: Schemas.file }).fsPath;
95-
return {
96-
config: {
97-
...result.config,
98-
command: 'node',
99-
args: newArgs,
100-
version: server.version
101-
},
102-
inputs: result.inputs
103-
};
104-
}
105-
return result;
106-
}
107-
108-
private async findPackageEntryPoint(packageName: string, packageLocation: URI): Promise<URI> {
109-
const nodeModulesPath = this.uriIdentityService.extUri.joinPath(packageLocation, 'node_modules', packageName);
110-
const packageJsonPath = this.uriIdentityService.extUri.joinPath(nodeModulesPath, 'package.json');
111-
112-
try {
113-
const packageJsonContent = await this.fileService.readFile(packageJsonPath);
114-
const packageJson = JSON.parse(packageJsonContent.value.toString());
115-
116-
if (packageJson.bin) {
117-
if (typeof packageJson.bin === 'string') {
118-
return this.uriIdentityService.extUri.joinPath(nodeModulesPath, packageJson.bin);
119-
} else if (typeof packageJson.bin === 'object') {
120-
const binName = packageJson.bin[packageName] || Object.values(packageJson.bin)[0];
121-
if (binName) {
122-
return this.uriIdentityService.extUri.joinPath(nodeModulesPath, binName as string);
123-
}
124-
}
125-
}
126-
127-
if (packageJson.main) {
128-
return this.uriIdentityService.extUri.joinPath(nodeModulesPath, packageJson.main);
129-
}
130-
131-
return this.uriIdentityService.extUri.joinPath(nodeModulesPath, 'index.js');
132-
133-
} catch (error) {
134-
this.logService.error('Failed to read package.json for entry point', packageName, error);
135-
throw new Error(`Could not find entry point for package ${packageName}`);
136-
}
137-
}
138-
13963
}
14064

14165
export class McpManagementService extends CommonMcpManagementService implements IMcpManagementService {

src/vs/platform/mcp/node/npmPackageService.ts

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/vs/server/node/serverServices.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ import { IExtensionGalleryManifestService } from '../../platform/extensionManage
8787
import { ExtensionGalleryManifestIPCService } from '../../platform/extensionManagement/common/extensionGalleryManifestServiceIpc.js';
8888
import { IAllowedMcpServersService, IMcpGalleryService, IMcpManagementService } from '../../platform/mcp/common/mcpManagement.js';
8989
import { McpManagementService } from '../../platform/mcp/node/mcpManagementService.js';
90-
import { INpmPackageManagementService, NpmPackageService } from '../../platform/mcp/node/npmPackageService.js';
9190
import { McpGalleryService } from '../../platform/mcp/common/mcpGalleryService.js';
9291
import { IMcpResourceScannerService, McpResourceScannerService } from '../../platform/mcp/common/mcpResourceScannerService.js';
9392
import { McpManagementChannel } from '../../platform/mcp/common/mcpManagementIpc.js';
@@ -228,7 +227,6 @@ export async function setupServerServices(connectionToken: ServerConnectionToken
228227
services.set(IAllowedMcpServersService, new SyncDescriptor(AllowedMcpServersService));
229228
services.set(IMcpResourceScannerService, new SyncDescriptor(McpResourceScannerService));
230229
services.set(IMcpGalleryService, new SyncDescriptor(McpGalleryService));
231-
services.set(INpmPackageManagementService, new SyncDescriptor(NpmPackageService));
232230
services.set(IMcpManagementService, new SyncDescriptor(McpManagementService));
233231

234232
instantiationService.invokeFunction(accessor => {

0 commit comments

Comments
 (0)