Skip to main content

PSScriptAnalyzer MCP Server

PyPI version Python License: MIT

MCP server wrapping PSScriptAnalyzer - Microsoft's PowerShell static analysis tool. Enables AI agents to analyze, lint, and auto-fix PowerShell code.

Features

  • 🔍 Static Analysis: Detect security, performance, and style issues
  • 🛠️ Auto-Fix: Automatically correct supported violations
  • 📚 80+ Rules: Built-in rules for best practices
  • 🤖 AI-Friendly: Designed for LLM/MCP integration
  • 🌍 Cross-Platform: Windows, Linux, macOS (PowerShell 7+)

Requirements

  • Python 3.10+
  • PowerShell 5.1 (Windows) or PowerShell 7+ (cross-platform)
  • PSScriptAnalyzer module

Installing PSScriptAnalyzer

Install-Module PSScriptAnalyzer -Scope CurrentUser

Installation

# Using uvx (recommended)
uvx psscriptanalyzer-mcp

# Using pip
pip install psscriptanalyzer-mcp

Usage

With Claude Desktop

fastmcp install psscriptanalyzer-mcp

With MCP Inspector

fastmcp dev psscriptanalyzer_mcp.server:mcp

Programmatic

from psscriptanalyzer_mcp.server import mcp

# Run the server
mcp.run()

MCP Tools

pssa_analyze

Analyze PowerShell scripts for issues.

{
  "path": "C:/Scripts/script.ps1",
  "severity": ["Error", "Warning"]
}

Supports:

  • File paths
  • Directory paths (with recursion)
  • Inline code

pssa_list_rules

List available analysis rules.

{
  "severity": ["Error"],
  "name": "*Security*"
}

pssa_analyze_and_fix

Analyze and auto-fix issues.

{
  "path": "script.ps1",
  "dry_run": true,
  "backup": true
}

pssa_get_rule_info

Get detailed rule documentation.

{
  "rule_name": "PSAvoidUsingPlainTextForPassword"
}

Example Workflow

User: "Check this PowerShell script for issues"

AI: [calls pssa_analyze]
    Found 3 issues:
    - Line 10: Password in plain text (Error)
    - Line 25: Using alias 'dir' (Warning)
    - Line 40: Missing help comment (Information)
    
    Want me to fix the auto-fixable issues?

User: "Yes, fix them"

AI: [calls pssa_analyze_and_fix with dry_run=false]
    Fixed 1 issue:
    - Replaced 'dir' with 'Get-ChildItem'
    
    2 issues require manual review.

Rule Categories

Category Examples
Security Plain text passwords, injection risks
Performance Inefficient patterns, positional parameters
Best Practices Approved verbs, ShouldProcess
Style Aliases, formatting, casing

Development

# Clone
git clone https://github.com/yourorg/psscriptanalyzer-mcp.git
cd psscriptanalyzer-mcp

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run linter
ruff check src/

# Type check
mypy src/

License

MIT License - see LICENSE for details.

Related

Metadata

Release files for psscriptanalyzer-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for psscriptanalyzer-mcp 0.1.0
File Size Uploaded
psscriptanalyzer_mcp-0.1.0.tar.gz 27.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for psscriptanalyzer-mcp 0.1.0
File Interpreter ABI Platform
psscriptanalyzer_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 48.3 kB

Release files / psscriptanalyzer_mcp-0.1.0.tar.gz

Download URL psscriptanalyzer_mcp-0.1.0.tar.gz
Size 27.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c3ac0e40bcbf706bf8f79d8b5d2f9098f3aba9d31474bc70742950cb532cb9a0
BLAKE2b-256 checksum
How to use checksums
e0478cab1e6ba150bad51832f8a2b408182db7dffe1b1dcc6120c4fa8af43033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / psscriptanalyzer_mcp-0.1.0-py3-none-any.whl

Download URL psscriptanalyzer_mcp-0.1.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0342840ada7612d181497010426a760f44afab410deacaf56574c7409374bd7e
BLAKE2b-256 checksum
How to use checksums
ddddc90102cf68d14816c02693219eea1d12c68a319612015200101b97296a75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page