@@ -67,55 +67,53 @@ async function runWebClient(args: Args): Promise<void> {
67
67
"cli.js" ,
68
68
) ;
69
69
70
- const CLIENT_PORT = process . env . CLIENT_PORT ?? "5173 " ;
71
- const SERVER_PORT = process . env . SERVER_PORT ?? "3000 " ;
70
+ const CLIENT_PORT : string = process . env . CLIENT_PORT ?? "6274 " ;
71
+ const SERVER_PORT : string = process . env . SERVER_PORT ?? "6277 " ;
72
72
73
73
console . log ( "Starting MCP inspector..." ) ;
74
74
75
75
const abort = new AbortController ( ) ;
76
-
77
- let cancelled = false ;
76
+ let cancelled : boolean = false ;
78
77
process . on ( "SIGINT" , ( ) => {
79
78
cancelled = true ;
80
79
abort . abort ( ) ;
81
80
} ) ;
82
81
83
- const server = spawnPromise (
84
- "node" ,
85
- [
86
- inspectorServerPath ,
87
- ...( args . command ? [ `--env` , args . command ] : [ ] ) ,
88
- ...( args . args ? [ `--args=${ args . args . join ( " " ) } ` ] : [ ] ) ,
89
- ] ,
90
- {
91
- env : {
92
- ...process . env ,
93
- PORT : SERVER_PORT ,
94
- MCP_ENV_VARS : JSON . stringify ( args . envArgs ) ,
95
- } ,
96
- signal : abort . signal ,
97
- echoOutput : true ,
98
- } ,
99
- ) ;
100
-
101
- const client = spawnPromise ( "node" , [ inspectorClientPath ] , {
102
- env : { ...process . env , PORT : CLIENT_PORT } ,
103
- signal : abort . signal ,
104
- echoOutput : true ,
105
- } ) ;
106
-
107
- // Make sure our server/client didn't immediately fail
108
- await Promise . any ( [ server , client , delay ( 2 * 1000 ) ] ) ;
109
- const portParam = SERVER_PORT === "3000" ? "" : `?proxyPort=${ SERVER_PORT } ` ;
110
- console . log (
111
- `\n🔍 MCP Inspector is up and running at http://127.0.0.1:${ CLIENT_PORT } ${ portParam } 🚀` ,
112
- ) ;
82
+ let server : ReturnType < typeof spawnPromise > ;
83
+ let serverOk : unknown ;
113
84
114
85
try {
115
- await Promise . any ( [ server , client ] ) ;
116
- } catch ( e ) {
117
- if ( ! cancelled || process . env . DEBUG ) {
118
- throw e ;
86
+ server = spawnPromise (
87
+ "node" ,
88
+ [
89
+ inspectorServerPath ,
90
+ ...( args . command ? [ `--env` , args . command ] : [ ] ) ,
91
+ ...( args . args ? [ `--args=${ args . args . join ( " " ) } ` ] : [ ] ) ,
92
+ ] ,
93
+ {
94
+ env : {
95
+ ...process . env ,
96
+ PORT : SERVER_PORT ,
97
+ MCP_ENV_VARS : JSON . stringify ( args . envArgs ) ,
98
+ } ,
99
+ signal : abort . signal ,
100
+ echoOutput : true ,
101
+ } ,
102
+ ) ;
103
+
104
+ // Make sure server started before starting client
105
+ serverOk = await Promise . race ( [ server , delay ( 2 * 1000 ) ] ) ;
106
+ } catch ( error ) { }
107
+
108
+ if ( serverOk ) {
109
+ try {
110
+ await spawnPromise ( "node" , [ inspectorClientPath ] , {
111
+ env : { ...process . env , PORT : CLIENT_PORT } ,
112
+ signal : abort . signal ,
113
+ echoOutput : true ,
114
+ } ) ;
115
+ } catch ( e ) {
116
+ if ( ! cancelled || process . env . DEBUG ) throw e ;
119
117
}
120
118
}
121
119
}
0 commit comments