LmsPs
Provides a persistent PowerShell session interface with tools for running commands, managing working directory, and handling environment variables
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., "@LmsPslist all files in the current directory"
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.
LmsPs — LM Studio PowerShell MCP Server
A minimal, environment‑driven MCP server that exposes a persistent PowerShell session to LM Studio. It keeps a single pwsh.exe/powershell.exe process alive and offers tools to run commands, manage cwd, and get/set env vars. Responses to the client are trimmed (default 500 chars) while full I/O is logged.
Features
Tools:
ps_run,cd,cwd,env_get,env_set,pingPersistent PowerShell between calls (stateful session)
500‑char response trim to the client; full logs on disk
All paths/config via environment variables (no hardcoded paths)
Related MCP server: MCP Toolbox
Install (dev)
cd K:/Repos/LmsPs
python -m venv .venv
. .venv/Scripts/activate # Windows
pip install -e .Run (stdio)
From WSL (recommended by LM Studio):
bash K:/Repos/LmsPs/scripts/start_ps_mcp_stdio.shOr directly (Windows):
python -m lmsps.serverEnvironment variables
LMSPS_POWERSHELL_PATH— Preferred path to Windows PowerShell 5.1 (defaultC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe).LMSPS_PWSH— Legacy override for the PowerShell executable (retained for backward compatibility).LMSPS_LOGDIR— log directory (default:<repo>/logs)LMSPS_TRIM_CHARS— max characters returned to client (default:500)LMSPS_TIMEOUT_SEC— per‑call timeout in seconds (default:30)LMSPS_MAX_COMMAND_CHARS— maximum PowerShell command length accepted byps_run(default:8192)
ps_run tool
Arguments
command(required): exact PowerShell command text passed to-Command.timeout_sec(optional): overrides the per-call timeout (defaults toLMSPS_TIMEOUT_SECor 30s).trim_chars(optional): overrides the maximum characters returned to the client (defaults toLMSPS_TRIM_CHARSor 500).
Execution
Uses Windows PowerShell 5.1 (
powershell.exe) with-NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypassto avoid side effects. Override the path withLMSPS_POWERSHELL_PATH(or legacyLMSPS_PWSH).The process runs with the server's current working directory and an environment overlay managed by
env_set.The working directory persists across calls; use
cdto reposition before running relative-path commands.
Return payload
The tool now returns a JSON object with fields:
status:ok,powershell-error,timeout,invalid-command, orinternal-error.exit_code: integer PowerShell exit code (ornullfor tool-level failures).stdout/stderr: decoded (UTF‑16/UTF‑8 aware) output trimmed totrim_chars.message: optional human-readable context (e.g., timeout notice, validation failure).timeout_seconds: populated only for timeout responses so callers know the enforced limit.
Validation & failure modes
Commands must be non-empty strings and shorter than
LMSPS_MAX_COMMAND_CHARS; invalid input returnsstatus: invalid-commandwithout touching PowerShell.Timeouts return
status: timeoutwith any partial decoded output that PowerShell produced.Spawn failures or unexpected exceptions return
status: internal-erroralong with the exception type inmessage.
LM Studio configuration example
Add to your LM Studio settings JSON:
{
"mcpServers": {
"lmsps": {
"command": "bash",
"args": ["-lc", "K:/Repos/LmsPs/scripts/start_ps_mcp_stdio.sh"],
"env": {
"LMSPS_PWSH": "/mnt/c/Program Files/PowerShell/7/pwsh.exe",
"LMSPS_LOGDIR": "/mnt/k/LMstudio/LmsPs/logs",
"LMSPS_TRIM_CHARS": "500"
}
}
}
}Smoke test (from LM Studio)
ps_run→Get-Process | Select-Object -First 3cwd→ should show current locationcd→ change to a test directory and re‑runcwdenv_set/env_get→ write/read a temp environment variableRe‑run
ps_runto confirm session persistence
Working directory model
The MCP server maintains a single-process working directory stored in memory.
cwdreports the current directory, andcdupdates it (accepting absolute or relative paths).Subsequent
ps_runcommands execute within that directory, soGet-ChildItem -Path .andGet-Contenton relative paths resolve as expected.FastMCP routes requests sequentially, so there is no concurrent mutation of this state; the model matches LM Studio's expectation of a single PowerShell session.
Logs
Full request/response JSON lines are appended to
LMSPS_LOGDIR/lmsps_server.log.
Repo layout
src/lmsps/server.py— MCP server implementationscripts/start_ps_mcp_stdio.sh— stdio launcher (used by LM Studio)logs/— default log directory (overridable viaLMSPS_LOGDIR)
License
MIT
This server cannot be installed
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
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/BerejikB/LmsPs'
If you have feedback or need assistance with the MCP directory API, please join our Discord server