home / mcp / lmsps — lm studio powershell mcp server
LmstudioPowershell Mcp
Configuration
View docs{
"mcpServers": {
"berejikb-lmsps": {
"command": "bash",
"args": [
"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",
"LMSPS_TIMEOUT_SEC": "30",
"LMSPS_POWERSHELL_PATH": "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe",
"LMSPS_MAX_COMMAND_CHARS": "8192"
}
}
}
}You set up and use a minimal, stateful MCP server that exposes a persistent PowerShell session to LM Studio. It lets you run PowerShell commands, navigate and manage the current working directory, and read or set environment variables, all through a simple, stateful interface with controlled, trimmed responses.
You connect to the MCP server using a client that supports MCP endpoints. You start a local MCP server process and interact with it as if you have a single, long‑lived PowerShell session. Use the provided tools to run commands, adjust the working directory, and manage environment variables. The session persists between requests, so you can set up your environment once and run a sequence of commands without restarting the PowerShell process.
Prerequisites: you need Python and a shell available on your system to run the MCP server. The setup uses a virtual environment to isolate dependencies.
# 1) Prepare a development directory
# 2) Create and activate a Python virtual environment
cd K:/Repos/LmsPs
python -m venv .venv
. .venv/Scripts/activate # Windows
pip install -e .You have two options to start the MCP server, depending on your environment. Use the stdio launcher for LM Studio integration or run the server directly with Python.
# Option 1: Use the stdio launcher (recommended for LM Studio via WSL)
bash K:/Repos/LmsPs/scripts/start_ps_mcp_stdio.sh
# Option 2: Run the Python module directly (Windows)
python -m lmsps.serverThe server will start in the current working directory and maintain a single PowerShell session per process. If you launch via the stdio launcher, LM Studio can issue ps_run, cd, cwd, env_get, env_set, and ping operations against that session.
You can customize behavior with environment variables. The following are supported by the server and are shown in the configuration examples.
LMSPS_POWERSHELL_PATH — Preferred path to Windows PowerShell 5.1 (default C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe)
LMSPS_PWSH — Legacy override for the PowerShell executable
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— Max PowerShell command length accepted by ps_run (default: 8192)The MCP exposes a small set of tools that operate on the persistent PowerShell session. You can run commands, manage the current directory, and inspect or modify environment variables.
Execute a PowerShell command in the persistent session with optional timeout and trim settings. Returns a structured payload including status, exit code, stdout, and stderr.
Change the current working directory of the persistent PowerShell session. Supports absolute and relative paths.
Query the current working directory of the persistent PowerShell session.
Read an environment variable from the session's environment overlay.
Set or update an environment variable in the session's environment overlay.
Check the liveness of the persistent PowerShell session.