@@ -35,6 +35,33 @@ export class ProcessManager extends EventEmitter {
3535 } ) ;
3636 }
3737
38+ /**
39+ * Resolve command to full path for nsjail execution
40+ * nsjail has limited PATH, so we need full paths for common commands
41+ */
42+ private resolveCommandPath ( command : string ) : string {
43+ // Map of common commands to their full paths
44+ const commandPaths : Record < string , string > = {
45+ 'npx' : '/usr/bin/npx' ,
46+ 'node' : '/usr/bin/node' ,
47+ 'python' : '/usr/bin/python' ,
48+ 'python3' : '/usr/bin/python3'
49+ } ;
50+
51+ // If command is in our map, return full path
52+ if ( commandPaths [ command ] ) {
53+ return commandPaths [ command ] ;
54+ }
55+
56+ // If command already starts with /, assume it's a full path
57+ if ( command . startsWith ( '/' ) ) {
58+ return command ;
59+ }
60+
61+ // Otherwise, try /usr/bin/ as default
62+ return `/usr/bin/${ command } ` ;
63+ }
64+
3865 /**
3966 * Handle process exit - determine if crash and attempt restart
4067 */
@@ -982,6 +1009,15 @@ export class ProcessManager extends EventEmitter {
9821009 const uid = process . getuid ? process . getuid ( ) : 1000 ;
9831010 const gid = process . getgid ? process . getgid ( ) : 1000 ;
9841011
1012+ // Resolve command to full path (nsjail requires full paths)
1013+ const fullCommandPath = this . resolveCommandPath ( config . command ) ;
1014+
1015+ this . logger . debug ( {
1016+ operation : 'command_path_resolved' ,
1017+ original_command : config . command ,
1018+ resolved_command : fullCommandPath
1019+ } , `Resolved command path: ${ config . command } -> ${ fullCommandPath } ` ) ;
1020+
9851021 // Build nsjail arguments based on working production configuration
9861022 const nsjailArgs = [
9871023 '-Mo' , // Mount mode: once, don't remount
@@ -1019,7 +1055,7 @@ export class ProcessManager extends EventEmitter {
10191055 '--disable_no_new_privs' , // May be needed for some packages
10201056 '--hostname' , `mcp-${ config . team_id } ` , // Team-specific hostname
10211057 '--' , // End of nsjail args
1022- config . command , // MCP server command (e.g., /usr/bin/npx)
1058+ fullCommandPath , // MCP server command with full path (e.g., /usr/bin/npx)
10231059 ...config . args // MCP server arguments
10241060 ] ;
10251061
0 commit comments