11const ip = require ( 'ip' ) ;
2- const { spawn } = require ( 'child_process' )
3- const env = require ( '../../env.json' )
2+ const { spawn } = require ( 'child_process' ) ;
3+ const env = require ( '../../env.json' ) ;
44
5- const { mcpInspectorWebPort, mcpInspectorServerPort, mcpInspectorDomainWhiteList } = env
5+ const { mcpInspectorWebPort, mcpInspectorServerPort, mcpInspectorDomainWhiteList } = env ;
66
77const startMcpInspector = ( agent ) => {
88 const localIP = ip . address ( ) ;
@@ -11,28 +11,32 @@ const startMcpInspector = (agent) => {
1111 domainWhiteList . push ( `http://localhost:${ port } ` ) ;
1212 domainWhiteList . push ( `http://127.0.0.1:${ port } ` ) ;
1313 domainWhiteList . push ( `http://${ localIP } :${ port } ` ) ;
14- domainWhiteList . push ( ...mcpInspectorDomainWhiteList . map ( domain => `${ domain } :${ port } ` ) ) ;
15- } ) ;
16-
17- const child = spawn ( 'npx' , [
18- // 如果fetch failed, 可以尝试切换到国内镜像
19- '--registry=https://registry.npmjs.org' ,
20- '-y' ,
21- '@modelcontextprotocol/[email protected] ' , 22- ] , {
23- stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
24- cwd : process . cwd ( ) ,
25- env : {
26- ...process . env ,
27- CLIENT_PORT : mcpInspectorWebPort ,
28- SERVER_PORT : mcpInspectorServerPort ,
29- MCP_AUTO_OPEN_ENABLED : false ,
30- HOST : '0.0.0.0' ,
31- DANGEROUSLY_OMIT_AUTH : true ,
32- ALLOWED_ORIGINS : domainWhiteList . join ( ',' ) ,
33- } ,
14+ domainWhiteList . push ( ...mcpInspectorDomainWhiteList . map ( ( domain ) => `${ domain } :${ port } ` ) ) ;
3415 } ) ;
3516
17+ const child = spawn (
18+ 'npx' ,
19+ [
20+ // 如果fetch failed, 可以尝试切换到国内镜像
21+ '--registry=https://registry.npmjs.org' ,
22+ '-y' ,
23+ '@modelcontextprotocol/[email protected] ' , 24+ ] ,
25+ {
26+ stdio : [ 'pipe' , 'pipe' , 'pipe' ] ,
27+ cwd : process . cwd ( ) ,
28+ env : {
29+ ...process . env ,
30+ CLIENT_PORT : mcpInspectorWebPort ,
31+ SERVER_PORT : mcpInspectorServerPort ,
32+ MCP_AUTO_OPEN_ENABLED : false ,
33+ HOST : '0.0.0.0' ,
34+ DANGEROUSLY_OMIT_AUTH : true ,
35+ ALLOWED_ORIGINS : domainWhiteList . join ( ',' ) ,
36+ } ,
37+ }
38+ ) ;
39+
3640 agent . logger . info ( '\n *** MCP INSPECTOR STARTED ***' ) ;
3741
3842 child . stdout . on ( 'data' , ( data ) => {
@@ -52,9 +56,8 @@ const startMcpInspector = (agent) => {
5256 } ) ;
5357
5458 return child ;
55- }
56-
59+ } ;
5760
5861module . exports = {
59- startMcpInspector
60- }
62+ startMcpInspector,
63+ } ;
0 commit comments