modelcontextprotocol / modelcontextprotocol/servers

edit_file tool fails with PowerShell expressions containing dollar signs

Open
#2,033 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug server-filesystem
Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Describe the bug
The edit_file tool fails with "Cannot convert undefined or null to object" when newText parameter contains PowerShell expressions with dollar signs and parentheses, specifically $($null -eq $toolObject.Config).
To Reproduce
Steps to reproduce the behavior:

Use edit_file tool with newText containing PowerShell expression: $($null -eq $toolObject.Config)
Tool attempts to parse JSON parameter
Error occurs: "Cannot convert undefined or null to object"

Expected behavior
The edit_file tool should handle PowerShell code with dollar signs and complex expressions without JSON parsing errors, or provide clear documentation about required escaping.
Logs
Error executing code: Cannot convert undefined or null to object
Additional context
The error occurs during JSON parameter parsing in the MCP filesystem server's edit_file function when PowerShell variables and expressions are used in newText strings. Dollar signs in PowerShell code appear to interfere with JSON processing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MCP filesystem server's edit_file function and reproduce the failure using newText containing $($null -eq $toolObject.Config). Trace how the JSON parameters are parsed, then verify that PowerShell expressions with dollar signs and parentheses are handled without the reported error or that the required escaping is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.