Skip to main content

MCP server wrapping PSScriptAnalyzer for PowerShell static analysis

Project description

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

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

psscriptanalyzer_mcp-0.1.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psscriptanalyzer_mcp-0.1.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file psscriptanalyzer_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: psscriptanalyzer_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for psscriptanalyzer_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c3ac0e40bcbf706bf8f79d8b5d2f9098f3aba9d31474bc70742950cb532cb9a0
MD5 3cc53f5ef645048ff04a21849095f954
BLAKE2b-256 e0478cab1e6ba150bad51832f8a2b408182db7dffe1b1dcc6120c4fa8af43033

See more details on using hashes here.

File details

Details for the file psscriptanalyzer_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for psscriptanalyzer_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0342840ada7612d181497010426a760f44afab410deacaf56574c7409374bd7e
MD5 2ea1cb6edfa87ce8539be632bc49ae2a
BLAKE2b-256 ddddc90102cf68d14816c02693219eea1d12c68a319612015200101b97296a75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page