101
*/
102
public static async create(instaService: IInstantiationService, opts: IMcpServerRequestHandlerOptions, token?: CancellationToken) {
104
>
const store = new DisposableStore();
105
>
try {
106
>
const timer = store.add(new IntervalTimer());
107
>
timer.cancelAndSet(() => {
108
opts.logger.info('Waiting for server to respond to `initialize` request...');
110
>
111
>
await instaService.invokeFunction(async accessor => {
112
>
const productService = accessor.get(IProductService);
113
>
const initialized = await mcp.sendRequest<MCP.InitializeRequest, MCP.InitializeResult>({
114
>
method: 'initialize',
115
>
params: {
116
>
protocolVersion: MCP.LATEST_PROTOCOL_VERSION,
117
>
capabilities: {
118
>
roots: { listChanged: true },
119
>
sampling: opts.createMessageRequestHandler ? {} : undefined,
120
>
elicitation: opts.elicitationRequestHandler ? { form: {}, url: {} } : undefined,
121
>
tasks: {
122
>
list: {},
123
>
cancel: {},
124
>
requests: {
125
>
sampling: opts.createMessageRequestHandler ? { createMessage: {} } : undefined,
126
>
elicitation: opts.elicitationRequestHandler ? { create: {} } : undefined,
127
>
},
128
>
},
129
>
extensions: {
130
>
'io.modelcontextprotocol/ui': {
131
>
mimeTypes: ['text/html;profile=mcp-app']
132
>
}
133
>
}
134
>
},
135
>
clientInfo: {
136
>
name: productService.nameLong,
137
>
version: productService.version,
138
>
}
139
>
}
140
>
}, token);
141
mcp._serverInit = initialized;
142
mcp._sendLogLevelToServer(opts.logger.getLevel());