modelcontextprotocol / modelcontextprotocol/servers
edit_file tool fails with PowerShell expressions containing dollar signs
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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