Metadata-Version: 2.4
Name: psscriptanalyzer-mcp
Version: 0.1.0
Summary: MCP server wrapping PSScriptAnalyzer for PowerShell static analysis
Author: PSScriptAnalyzer MCP Contributors
License-File: LICENSE.bak
Keywords: mcp,powershell,psscriptanalyzer,static-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.10
Requires-Dist: fastmcp>=2.0.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# PSScriptAnalyzer MCP Server

[![PyPI version](https://img.shields.io/pypi/v/psscriptanalyzer-mcp.svg)](https://pypi.org/project/psscriptanalyzer-mcp/)
[![Python](https://img.shields.io/pypi/pyversions/psscriptanalyzer-mcp.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**MCP server wrapping [PSScriptAnalyzer](https://github.com/PowerShell/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

```powershell
Install-Module PSScriptAnalyzer -Scope CurrentUser
```

## Installation

```bash
# Using uvx (recommended)
uvx psscriptanalyzer-mcp

# Using pip
pip install psscriptanalyzer-mcp
```

## Usage

### With Claude Desktop

```bash
fastmcp install psscriptanalyzer-mcp
```

### With MCP Inspector

```bash
fastmcp dev psscriptanalyzer_mcp.server:mcp
```

### Programmatic

```python
from psscriptanalyzer_mcp.server import mcp

# Run the server
mcp.run()
```

## MCP Tools

### `pssa_analyze`

Analyze PowerShell scripts for issues.

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

**Supports:**
- File paths
- Directory paths (with recursion)
- Inline code

### `pssa_list_rules`

List available analysis rules.

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

### `pssa_analyze_and_fix`

Analyze and auto-fix issues.

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

### `pssa_get_rule_info`

Get detailed rule documentation.

```json
{
  "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

```bash
# 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](LICENSE) for details.

## Related

- [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer) - Microsoft's PowerShell static analysis tool
- [FastMCP](https://github.com/PrefectHQ/fastmcp) - Python framework for MCP servers
- [MCP Specification](https://modelcontextprotocol.io/) - Model Context Protocol
