162
163
async call<T>(_ctx: unknown, command: string, arg?: unknown, cancellationToken?: CancellationToken): Promise<T> {
165
>
166
>
switch (command) {
167
>
case 'listServers': {
168
const servers = this._listServers();
169
return servers as T;
170
}
172
const { serverId } = arg as IServerIdArg;
173
const tools = await this._listToolsForServer(serverId);
174
return tools as T;
175
}
177
const { serverId, name, args, chatSessionResource } = arg as ICallToolForServerArgs;
178
const result = await this._callToolForServer(serverId, name, args || {}, chatSessionResource, cancellationToken);
179
return result as T;
180
}
182
const { serverId } = arg as IServerIdArg;
183
const resources = await this._listResourcesForServer(serverId);
184
return resources as T;
185
}
187
const { serverId, uri } = arg as IReadResourceForServerArgs;
188
const result = await this._readResourceForServer(serverId, uri, cancellationToken);
189
return result as T;
190
}
192
const { serverId } = arg as IServerIdArg;
193
const templates = await this._listResourceTemplatesForServer(serverId);
194
return templates as T;
195
}
197
198
throw new Error(`Invalid call: ${command}`);
200
201
private _listServers(): readonly IMcpGatewayServerDescriptor[] {