@@ -36,6 +36,7 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
3636 protected _toolsList : any [ ] = [ ] ;
3737 protected serverInitializeResult : InitializeResult | null = null ;
3838 protected clientSessionTimeoutSeconds ?: number ;
39+ protected timeout : number ;
3940
4041 params : DefaultMCPServerStdioOptions ;
4142 private _name : string ;
@@ -44,6 +45,7 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
4445 constructor ( params : MCPServerStdioOptions ) {
4546 super ( params ) ;
4647 this . clientSessionTimeoutSeconds = params . clientSessionTimeoutSeconds ?? 5 ;
48+ this . timeout = params . timeout ?? DEFAULT_TOOL_CALL_TIMEOUT ;
4749 if ( 'fullCommand' in params ) {
4850 const elements = params . fullCommand . split ( ' ' ) ;
4951 const command = elements . shift ( ) ;
@@ -121,7 +123,6 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
121123 async callTool (
122124 toolName : string ,
123125 args : Record < string , unknown > | null ,
124- timeout ?: number ,
125126 ) : Promise < CallToolResultContent > {
126127 const { CallToolResultSchema } = await import (
127128 '@modelcontextprotocol/sdk/types.js'
@@ -131,12 +132,16 @@ export class NodeMCPServerStdio extends BaseMCPServerStdio {
131132 'Server not initialized. Make sure you call connect() first.' ,
132133 ) ;
133134 }
134- const response = await this . session . callTool ( {
135- name : toolName ,
136- arguments : args ?? { } ,
137- } , undefined , {
138- timeout : timeout ?? DEFAULT_TOOL_CALL_TIMEOUT
139- } ) ;
135+ const response = await this . session . callTool (
136+ {
137+ name : toolName ,
138+ arguments : args ?? { } ,
139+ } ,
140+ undefined ,
141+ {
142+ timeout : this . timeout ,
143+ } ,
144+ ) ;
140145 const parsed = CallToolResultSchema . parse ( response ) ;
141146 const result = parsed . content ;
142147 this . debugLog (
@@ -168,6 +173,7 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
168173 protected _toolsList : any [ ] = [ ] ;
169174 protected serverInitializeResult : InitializeResult | null = null ;
170175 protected clientSessionTimeoutSeconds ?: number ;
176+ protected timeout : number ;
171177
172178 params : MCPServerStreamableHttpOptions ;
173179 private _name : string ;
@@ -178,6 +184,7 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
178184 this . clientSessionTimeoutSeconds = params . clientSessionTimeoutSeconds ?? 5 ;
179185 this . params = params ;
180186 this . _name = params . name || `streamable-http: ${ this . params . url } ` ;
187+ this . timeout = params . timeout ?? DEFAULT_TOOL_CALL_TIMEOUT ;
181188 }
182189
183190 async connect ( ) : Promise < void > {
@@ -241,7 +248,6 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
241248 async callTool (
242249 toolName : string ,
243250 args : Record < string , unknown > | null ,
244- timeout ?: number ,
245251 ) : Promise < CallToolResultContent > {
246252 const { CallToolResultSchema } = await import (
247253 '@modelcontextprotocol/sdk/types.js'
@@ -251,12 +257,16 @@ export class NodeMCPServerStreamableHttp extends BaseMCPServerStreamableHttp {
251257 'Server not initialized. Make sure you call connect() first.' ,
252258 ) ;
253259 }
254- const response = await this . session . callTool ( {
255- name : toolName ,
256- arguments : args ?? { } ,
257- } , undefined , {
258- timeout : timeout ?? DEFAULT_TOOL_CALL_TIMEOUT
259- } ) ;
260+ const response = await this . session . callTool (
261+ {
262+ name : toolName ,
263+ arguments : args ?? { } ,
264+ } ,
265+ undefined ,
266+ {
267+ timeout : this . timeout ,
268+ } ,
269+ ) ;
260270 const parsed = CallToolResultSchema . parse ( response ) ;
261271 const result = parsed . content ;
262272 this . debugLog (
0 commit comments