powershell-terminal
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@powershell-terminalCheck my Python version and install requests if missing"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PowerShell Terminal
Shared AI + user PowerShell session on Windows ā execute commands, run scripts, automate your PC
PowerShell Terminal lets Claude (the AI assistant) run commands in a persistent, interactive PowerShell 7 session on your Windows machine through a real pseudo-terminal (ConPTY). Watch every command stream into your browser in real time while Claude receives smart-filtered output optimized for token efficiency.
šÆ What Is This?
Imagine telling Claude:
"Check what Python version I have and install requests if it's missing"
"Run my build script and tell me if anything failed"
"Find all .log files modified today and show me any errors"
"Save this cleanup script and run it every time I ask"And Claude does it ā executing commands in your real PowerShell session, analyzing output, saving reusable scripts, and taking action on your behalf.
That's PowerShell Terminal.
Related MCP server: PC-Control MCP Server
⨠Key Features
Core Capabilities
š„ļø Real PowerShell Session ā Persistent
pwsh(PS7) or PS5.1 session via ConPTY; state carries across commands (working directory, variables, activated venv)š Shared Human + AI Terminal ā NiceGUI + xterm.js web terminal at
http://localhost:8090; type your own commands alongside Claude'sš Multi-Terminal Sync ā Open multiple browser tabs, all perfectly synchronized
šŖ No Popup Windows ā Native console executables (
git,python,ipconfig, full paths) run inside ConPTY without spawning new windowsāļø Dual-Stream Output ā You see full output in the browser; Claude receives a token-reduced summary
ā Reliable Completion Detection ā Exit codes and command completion detected via invisible prompt token in OSC escape sequences ā no fragile regex matching
š Multi-Line Commands ā Send readable multi-line blocks (functions, loops, here-strings, piped chains); they execute as a single unit and render as a proper
>>continuation block in the terminal, with variables persisting across the sessionāØļø Interactive Programs ā REPLs, installers, and prompts (
python -i,node,ftp,Read-Host) work end-to-end: Claude drives them turn-by-turn via a state machine (AWAITING_INPUT/IDLE/RUNNING/EXITED) withsend_input,poll, and Ctrl+C. Interactive programs you type yourself in the web terminal work too.š Reconnect Replay ā Reopen or refresh the web terminal and the current screen is restored in color, instead of a blank tab
š Script Library ā Save and reuse named
.ps1scripts; full output persisted on script runsšļø Command History ā Commands grouped into conversations and logged to SQLite with selective output persistence
The Interactive Web Terminal
PowerShell Terminal provides a fully interactive terminal window in your browser at http://localhost:8090 ā it looks and feels just like a native PowerShell window:
You can:
Type commands directly (just like any terminal)
Right-click to Copy/Paste, or use Ctrl+Shift+C / Ctrl+Shift+V
Scroll through the full session scrollback
Watch every command Claude runs appear in real time
Claude can:
Execute commands that stream into your terminal
See results instantly
Continue working while you watch
The key advantage: Complete visibility and control. Every command Claude runs appears in your terminal in real time. You're never in the dark ā it's like sitting side-by-side with an assistant who types commands while you watch the screen.
Multi-Terminal Support: Open multiple browser windows at http://localhost:8090 ā they all stay perfectly synchronized via WebSocket broadcast. Type in one terminal, see it in all terminals instantly.
Terminal Reconnect / History Replay
When you reopen the web terminal (a reopened tab, a refresh, or open_terminal() after a disconnect), the new tab is sent the current screen contents so it isn't blank ā the prompt, recent commands, and their output are restored in color, with the cursor correctly placed. This includes commands you typed, not just Claude's.
Why it's needed: the browser only receives new output from the moment it connects, so before this a reopened tab was blank until you pressed Enter. On connect the server now replays the session's screen buffer (terminal query/response escape sequences are stripped, so the reconnecting terminal can't inject a stray reply into your next command).
Configured under server: in config.yaml:
Setting | Behavior |
| Full buffer from session start ā faithful and cursor-safe (default). |
| Current prompt line only ā no history, but still a usable prompt. |
| Last N lines (byte-capped by |
| Byte cap for the |
Full replay is faithful because it re-feeds the exact byte stream the terminal already processed. A very long/noisy session makes reconnect parse more (seconds at most); switch to a bounded N if that ever matters.
The Dual-Stream Architecture
PowerShell Session Output (ConPTY)
|
[Raw Output]
|
---------+---------
| |
[FULL] [FILTERED]
| |
v v
Web Terminal Claude
(You see all) (Smart summary)You: Full output, colors, and scrollback in the browser terminal
Claude: Token-efficient filtered summary
Both: Same live PowerShell session, synchronized state
Native Exe ā No Popup Windows
A key problem with running an AI-controlled terminal on Windows: native console executables like python, git, ipconfig, or any .exe would spawn a separate conhost.exe popup window, breaking the in-terminal experience.
PowerShell Terminal solves this completely:
A PostCommandLookupAction hook intercepts every native CUI executable before it runs
A PE header check distinguishes console apps (CUI) from GUI apps ā GUI apps like
notepadandcodeopen normally without blockingExecution is handled via
System.Diagnostics.ProcesswithCreateNoWindow=trueand redirected I/O, so output flows through ConPTY instead of a new windowWorks for short names (
git,python), full paths (D:\tools\ffmpeg.exe), and any exe not known in advance
Multi-Line Commands
Claude can send multi-line command blocks ā functions, foreach / if blocks, here-strings, or long piped chains ā and they run as a single unit while rendering as a readable continuation block in your terminal:
PS D:\> if ($true) {
>> $sum = 0
>> 1..10 | ForEach-Object { $sum += $_ }
>> $sum
>> }
55Under the hood, a multi-line command is wrapped in an if ($true) { ... } block and submitted with carriage-return line separators ā the same way a human paste enters the shell. This gives:
One submission, one result ā the whole block completes as a single command with one exit code, so output capture stays clean (no partial/early return)
Variables persist ā the block runs in the current scope, so any variables or functions defined inside remain available to later commands
Accurate success ā an
ifblock (unlike the. { }/& { }call operators) does not reset$?, so a failure in the block's last statement is reported correctly instead of maskedReadable on screen ā the block shows as a normal
>>continuation block instead of scrambling, reordering, or wedging the terminal
Why it is needed: sending raw line-feed (\n) separators to the ConPTY desynchronizes PowerShell's multi-line redraw (lines reverse, the cursor jumps, the session sticks at >>). Matching what a paste does ā carriage returns plus a single-submission wrapper ā avoids that entirely.
Single-line commands are unchanged. If you prefer one line, semicolons (;) still work. The if ($true) { header and } footer are the only additions the wrapper makes to the on-screen echo.
š Quick Start
Requirements
Windows 10 1809+ or Windows 11 (ConPTY required)
PowerShell 7 (
pwsh) recommended; falls back to Windows PowerShell 5.1Python 3.10+
Option A ā Install from PyPI
Step 1: Create a virtual environment
mkdir D:\powershell_terminal
cd D:\powershell_terminal
py -m venv .venv
.\.venv\Scripts\Activate.ps1Step 2: Install the package
pip install powershell-terminal-mcpStep 3: Register with Claude Desktop
notepad $env:APPDATA\Claude\claude_desktop_config.jsonAdd:
{
"mcpServers": {
"powershell-terminal": {
"command": "D:\\powershell_terminal\\.venv\\Scripts\\powershell-terminal-mcp.exe"
}
}
}Option B ā Install from Source (dev)
Step 1: Clone the repo
git clone https://github.com/TiM00R/powershell-terminal-mcp D:\powershell_terminal
cd D:\powershell_terminalStep 2: Create the virtual environment and install dependencies
.\setup_venv.ps1This creates .venv, installs all dependencies (including pywinpty), and installs the project in editable mode.
Step 3: Register with Claude Desktop
notepad $env:APPDATA\Claude\claude_desktop_config.jsonAdd:
{
"mcpServers": {
"powershell-terminal": {
"command": "D:\\powershell_terminal\\.venv\\Scripts\\python.exe",
"args": ["D:\\powershell_terminal\\src\\mcp_server.py"]
}
}
}Fully quit and relaunch Claude Desktop (system tray ā Exit), then open a new conversation. On the first tool call the server starts the PowerShell session and opens the web terminal at http://localhost:8090.
š” Usage Examples
Running Commands
"What Python version do I have?"
"Run git status in D:\myproject"
"List all files modified today in my Downloads folder"
"Check if port 8080 is in use"Scripts & Automation
"Save this build script and run it"
"Run my cleanup script"
"List my saved scripts"Diagnostics & System Info
"Check disk space on all drives"
"What processes are using the most memory?"
"Show me the last 20 lines of the application event log"
"Is the Docker daemon running?"Development Workflows
"Activate the venv and run the tests"
"Install requests and check if it imports correctly"
"Run git log --oneline -10 and summarize what changed"šØ Example Session
You:
Run my test suite and tell me what failed
Claude:
I'll run the tests now...
Web terminal opens automatically at http://localhost:8090
Web Terminal shows (real-time):
PS D:\myproject> python -m pytest tests/ -v
============================= test session starts ==============================
collected 42 items
tests/test_api.py::test_login PASSED [ 2%]
tests/test_api.py::test_auth_required PASSED [ 4%]
tests/test_db.py::test_connection FAILED [ 26%]
...
========================= 3 failed, 39 passed in 8.42s =========================Claude receives (filtered summary):
pytest: 42 tests, 3 failed, 39 passed (8.4s)
Failed: test_connection, test_insert_duplicate, test_rollbackClaude responds:
3 tests failed, all in
test_db.pyā looks like a database connection issue. Want me to look at the error details and fix them?
šļø Architecture
How It Works
Claude <--stdio JSON-RPC--> mcp_server.py
|
SharedTerminalState
/ | \
PwshSession OutputBuffer SmartOutputFilter SQLite (db.py)
(ConPTY via (full human (AI token- (conversations,
pywinpty) scrollback) reduced view) commands, scripts)
|
NiceGUI + xterm.js web terminal (shared, multi-tab)A single
pwshprocess runs inside a ConPTY (pywinpty). A background thread reads its output into a circular buffer.The session's prompt is overridden (in the MCP session only) to emit a unique completion token + exit status inside invisible OSC escape sequences. The browser swallows them; the server detects them in the raw stream.
An output start-marker (emitted via a PSReadLine Enter handler, also invisible) lets the server separate a command's real output from the terminal's echo of the typed command.
Human keystrokes from the browser are passed through raw and are not tracked by the AI's completion detection, so the two streams never collide.
Project Structure
powershell_terminal/
āāā config/
ā āāā config.yaml # Web port, filter thresholds, error patterns
āāā data/
ā āāā commands.db # SQLite: conversations, commands, scripts
āāā scripts/ # Headless test harnesses
ā āāā test_pwsh_session.py # Session: completion, exit codes, interactive, Ctrl+C
ā āāā test_session_output.py # Buffer + dual-stream filter
ā āāā test_mcp_dispatch.py # All MCP tools via direct dispatch
āāā src/
ā āāā config/ # Configuration loading
ā āāā output/ # Output filtering and buffering
ā āāā pwsh/ # PowerShell session (ConPTY)
ā ā āāā pwsh_launch.py # Shell spawn, init script, native exe hook
ā ā āāā pwsh_session.py # Session lifecycle, run_command, send_input
ā ā āāā session_output.py # Dual-stream wrapper (raw + filtered)
ā ā āāā completion_token.py # Prompt token and OSC escape injection
ā āāā web/
ā ā āāā web_terminal.py # NiceGUI + xterm.js web terminal
ā āāā db.py # SQLite database layer
ā āāā mcp_server.py # MCP server entry point (all tools)
ā āāā shared_state.py # Global session hub
āāā setup_venv.ps1 # One-command environment setup
āāā run_web.py # Launch web terminal standalone (no Claude)Technology Stack
Python 3.10+ ā Core language
MCP Protocol ā Claude integration (stdio JSON-RPC)
pywinpty ā ConPTY pseudo-terminal on Windows
NiceGUI + WebSockets ā Web terminal with multi-tab sync
SQLite ā Command history and script storage
xterm.js ā Browser terminal renderer
š§ MCP Tools Reference
Terminal / Execution
Tool | Description |
| Run a command. Batch (default): filtered output + exit code, |
| Fetch a prior command's output by id. |
| Send a line to a running/interactive program, then wait; returns |
| Accumulate more output from a running/interactive command without sending input. |
| Send Ctrl+C to the running command. |
| Session alive? Web terminal URL. |
| Kill and respawn the PowerShell session (clears all state). |
| Open (or re-open) the web terminal in the browser. |
Scripts
Tool | Description |
| Save (or overwrite) a named |
| List all saved scripts. |
| Run a saved script; full output is always persisted. |
Conversations (History)
Tool | Description |
| Group subsequent commands; returns |
| End the active (or specified) conversation. |
| List recent conversations. |
| Commands logged under a conversation. |
š§ Configuration
config.yaml (project root) controls:
server.host/server.portā Web terminal address (defaultlocalhost:8090)server.replay_linesā On-connect screen replay:-1full buffer (default),0prompt only,Nlast N linesserver.replay_max_bytesā Byte cap for theN > 0replay modeinteractive.idle_ms/interactive.max_s/interactive.poll_msā Interactive-command tuning (defaults600/30/30)Output filter thresholds and error patterns
SQLite database lives at
data\commands.dbin the project root
š”ļø Security Considerations
Web terminal bound to
localhostonly ā not exposed to the networkFull command audit trail in SQLite
The init script runs in the MCP's own session only ā your
$PROFILE, normal PowerShell, and prompt are never modifiedClaude runs commands in your local user context with your normal permissions
š Known Issues & Limitations
Windows only ā ConPTY is a Windows API; Linux/Mac not supported
Interactive TUI apps not supported ā Commands that take over the terminal (e.g.
vim,htop) will hang; use-NonInteractivealternativessshpassword auth via Claude ā Windows OpenSSH reads its password from the console (CONIN$), not stdin, sosshdoesn't prompt through the interactive path (silent exit 255). Use key auth /BatchMode, a scripted client (ftp -s:), or type the password yourself in the web terminal. stdin-based tools (python -i,node,ftp,Read-Host) work.Single session ā One shared PowerShell session; no per-command isolation
Incomplete multi-line commands hang ā A multi-line command with unbalanced braces, parentheses, or quotes stays at the
>>continuation prompt until it times out (returned asstatus: "running") and must be cleared withsend_interrupt(). This is inherent to PowerShell's continuation model, not specific to this tool ā send syntactically complete blocks.
š Development
Run the headless test harnesses without Claude Desktop:
.\.venv\Scripts\python.exe scripts\test_pwsh_session.py # session: completion, exit codes, interactive, Ctrl+C, restart
.\.venv\Scripts\python.exe scripts\test_session_output.py # buffer + dual-stream filter
.\.venv\Scripts\python.exe scripts\test_mcp_dispatch.py # all MCP tools via direct dispatch
python run_web.py # launch web terminal standaloneš Version History
v0.2.0 (July 2026) ā Interactive operation, multi-line commands, reconnect replay
ā Interactive command operation ā Claude can drive interactive programs (REPLs, installers, prompting tools like
python -i,node,ftp,Read-Host) turn-by-turn. A state machine returns{state, output, exit_code, tail}with statesEXITED/AWAITING_INPUT/IDLE/RUNNING;execute_commandgainsinteractive/idle_ms/max_s/expect,send_inputnow waits on the same primitive, and a newpolltool accumulates more output. Per-step latency dropped from the old 60 s token timeout to sub-second (tool-side).ā Human interactive programs fixed ā The native-exe wrapper now bypasses (keeps stdin open) by default, so interactive programs you type yourself in the web terminal (
ftp,python -i, ā¦) prompt correctly instead of dying on EOF. AI batch commands still run wrapped (stdin closed, output captured) ā marked invisibly by a zero-width sentinel, so nothing shows in the shared terminal and batch behavior is unchanged.ā Multi-line commands ā Multi-line command blocks now execute reliably and display as a readable
>>continuation block instead of scrambling/reordering the terminal or wedging at>>. Each block is wrapped in anif ($true) { }and submitted with carriage-return separators (matching how a paste enters the shell), so it runs as one command ā one exit code, clean output capture, variables persist in the session, and$?/successstays accurate (anifblock doesn't reset$?the way. { }/& { }do). The Enter handler now only strips the batch sentinel / emits the output marker on a real submit, leaving interior continuation lines untouched (the prior scramble cause). Single-line commands are unchanged;;still works if you prefer one line.ā Terminal reconnect / history replay ā Reopening the web terminal restores the current screen in color (prompt + recent history, including your own typed commands) instead of a blank tab. Configurable via
server.replay_lines(-1full /0prompt /Nlines) andserver.replay_max_bytes; terminal query/response escapes are stripped so a reconnect can't corrupt the next command.
Breaking:
send_inputnow returns{state, output, exit_code}instead of the previous token-shaped result. The native-exe wrapper default flipped from wrap to bypass (AI batch opts in via the sentinel).
v0.1.2 (July 2026) ā Web terminal fix
ā Duplicate tab fix: opening the terminal on a fresh session no longer spawns two browser tabs.
start()now launches the server only;open_terminal()is the single place that opens a tab, and it always closes any existing tabs before opening exactly one. The output broadcast loop was hardened alongside this rework so a freshly opened tab reliably shows output.
v0.1.1 (July 2026) ā Bug fixes
ā Native exe output routing: native console output (
git,python,netstat,ipconfig, etc.) now flows through the PowerShell success stream instead ofWrite-Host, restoring pipelines (native | Select-String), variable capture ($x = native), and file redirection (native > file). The hidden-windowProcessStartInfobehavior is unchanged, so native exes still run without popup windows.ā Output extraction: quoted-argument and empty-result commands now return clean or empty output instead of echoing the typed input; the captured region is bounded to the current command's start marker.
v0.1.0 (July 2026) ā Initial public release
ā ConPTY-based persistent PowerShell 7 session via
pywinptyā Shared human + AI terminal: NiceGUI + xterm.js web terminal, multi-tab WebSocket sync
ā Native exe fix: all CUI executables run inside ConPTY without popup windows (
System.Diagnostics.Process+CreateNoWindow=true+ redirected I/O)ā PostCommandLookupAction hook covers short names, full paths, and any unknown exe
ā PE header subsystem check: GUI apps (notepad, code) bypass the hook and open normally
ā PATHEXT fix: session always gets a correct PATHEXT so bare command names resolve reliably
ā Dual-stream output: full output in browser, token-reduced view for Claude
ā Reliable command completion via prompt token in invisible OSC escape sequences
ā Interactive commands:
Read-Host,Ctrl+C,send_inputā SQLite history: conversations, commands (selective persistence), saved scripts
ā Full MCP tool set: execute, send_input, interrupt, restart, scripts, conversations
š¤ Contributing
This is Tim's personal project. If you'd like to contribute:
Test on your setup and document any issues found
Suggest improvements or missing features
Share useful scripts you create
š License
MIT
Ready to let Claude run PowerShell for you? Register the MCP server in Claude Desktop and open a new conversation to get started.
Version: 0.2.0 Last Updated: July 2026 Maintainer: Tim
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/TiM00R/powershell-terminal-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server