AI-powered agentic PowerShell tool - Groq LLM + GitHub MCP + session history
Project description
powershell-agent
A natural language interface for PowerShell, powered by Groq. You describe what you want done, and the agent figures out which commands to run, executes them step by step, and gives you a summary of what happened.
Requirements
- Python 3.10+
- Windows (PowerShell)
- Groq API key (free tier works)
Setup
poetry install
$env:GROQ_API_KEY = "gsk_..."
Optional overrides:
| Variable | Default | Description |
|---|---|---|
MODEL_PS |
llama-3.3-70b-versatile |
Groq model to use |
GITHUB_MCP_URL |
— | Your MCP server URL for --github queries |
GITHUB_TOKEN |
— | GitHub PAT for --github queries |
PS_MAX_ITERATIONS |
10 |
Max agent loop iterations |
PS_TIMEOUT |
300 |
Command timeout in seconds |
PS_HISTORY_DIR |
~/.powershell-agent/history |
Where sessions are saved |
Usage
# Direct prompt
poetry run powershell-agent "find all TODO comments in python files"
# Review each command before it runs
poetry run powershell-agent --review "create a feature branch for dark mode"
# Interactive
poetry run powershell-agent
CLI Flags
| Flag | Description |
|---|---|
--review |
Approve / skip / edit / quit each command before it runs |
--model <name> |
Override the model for this session |
--iterations <n> |
Max number of agent iterations |
--history |
List past sessions |
--clear-history |
Delete all saved sessions |
--replay <id> |
Print the commands from a past session |
--github "<query>" |
Query GitHub via MCP (see below) |
--version |
Print version |
GitHub MCP
The agent can query GitHub repositories using the Model Context Protocol via Groq's Responses API.
GITHUB_MCP_URL=https://your-mcp-server.com/mcp # any MCP server URL you want
GITHUB_TOKEN=ghp_... # your GitHub PAT (optional, for private repos)
Supported models for --github (Groq Responses API restriction):
llama-3.3-70b-versatile, llama-3.1-8b-instant, qwen/qwen3-32b, openai/gpt-oss-120b, openai/gpt-oss-20b
Models like mixtral and gemma are not supported and will return an error. The default model works fine.
$env:GITHUB_TOKEN = "ghp_..."
poetry run powershell-agent --github "summarise the open issues in abderrahmanyouabd/powershell-agent"
poetry run powershell-agent --github "what changed in the last 5 commits of abderrahmanyouabd/powershell-agent"
Session History
Every run is saved to disk automatically.
# List sessions
poetry run powershell-agent --history
# Replay one
poetry run powershell-agent --replay abc123def456
Developer Usage
import asyncio
from powershell_agent import PowerShellAgent, list_sessions
async def main():
agent = PowerShellAgent()
response = await agent.run("find all python files and count them")
print(response)
# Past sessions
for s in list_sessions(limit=5):
print(s["id"], s["prompt_preview"])
asyncio.run(main())
Adding a custom tool
from powershell_agent.tools import build_default_registry
registry = build_default_registry()
schema = {
"type": "function",
"function": {
"name": "my_tool",
"description": "Does something useful.",
"parameters": {
"type": "object",
"properties": {"input": {"type": "string"}},
"required": ["input"],
},
},
}
async def my_handler(input: str, **_):
return {"status": "success", "output": f"got: {input}", "error": None, "return_code": 0}
registry.register(schema, my_handler)
agent = PowerShellAgent(registry=registry)
Running Tests
poetry run pytest tests/ -v
Architecture
powershell_agent/
config.py # all constants + env-var overrides
executor.py # PowerShell subprocess engine
tools.py # ToolRegistry + built-in tools (run_powershell, write_file)
prompt.py # system prompt builder
memory.py # session persistence
agent.py # agentic loop
mcp.py # GitHub MCP via Groq Responses API
cli.py # CLI entry point
tests/ # pytest suite
Security
This tool executes PowerShell commands on your machine. Use --review mode when you want to approve each command before it runs, especially for unfamiliar prompts.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powershell_agent-0.3.1.tar.gz.
File metadata
- Download URL: powershell_agent-0.3.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f48ed4851ec65c721a25eef526c2ecd9022a9b7f73d00336bd15a9a2a742f02e
|
|
| MD5 |
2f9774858f6e0fd59d6434a04ffa21e2
|
|
| BLAKE2b-256 |
a4ab5b2eb4feb3d24bf852dff7a87206f780da495a41e626e6e118c3b9a17f94
|
File details
Details for the file powershell_agent-0.3.1-py3-none-any.whl.
File metadata
- Download URL: powershell_agent-0.3.1-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.10.0 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d00f72b8b1125c159776aeb645b813455e3ae2bda96525f978470741e1c94160
|
|
| MD5 |
4935ab54bbf50d68197200dbfb296c3e
|
|
| BLAKE2b-256 |
d9206ac1da2e51784f3bac9127fdfa4e60ae6d16f9879f2bc69564388bf261b2
|