111
112
public registerCollection(collection: McpCollectionDefinition): IDisposable {
113
>
const currentCollections = this._collections.get();
mcpRegistry.ts
114
>
const toReplace = currentCollections.find(c => c.id === collection.id);
115
>
116
>
// Incoming collections replace the "lazy" versions. See `ExtensionMcpDiscovery` for an example.
117
>
if (toReplace && !toReplace.lazy) {
118
return Disposable.None;
120
this._collections.set(currentCollections.map(c => c === toReplace ? collection : c), undefined);
122
>
this._collections.set([...currentCollections, collection]
123
>
.sort((a, b) => a.order - b.order), undefined);
124
>
}
125
>
126
>
return {
127
>
dispose: () => {
128
>
const currentCollections = this._collections.get();
129
>
this._collections.set(currentCollections.filter(c => c !== collection), undefined);
130
>
}
131
>
};
132
>
}
133
134
public getServerDefinition(collectionRef: McpDefinitionReference, definitionRef: McpDefinitionReference): IObservable<{ server: McpServerDefinition | undefined; collection: McpCollectionDefinition | undefined }> {