@@ -5,7 +5,7 @@ use moka::sync::Cache;
55use nu_engine:: eval_block;
66use nu_parser:: parse;
77use nu_protocol:: {
8- PipelineData , PipelineExecutionData , Value ,
8+ Config , PipelineData , PipelineExecutionData , UseAnsiColoring , Value ,
99 debugger:: WithoutDebug ,
1010 engine:: { EngineState , Stack , StateWorkingSet } ,
1111 write_all_and_flush,
@@ -24,12 +24,18 @@ pub struct Evaluator {
2424
2525impl Evaluator {
2626 pub fn new ( engine_state : Arc < EngineState > ) -> Self {
27+ // Disable ANSI coloring for MCP - it's a computer-to-computer protocol
28+ let mut engine_state = Arc :: unwrap_or_clone ( engine_state) ;
29+ let mut config = Config :: clone ( engine_state. get_config ( ) ) ;
30+ config. use_ansi_coloring = UseAnsiColoring :: False ;
31+ engine_state. set_config ( config) ;
32+
2733 let cache = Cache :: builder ( )
2834 . max_capacity ( 100 )
2935 . time_to_live ( std:: time:: Duration :: from_secs ( 300 ) )
3036 . build ( ) ;
3137 Self {
32- engine_state,
38+ engine_state : Arc :: new ( engine_state ) ,
3339 cache,
3440 }
3541 }
@@ -48,7 +54,7 @@ impl Evaluator {
4854 // Check for parse errors
4955 if let Some ( err) = working_set. parse_errors . first ( ) {
5056 return Err ( McpError :: internal_error (
51- nu_protocol:: format_cli_error ( & working_set, err, Some ( "nu::parser::error" ) ) ,
57+ nu_protocol:: format_cli_error ( & working_set, err, None ) ,
5258 None ,
5359 ) ) ;
5460 }
@@ -57,7 +63,7 @@ impl Evaluator {
5763 // These are caught during the parse/compile phase, before evaluation
5864 if let Some ( err) = working_set. compile_errors . first ( ) {
5965 return Err ( McpError :: internal_error (
60- nu_protocol:: format_cli_error ( & working_set, err, Some ( "nu::compile::error" ) ) ,
66+ nu_protocol:: format_cli_error ( & working_set, err, None ) ,
6167 None ,
6268 ) ) ;
6369 }
0 commit comments