486
487
public async resolveConnection(opts: IMcpResolveConnectionOptions): Promise<IMcpServerConnection | undefined> {
488
>
const { collectionRef, definitionRef, interaction, logger, debug } = opts;
mcpRegistry.ts
489
>
let collection = this._collections.get().find(c => c.id === collectionRef.id);
490
>
if (collection?.lazy) {
491
await collection.lazy.load();
492
collection = this._collections.get().find(c => c.id === collectionRef.id);
493
}
495
>
const definition = collection?.serverDefinitions.get().find(s => s.id === definitionRef.id);
496
>
if (!collection || !definition) {
497
throw new Error(`Collection or definition not found for ${collectionRef.id} and ${definitionRef.id}`);
498
}
500
>
const delegate = this._delegates.get().find(d => d.canStart(collection, definition));
501
>
if (!delegate) {
502
throw new Error('No delegate found that can handle the connection');
503
}
505
>
const trusted = await this._checkTrust(collection, definition, opts);
506
>
interaction?.participants.set(definition.id, { s: 'resolved' });
507
>
if (!trusted) {
508
return undefined;
509
}