|
3 | 3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
| 6 | +import { MarkdownString } from '../../../../base/common/htmlContent.js'; |
6 | 7 | import { IJSONSchema, IJSONSchemaMap } from '../../../../base/common/jsonSchema.js';
|
| 8 | +import { Disposable } from '../../../../base/common/lifecycle.js'; |
7 | 9 | import { localize } from '../../../../nls.js';
|
8 |
| -import { IMcpCollectionContribution } from '../../../../platform/extensions/common/extensions.js'; |
| 10 | +import { IExtensionManifest, IMcpCollectionContribution } from '../../../../platform/extensions/common/extensions.js'; |
| 11 | +import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js'; |
| 12 | +import { Registry } from '../../../../platform/registry/common/platform.js'; |
9 | 13 | import { mcpSchemaId } from '../../../services/configuration/common/configuration.js';
|
10 | 14 | import { inputsSchema } from '../../../services/configurationResolver/common/configurationResolverSchema.js';
|
| 15 | +import { Extensions, IExtensionFeaturesRegistry, IExtensionFeatureTableRenderer, IRenderedData, IRowData, ITableData } from '../../../services/extensionManagement/common/extensionFeatures.js'; |
11 | 16 | import { IExtensionPointDescriptor } from '../../../services/extensions/common/extensionsRegistry.js';
|
12 | 17 |
|
13 | 18 | const mcpActivationEventPrefix = 'onMcpCollection:';
|
@@ -239,3 +244,42 @@ export const mcpContributionPoint: IExtensionPointDescriptor<IMcpCollectionContr
|
239 | 244 | }
|
240 | 245 | }
|
241 | 246 | };
|
| 247 | + |
| 248 | +class McpServerDefinitionsProviderRenderer extends Disposable implements IExtensionFeatureTableRenderer { |
| 249 | + |
| 250 | + readonly type = 'table'; |
| 251 | + |
| 252 | + shouldRender(manifest: IExtensionManifest): boolean { |
| 253 | + return !!manifest.contributes?.mcpServerDefinitionProviders && Array.isArray(manifest.contributes.mcpServerDefinitionProviders) && manifest.contributes.mcpServerDefinitionProviders.length > 0; |
| 254 | + } |
| 255 | + |
| 256 | + render(manifest: IExtensionManifest): IRenderedData<ITableData> { |
| 257 | + const mcpServerDefinitionProviders = manifest.contributes?.mcpServerDefinitionProviders ?? []; |
| 258 | + const headers = [localize('id', "ID"), localize('name', "Name")]; |
| 259 | + const rows: IRowData[][] = mcpServerDefinitionProviders |
| 260 | + .map(mcpServerDefinitionProvider => { |
| 261 | + return [ |
| 262 | + new MarkdownString().appendMarkdown(`\`${mcpServerDefinitionProvider.id}\``), |
| 263 | + mcpServerDefinitionProvider.label |
| 264 | + ]; |
| 265 | + }); |
| 266 | + |
| 267 | + return { |
| 268 | + data: { |
| 269 | + headers, |
| 270 | + rows |
| 271 | + }, |
| 272 | + dispose: () => { } |
| 273 | + }; |
| 274 | + } |
| 275 | +} |
| 276 | + |
| 277 | +Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({ |
| 278 | + id: mcpConfigurationSection, |
| 279 | + label: localize('mcpServerDefinitionProviders', "MCP Servers"), |
| 280 | + access: { |
| 281 | + canToggle: false |
| 282 | + }, |
| 283 | + renderer: new SyncDescriptor(McpServerDefinitionsProviderRenderer), |
| 284 | +}); |
| 285 | + |
0 commit comments