
Pwsh Exec Mcp
io.github.Jason26214由 GitHub 帳號 Jason26214 發布v1.0.1更新於 Oct 24, 2026
A minimal, transparent PowerShell 7 MCP for Windows — one tool: raw exit code, stdout, stderr.
概覽
一個精簡的 Windows MCP 伺服器,只提供一個工具,讓助理執行 PowerShell 7 命令並取回原始結束碼、標準輸出與標準錯誤。
- 可以做什麼
- 在新的 pwsh 程序中執行 PowerShell 命令或指令碼,需提供以秒為單位的逾時與可選的絕對工作目錄,回傳結束碼以及帶標籤的 stdout 和 stderr 原文,並附上時間戳與耗時頁尾。每個輸出串流超過 500 行時只保留前後各 250 行。每次呼叫都是無狀態的,目錄切換與變數不會在呼叫之間保留。
- 適用情境
- 適用於 Windows 上的助理需要真實終端機執行一次性命令的情境,例如 git status、檢視檔案或執行短指令碼,並且希望取得未經過濾的原始輸出而非摘要結果。不適合常駐 shell、需要系統管理員權限的工作,以及長時間執行或背景作業。
- 執行需求
- Windows 系統,PATH 中需有 PowerShell 7(pwsh),而非系統內建的 Windows PowerShell 5.1。需要 uv 提供的 uvx 執行器,透過 stdio 啟動這個 PyPI 套件。可選設定 PWSH_EXEC_DEFAULT_DIR 指定預設工作目錄,否則回退到 %TEMP% 下的子目錄。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Pwsh Exec Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
pwsh-exec
[version] [license] [python] [platform] [PowerShell]
A minimal, transparent PowerShell 7 MCP for Windows — one tool: run a command, get raw exit code / stdout / stderr back.
pwsh-exec is a minimal, transparent PowerShell 7 MCP server for Windows. It exposes a single tool, run_command, that runs a command in a fresh pwsh process and returns the raw exit_code, stdout, and stderr — nothing parsed, filtered, or reformatted.
- One tool, three inputs —
command,timeout(seconds), optionalworking_directory. - Transparent — exit code + stdout + stderr returned verbatim, errors and all.
- Stateless — every call is a new process; no session state persists.
- Bounded — 1–300 s timeout per call; on timeout the whole process tree is killed.
- Windows-hardened — UTF-8 output on any locale, PATH read fresh from the registry, no stdin hangs.
- Not for — persistent shells, admin-elevated tasks, or long-running / background jobs.
It gives any AI agent on Windows a real terminal: you send a command, you get back exactly what the terminal produced.
Status — stable & complete
Feature-complete and stable. One tool, a frozen v1.0.0 API, 38 passing tests, in daily use driving real agent work since April 2026 with no known bugs. Reproducible bugs get fixed; the scope stays intentionally small — it does one thing.
Requirements
- Windows
- PowerShell 7 (
pwsh) onPATH— this is the modern cross-platform PowerShell, not the built-in Windows PowerShell 5.1 (powershell.exe). Install it viawinget install Microsoft.PowerShellor from the official install guide. - uv — provides the
uvxrunner used below.
Install
No clone required — uvx fetches and runs it on demand. Register it with your MCP client (stdio transport):
Any MCP client
Use this as the server's launch command:
Claude Desktop
Edit claude_desktop_config.json:
The
cmd /cwrapper is recommended on Claude Desktop: as an Electron app it has no console of its own, and launching a console program directly can leave child processes (pwsh → git and other external.exes) without a working console — flickering windows, lost stdout, PATH lookups failing.cmd.exeacquires the hidden console first and every child inherits it. This is the same pattern Desktop Commander and other Windows MCP servers use.
The tool: run_command
The output is plain text: the exit code first, then labelled stdout and stderr sections (empty ones still show, so the two streams are never ambiguous), then a diagnostic footer with a timestamp and elapsed time.
For example, calling run_command with command: "git status" returns the raw git output, untouched:
Nothing is summarised or filtered. A non-zero exit code, a syntax error written to stderr, an empty result — all of it comes back as the terminal produced it. Output longer than 500 lines per stream is trimmed to the first and last 250 lines so it never floods the context window.
Why it's robust on Windows
Running a shell on Windows from a host process is full of small traps. pwsh-exec handles them so the agent doesn't have to:
- UTF-8 on any locale — output encoding is forced to UTF-8 end to end, so text isn't mangled even on non-English Windows. It was hardened on zh-CN / GBK systems, where these encoding bugs bite hardest; the fix is universal.
- Always-fresh PATH — User-scope environment variables are read from the registry on every call, so CLIs you installed after the host started are still found (and
REG_EXPAND_SZvalues like%USERPROFILE%\...are expanded correctly). - Clean process-tree kills — on timeout the whole tree is terminated (
pwshplus any children it spawned, e.g.node,python), leaving no orphans. - No stdin hangs — stdin is detached, so tools that probe it (git and other MSYS2 programs) don't deadlock.
- Sane truncation — very long output is head+tail trimmed instead of blowing up the model's context.
What it's not for
The small scope is the design. pwsh-exec deliberately does not do:
- Persistent sessions — each call is stateless;
cdand variables don't carry over. Passworking_directory, or combine dependent steps into one command. - Admin-elevated tasks — it runs as the host user, with no elevation.
- Long-running / background jobs — the hard cap is 300 s and calls are synchronous. Installers, large builds, dev servers, and watchers are out of scope.
Configuration
working_directory defaults to a resolved directory, chosen in this order (highest priority first):
- The
working_directoryargument passed on the call. - The
PWSH_EXEC_DEFAULT_DIRenvironment variable, if set. - The built-in fallback:
%TEMP%\pwsh-exec.
To change the default, set PWSH_EXEC_DEFAULT_DIR in your MCP client's config:
An unset or blank value falls back to the built-in default. The default lives under %TEMP% (its own subfolder, so you can wipe it wholesale) rather than scattering files into the shared temp directory.
License
MIT © 2026 Jason26214
來源:README.md,提交 4cb68fd
工具
0版本歷史
1- v1.0.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分