Skip to content

edit_file tool fails with PowerShell expressions containing dollar signs #2033

@DannyJanmaat

Description

@DannyJanmaat

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingserver-filesystemReference implementation for the Filesystem MCP server - src/filesystem

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions