Skip to content

fix: prevent double escaping of string output in eval_on_state and add test - #18260

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:reduce_mcp_escaping
Jun 1, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:reduce_mcp_escaping

Conversation

@fdncred

@fdncred fdncred commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

Talking in discord, we discovered that nu-mcp was escaping nuon mutliple times in the output. This PR tries to address that.

User-facing changes (Release notes)

Reduced escaping in nu-mcp evaluation output

Reduce the amount of escaping that nu-mcp does by using raw-strings.

Before

  {
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "{cwd:/Users/fdncred/src/nushell,history_index:0,timestamp:2026-05-21T15:10:18.619935+00:00,output:\"\\\"[\n  {\n    \\\\\\\"name\\\\\\\": \\\\\\\"assets\\\\\\\",\n    \\\\\\\"type\\\\\\\": \\\\\\\"dir\\\\\\\",\n    \\\\\\\"size\\\\\\\": 160,\n    \\\\\\\"modified\\\\\\\": \\\\\\\"2024-09-14T07:06:47.316979108-05:00\\\\\\\"\n  },\n  {\n    \\\\\\\"name\\\\\\\": \\\\\\\"ast-grep\\\\\\\",\n    \\\\\\\"type\\\\\\\": \\\\\\\"dir\\\\\\\",\n    \\\\\\\"size\\\\\\\": 160,\n    \\\\\\\"modified\\\\\\\": \\\\\\\"2026-01-07T06:22:12.488582817-06:00\\\\\\\"\n  },\n  {\n    \\\\\\\"name\\\\\\\": \\\\\\\"benches\\\\\\\",\n    \\\\\\\"type\\\\\\\": \\\\\\\"dir\\\\\\\",\n    \\\\\\\"size\\\\\\\": 128,\n    \\\\\\\"modified\\\\\\\": \\\\\\\"2026-05-21T08:31:29.486599444-05:00\\\\\\\"\n  }\n]\\\"\"}"
        }
      ],
      "isError": false
    }
  }

After

  {
    "jsonrpc": "2.0",
    "id": 3,
    "result": {
      "content": [
        {
          "type": "text",
          "text": "{cwd:/Users/fdncred/src/nushell,history_index:0,timestamp:2026-05-21T15:20:18.004016+00:00,output:r#'[\n  {\n    \"name\": \"assets\",\n    \"type\": \"dir\",\n    \"size\": 160,\n    \"modified\": \"2024-09-14T07:06:47.316979108-05:00\"\n  },\n  {\n    \"name\": \"ast-grep\",\n    \"type\": \"dir\",\n    \"size\": 160,\n    \"modified\": \"2026-01-07T06:22:12.488582817-06:00\"\n  },\n  {\n    \"name\": \"benches\",\n    \"type\": \"dir\",\n    \"size\": 128,\n    \"modified\": \"2026-05-21T08:31:29.486599444-05:00\"\n  }\n]'#}"
        }
      ],
      "isError": false
    }
  }

Additional notes

@fdncred
fdncred merged commit 6a32107 into nushell:main Jun 1, 2026
18 checks passed
@fdncred
fdncred deleted the reduce_mcp_escaping branch June 1, 2026 15:50
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 1, 2026
@fdncred fdncred added notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:fixes Noted in "Bug fixes" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant