@@ -16,7 +16,6 @@ import * as vscode from "vscode"
1616import { z } from "zod"
1717import { ClineProvider , GlobalFileNames } from "../../core/webview/ClineProvider"
1818import {
19- DEFAULT_MCP_TIMEOUT_SECONDS ,
2019 McpMode ,
2120 McpResource ,
2221 McpResourceResponse ,
@@ -27,7 +26,7 @@ import {
2726} from "../../shared/mcp"
2827import { fileExistsAtPath } from "../../utils/fs"
2928import { arePathsEqual } from "../../utils/path"
30- import { secondsToMs } from "../../utils/time"
29+
3130export type McpConnection = {
3231 server : McpServer
3332 client : Client
@@ -43,7 +42,6 @@ const StdioConfigSchema = z.object({
4342 env : z . record ( z . string ( ) ) . optional ( ) ,
4443 autoApprove : AutoApproveSchema . optional ( ) ,
4544 disabled : z . boolean ( ) . optional ( ) ,
46- timeout : z . number ( ) . min ( 1 ) . max ( 3600 ) . optional ( ) . default ( DEFAULT_MCP_TIMEOUT_SECONDS ) ,
4745} )
4846
4947const McpSettingsSchema = z . object ( {
@@ -244,6 +242,28 @@ export class McpHub {
244242 }
245243 transport . start = async ( ) => { } // No-op now, .connect() won't fail
246244
245+ // // Set up notification handlers
246+ // client.setNotificationHandler(
247+ // // @ts -ignore-next-line
248+ // { method: "notifications/tools/list_changed" },
249+ // async () => {
250+ // console.log(`Tools changed for server: ${name}`)
251+ // connection.server.tools = await this.fetchTools(name)
252+ // await this.notifyWebviewOfServerChanges()
253+ // },
254+ // )
255+
256+ // client.setNotificationHandler(
257+ // // @ts -ignore-next-line
258+ // { method: "notifications/resources/list_changed" },
259+ // async () => {
260+ // console.log(`Resources changed for server: ${name}`)
261+ // connection.server.resources = await this.fetchResources(name)
262+ // connection.server.resourceTemplates = await this.fetchResourceTemplates(name)
263+ // await this.notifyWebviewOfServerChanges()
264+ // },
265+ // )
266+
247267 // Connect
248268 await client . connect ( transport )
249269 connection . server . status = "connected"
@@ -323,6 +343,10 @@ export class McpHub {
323343 const connection = this . connections . find ( ( conn ) => conn . server . name === name )
324344 if ( connection ) {
325345 try {
346+ // connection.client.removeNotificationHandler("notifications/tools/list_changed")
347+ // connection.client.removeNotificationHandler("notifications/resources/list_changed")
348+ // connection.client.removeNotificationHandler("notifications/stderr")
349+ // connection.client.removeNotificationHandler("notifications/stderr")
326350 await connection . transport . close ( )
327351 await connection . client . close ( )
328352 } catch ( error ) {
@@ -539,7 +563,6 @@ export class McpHub {
539563 if ( connection . server . disabled ) {
540564 throw new Error ( `Server "${ serverName } " is disabled` )
541565 }
542-
543566 return await connection . client . request (
544567 {
545568 method : "resources/read" ,
@@ -563,17 +586,6 @@ export class McpHub {
563586 throw new Error ( `Server "${ serverName } " is disabled and cannot be used` )
564587 }
565588
566- let timeout = secondsToMs ( DEFAULT_MCP_TIMEOUT_SECONDS ) // sdk expects ms
567-
568- try {
569- const config = JSON . parse ( connection . server . config )
570- const parsedConfig = StdioConfigSchema . parse ( config )
571- timeout = secondsToMs ( parsedConfig . timeout )
572- } catch ( error ) {
573- console . error ( `Failed to parse timeout configuration for server ${ serverName } : ${ error } ` )
574- // Continue with default timeout
575- }
576-
577589 return await connection . client . request (
578590 {
579591 method : "tools/call" ,
@@ -583,9 +595,6 @@ export class McpHub {
583595 } ,
584596 } ,
585597 CallToolResultSchema ,
586- {
587- timeout,
588- } ,
589598 )
590599 }
591600
@@ -654,47 +663,6 @@ export class McpHub {
654663 }
655664 }
656665
657- public async updateServerTimeout ( serverName : string , timeout : number ) : Promise < void > {
658- try {
659- // Validate timeout against schema
660- const setConfigResult = StdioConfigSchema . shape . timeout . safeParse ( timeout )
661- if ( ! setConfigResult . success ) {
662- throw new Error ( `Invalid timeout value: ${ timeout } . Must be between 1 and 3600 seconds.` )
663- }
664-
665- const settingsPath = await this . getMcpSettingsFilePath ( )
666- const content = await fs . readFile ( settingsPath , "utf-8" )
667- const config = JSON . parse ( content )
668-
669- if ( ! config . mcpServers ?. [ serverName ] ) {
670- throw new Error ( `Server "${ serverName } " not found in settings` )
671- }
672-
673- // Update the timeout in the config
674- config . mcpServers [ serverName ] = {
675- ...config . mcpServers [ serverName ] ,
676- timeout,
677- }
678-
679- // Write updated config back to file
680- await fs . writeFile ( settingsPath , JSON . stringify ( config , null , 2 ) )
681-
682- // Update server connections to apply the new timeout
683- await this . updateServerConnections ( config . mcpServers )
684-
685- vscode . window . showInformationMessage ( `Updated timeout to ${ timeout } seconds` )
686- } catch ( error ) {
687- console . error ( "Failed to update server timeout:" , error )
688- if ( error instanceof Error ) {
689- console . error ( "Error details:" , error . message , error . stack )
690- }
691- vscode . window . showErrorMessage (
692- `Failed to update server timeout: ${ error instanceof Error ? error . message : String ( error ) } ` ,
693- )
694- throw error
695- }
696- }
697-
698666 async dispose ( ) : Promise < void > {
699667 this . removeAllFileWatchers ( )
700668 for ( const connection of this . connections ) {
0 commit comments