You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplify invoke_expression description for Claude Code
- Add API Exploration hint (Invoke-RestMethod, Add-Type for Win32)
- Replace detailed file cmdlet documentation with Get-Help reference
- Claude Code has built-in file editing tools, detailed docs unnecessary
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: PowerShell.MCP.Proxy/Tools/PowerShellTools.cs
+4-40Lines changed: 4 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -110,52 +110,16 @@ public static async Task<string> GetCurrentLocation(
110
110
[McpServerTool]
111
111
[Description(@"Execute PowerShell cmdlets and CLI tools (e.g., git) in persistent console. Session persists: modules, variables, functions, authentication stay active—no re-authentication. Install any modules and learn them via Get-Help. Commands visible in history for user learning.
112
112
113
+
💡 API Exploration: Use Invoke-RestMethod to explore Web APIs and Add-Type for Win32 API testing. Verify API behavior before writing production code—get immediate feedback without compilation.
114
+
113
115
⚠️ CRITICAL - Variable Scope:
114
116
Local variables are NOT preserved between invoke_expression calls. Use $script: or $global: scope to share variables across calls.
115
117
116
118
⚠️ CRITICAL - Verbose/Debug Output:
117
119
Verbose and Debug streams are NOT visible to you. If you need verbose/debug information, ask the user to copy it from the console and share it with you.
118
120
119
-
⚠ CRITICAL - File Operations:
120
-
For user-provided paths (like C:\), use PowerShell.MCP tools ONLY. Server-side tools (such as str_replace) cannot access them.
121
-
When calling invoke_expression for file operations, ALWAYS use these cmdlets. NEVER use Set-Content, Get-Content, or Out-File:
- Replace PART OF LINE → Update-MatchInFile -OldText 'old' -Replacement 'new'
146
-
147
-
Note: All cmdlets support -LiteralPath for exact paths and accept arrays directly (no loops needed). For LineRange, use -1 or 0 for end of file (e.g., 100,-1).
For text file editing, use Get-Help to learn the specialized cmdlets: Show-TextFile, Add-LinesToFile, Update-LinesInFile, Update-MatchInFile, Remove-LinesFromFile.
159
123
For detailed examples: invoke_expression('Get-Help <cmdlet-name> -Examples')")]
0 commit comments