Skip to content
cd /languages
  • Windows automation
  • Shell
  • AST and symbol support

PowerShell Support in Maguyva: Code Graphs for Scripts and Modules

Maguyva parses PowerShell with AST, symbol, and graph support, so AI agents can follow functions, classes, and cmdlet calls across scripts and modules.

Where PowerShell trips up shallow AI tools

Your functions and the built-in cmdlets share one naming style. Get-Invoice and Get-ChildItem look the same, so a tool that drops “built-ins” by verb throws away your own functions too. Scripts also mix module-level code, functions, classes, and script blocks in one file, which makes it hard to tell which function a line belongs to.

Maguyva keeps both kinds of call and attributes each one to the function it sits in.

What Maguyva extracts in PowerShell

Maguyva covers .ps1, .psm1, and .psd1 files. Functions and class methods are extracted as callables, and classes and enums as types. Script and method parameters are tracked, and reads and writes inside a function are attributed to that function rather than to the module.

Cmdlet calls stay in the graph. PowerShell does not apply the standard-library filter that most languages use, so Write-Host, Get-ChildItem, and Restart-Service appear as call edges next to your own Get-* and Set-* functions. An agent can ask which scripts restart a service, or which functions write to the console, and get a structural answer.

No relationship type is marked not applicable for PowerShell, so the graph also records class inheritance and interface implementation, instantiation, control flow, and reads and writes.

Example agent prompts

  • “Who calls Invoke-Backup, and from which scheduled scripts?” (find_symbol, then dependency_search incoming)
  • “Which functions call Restart-Service?” (dependency_search)
  • “Trace what Deploy-Site does from start to finish.” (get_task_context)

Known limits

  • Because cmdlet calls are kept, very common ones such as Write-Host and Select-Object have a large number of incoming edges. Start from your own function when you want a focused call graph.
  • Import-Module and dot-sourcing are ordinary commands, so the imports preset in structural_search selects nothing. Use text_pattern_search to list them.

Next steps

Connect a repository with the quickstart, then check the support matrix on the compatibility page. For .NET code that your scripts call, read the C# guide.

Best fit

  • > Infrastructure and operations teams with large `.ps1` and `.psm1` estates whose scripts call each other's functions.
  • > PowerShell modules built from advanced functions, classes, and enums.
  • > Automation runbooks where agents need to see which scripts touch a service, a file share, or a registry key before a change.

Agent workflows

  • > Find every caller of an advanced function before changing its parameters.
  • > List which scripts call a cmdlet such as `Restart-Service` before changing a runbook.
  • > Map which functions write to a shared variable before refactoring a module.

Engine details

  • > PowerShell support covers `.ps1`, `.psm1`, and `.psd1`. Functions and class methods are callables, and classes and enums are types.
  • > The standard-library filter is off for PowerShell, so cmdlet calls such as `Get-ChildItem` stay in the graph beside your own functions.
  • > Reads and writes inside a function are attributed to that function rather than to the module.

Useful MCP entry points

  • find_symbol

    Use it for an advanced function or class when you need the definition and callers.

  • dependency_search

    Use incoming traversal on a cmdlet such as `Restart-Service` to see which scripts call it.

  • get_task_context

    Use it for prompts like “trace what `Deploy-Site` does from start to finish.”