en-US/PowerCode.PsMcp.dll-Help.xml
|
<?xml version="1.0" encoding="utf-8"?> <helpItems xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" schema="maml" xmlns="http://msh"> <command:command> <command:details> <command:name>New-McpToolConfig</command:name> <maml:description> <maml:para>Creates a per-command MCP tool configuration object for use with `Start-McpServer -CommandConfiguration`.</maml:para> </maml:description> <command:verb>New</command:verb> <command:noun>McpToolConfig</command:noun> </command:details> <maml:description> <maml:para>`New-McpToolConfig` creates an `McpToolConfig` object that controls how a PowerShell command is exposed as an MCP tool.</maml:para> <maml:para>Use it to configure one or more of the following for a specific command:</maml:para> <maml:para>- A friendly tool name (`-Name`) - Included output properties (`-Property`) - Excluded output properties (`-ExcludeProperty`) - Per-command JSON depth (`-Depth`) - Parameter-set filter for the input schema (`-ParameterSets`)</maml:para> <maml:para>The object returned by this cmdlet is intended to be placed in the hashtable passed to `Start-McpServer -CommandConfiguration`, where the hashtable key is the PowerShell command name.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>New-McpToolConfig</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Depth</maml:name> <maml:description> <maml:para>JSON serialization depth override (1-10)</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Int32</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ExcludeProperty</maml:name> <maml:description> <maml:para>Properties to exclude from tool output</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Friendly MCP tool name</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ParameterSets</maml:name> <maml:description> <maml:para>One or more parameter-set names to filter the MCP input schema to. When specified, only parameters that belong to at least one of the named sets are included in the schema. A parameter that is mandatory in every named set is marked as required in the schema. An error is raised at tool-creation time if any supplied name does not match a parameter set declared by the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Property</maml:name> <maml:description> <maml:para>Properties to include in tool output</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Depth</maml:name> <maml:description> <maml:para>JSON serialization depth override (1-10)</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Int32</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ExcludeProperty</maml:name> <maml:description> <maml:para>Properties to exclude from tool output</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Name</maml:name> <maml:description> <maml:para>Friendly MCP tool name</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ParameterSets</maml:name> <maml:description> <maml:para>One or more parameter-set names to filter the MCP input schema to. When specified, only parameters that belong to at least one of the named sets are included in the schema. A parameter that is mandatory in every named set is marked as required in the schema. An error is raised at tool-creation time if any supplied name does not match a parameter set declared by the command.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Property</maml:name> <maml:description> <maml:para>Properties to include in tool output</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes /> <command:returnValues> <command:returnValue> <dev:type> <dev:name>PowerCode.PsMcp.McpToolConfig</dev:name> </dev:type> <maml:description> <maml:para>Returns an `McpToolConfig` instance.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>If `-Depth` is not specified, the returned object has `Depth = $null`, so `Start-McpServer` uses its global `-Depth` value for that command.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 - Rename a command for MCP clients ---------</maml:title> <maml:introduction> <maml:para>```powershell $cfg = New-McpToolConfig -Name 'list-items' ```</maml:para> <maml:para>€</maml:para> <maml:para>Creates an `McpToolConfig` object that renames the exposed MCP tool to `list-items`.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2 - Include specific output properties ---------</maml:title> <maml:introduction> <maml:para>```powershell $cfg = New-McpToolConfig -Property Name, FullName ```</maml:para> <maml:para>€</maml:para> <maml:para>Restricts tool output to `Name` and `FullName`.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3 - Build command configuration for Start-McpServer ---------</maml:title> <maml:introduction> <maml:para>```powershell $commandConfiguration = @{ 'Get-Item' = New-McpToolConfig -Name 'list-items' -Property Name, FullName -Depth 3 'Get-Date' = New-McpToolConfig -Name 'now' }</maml:para> <maml:para>€</maml:para> <maml:para>Start-McpServer -Module MyModule -CommandConfiguration $commandConfiguration ```</maml:para> <maml:para>€</maml:para> <maml:para>Maps PowerShell command names to per-command MCP tool configuration.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4 - Restrict input schema to a single parameter set ---------</maml:title> <maml:introduction> <maml:para>```powershell $cfg = New-McpToolConfig -Name 'get-proc-by-name' -ParameterSets 'NameParameterSet' ```</maml:para> <maml:para>€</maml:para> <maml:para>Filters the exposed input schema to only the parameters in `NameParameterSet`. Parameters that belong exclusively to other parameter sets are omitted from the schema. An error is raised at tool-creation time if the name does not match any parameter set declared by the command.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Start-McpServer</maml:linkText> <command:uri>Start-McpServer.md</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> <command:command> <command:details> <command:name>Start-McpServer</command:name> <maml:description> <maml:para>Exposes PowerShell commands as MCP tools over JSON-RPC/stdio using automatic command discovery.</maml:para> </maml:description> <command:verb>Start</command:verb> <command:noun>McpServer</command:noun> </command:details> <maml:description> <maml:para>`Start-McpServer` starts a Model Context Protocol (MCP) server that exposes PowerShell commands as tools consumable by MCP clients (e.g. AI agents). The cmdlet blocks until the client disconnects or the user presses Ctrl+C.</maml:para> <maml:para>Tools are discovered automatically by diffing the commands available before and after loading your module or script. Only commands **introduced** by the load are exported — built-in commands are excluded by default.</maml:para> <maml:para>At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> <maml:para>**Include/Exclude filtering**</maml:para> <maml:para>`-Include` and `-Exclude` accept PowerShell wildcard patterns (e.g. `Get-*`). Include patterns can only pull in commands from the discovery delta **or** from a module explicitly named in `-Module`. A baseline command such as `Get-Date` can therefore only be included when its owning module (`Microsoft.PowerShell.Utility`) is also passed via `-Module`.</maml:para> <maml:para>**CommandConfiguration**</maml:para> <maml:para>`-CommandConfiguration` is a hashtable whose keys are PowerShell command names and whose values are `McpToolConfig` objects created by `New-McpToolConfig`. This allows per-command control over friendly tool names, selected output properties, excluded properties, and JSON serialization depth.</maml:para> </maml:description> <command:syntax> <command:syntaxItem> <maml:name>Start-McpServer</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CommandConfiguration</maml:name> <maml:description> <maml:para>A hashtable that maps PowerShell command names (keys) to `McpToolConfig` values created by `New-McpToolConfig`. Commands not present in the table keep their original tool name and use the global `-Depth` value.</maml:para> <maml:para>Example: `@{ 'Get-Item' = (New-McpToolConfig -Name 'list-items' -Property Name, FullName); 'Get-Date' = (New-McpToolConfig -Name 'now') }`</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Collections.Hashtable</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Depth</maml:name> <maml:description> <maml:para>Maximum serialisation depth passed to `ConvertTo-Json` when building structured output for each tool result. Higher values capture more nested object detail at the cost of larger payloads. Defaults to `2`. Valid range: 1–10.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Int32</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="Named" aliases="none"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>One or more PowerShell wildcard patterns. Commands whose names match any pattern are removed from the discovered command set. Exclusions are applied after `-Include`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="Named" aliases="none"> <maml:name>Include</maml:name> <maml:description> <maml:para>One or more PowerShell wildcard patterns. Commands from the discovery delta or from a module explicitly listed in `-Module` whose names match any pattern are added to the tool set. A baseline command (e.g. `Get-Date`) can only be included when its owning module (e.g. `Microsoft.PowerShell.Utility`) is also passed in `-Module`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Module</maml:name> <maml:description> <maml:para>One or more module names or paths to import into the discovery runspace before command discovery runs. All commands introduced by these modules are eligible for export. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>A script block that is invoked in the discovery runspace before command discovery runs. Functions and variables defined in the block are available to the MCP tools. Mutually exclusive with `-ScriptPath`; if both are supplied, `-ScriptBlock` is ignored. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ScriptPath</maml:name> <maml:description> <maml:para>Path to a `.ps1` file that is dot-sourced into the discovery runspace before command discovery runs. Use this to load helper functions that are not yet packaged as a module. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>CommandConfiguration</maml:name> <maml:description> <maml:para>A hashtable that maps PowerShell command names (keys) to `McpToolConfig` values created by `New-McpToolConfig`. Commands not present in the table keep their original tool name and use the global `-Depth` value.</maml:para> <maml:para>Example: `@{ 'Get-Item' = (New-McpToolConfig -Name 'list-items' -Property Name, FullName); 'Get-Date' = (New-McpToolConfig -Name 'now') }`</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Collections.Hashtable</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>Depth</maml:name> <maml:description> <maml:para>Maximum serialisation depth passed to `ConvertTo-Json` when building structured output for each tool result. Higher values capture more nested object detail at the cost of larger payloads. Defaults to `2`. Valid range: 1–10.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Int32</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="Named" aliases="none"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>One or more PowerShell wildcard patterns. Commands whose names match any pattern are removed from the discovered command set. Exclusions are applied after `-Include`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="true" pipelineInput="false" position="Named" aliases="none"> <maml:name>Include</maml:name> <maml:description> <maml:para>One or more PowerShell wildcard patterns. Commands from the discovery delta or from a module explicitly listed in `-Module` whose names match any pattern are added to the tool set. A baseline command (e.g. `Get-Date`) can only be included when its owning module (e.g. `Microsoft.PowerShell.Utility`) is also passed in `-Module`.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0" aliases="none"> <maml:name>Module</maml:name> <maml:description> <maml:para>One or more module names or paths to import into the discovery runspace before command discovery runs. All commands introduced by these modules are eligible for export. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ScriptBlock</maml:name> <maml:description> <maml:para>A script block that is invoked in the discovery runspace before command discovery runs. Functions and variables defined in the block are available to the MCP tools. Mutually exclusive with `-ScriptPath`; if both are supplied, `-ScriptBlock` is ignored. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.Management.Automation.ScriptBlock</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="Named" aliases="none"> <maml:name>ScriptPath</maml:name> <maml:description> <maml:para>Path to a `.ps1` file that is dot-sourced into the discovery runspace before command discovery runs. Use this to load helper functions that are not yet packaged as a module. At least one of `-Module`, `-ScriptBlock`, or `-ScriptPath` must be provided.</maml:para> </maml:description> <command:parameterValue required="false" variableLength="true">System.String</command:parameterValue> </command:parameter> </command:parameters> <command:inputTypes> <command:inputType> <dev:type> <dev:name>None</dev:name> </dev:type> <maml:description> <maml:para>This cmdlet does not accept pipeline input.</maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <dev:name>None</dev:name> </dev:type> <maml:description> <maml:para>This cmdlet does not produce output. It blocks until the MCP client disconnects or the cancellation token fires.</maml:para> </maml:description> </command:returnValue> </command:returnValues> <maml:alertSet> <maml:alert> <maml:para>The cmdlet communicates over the process's raw stdin/stdout handles so that the JSON-RPC messages bypass PowerShell's occupied pipeline. Do not write to stdout while the server is running; use `-Verbose` or redirect output to a file instead. The discovery runspace is isolated: it does not share state with the calling session.</maml:para> </maml:alert> </maml:alertSet> <command:examples> <command:example> <maml:title>--------- Example 1 — Expose all commands from a module ---------</maml:title> <maml:introduction> <maml:para>```powershell Start-McpServer -Module MyToolsModule ```</maml:para> <maml:para>€</maml:para> <maml:para>Imports `MyToolsModule` and exposes every command it introduces as an MCP tool.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 2 — Load a script file and expose its functions ---------</maml:title> <maml:introduction> <maml:para>```powershell Start-McpServer -ScriptPath ./tools.ps1 ```</maml:para> <maml:para>€</maml:para> <maml:para>Dot-sources `tools.ps1` into a fresh runspace and exposes the functions it defines.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 3 — Define tools inline with a ScriptBlock ---------</maml:title> <maml:introduction> <maml:para>```powershell Start-McpServer -ScriptBlock { function Get-CurrentWeather { <# .SYNOPSIS Gets the current weather for a location.</maml:para> <maml:para>€</maml:para> <maml:para>.DESCRIPTION Calls a weather service to retrieve current conditions for the specified city or region.</maml:para> <maml:para>€</maml:para> <maml:para>.PARAMETER Location The city or region to get weather for.</maml:para> <maml:para>€</maml:para> <maml:para>.PARAMETER Units Temperature units: Celsius or Fahrenheit.</maml:para> <maml:para>€</maml:para> <maml:para>.EXAMPLE Get-CurrentWeather -Location "Seattle" -Units Celsius #> [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Location,</maml:para> <maml:para>€</maml:para> <maml:para>[ValidateSet('Celsius', 'Fahrenheit')] [string]$Units = 'Celsius' ) @{ Location = $Location; Temperature = 72; Units = $Units } } } ```</maml:para> <maml:para>€</maml:para> <maml:para>Defines `Get-CurrentWeather` inline and exposes it as the only MCP tool. `Start-McpServer` uses `Get-Help` to extract the function's synopsis, description, and per-parameter descriptions from the comment-based help block — these become the MCP tool's `description` and input schema `description` fields visible to AI clients.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 4 — Include a baseline command by importing its module ---------</maml:title> <maml:introduction> <maml:para>```powershell Start-McpServer -Module Microsoft.PowerShell.Utility -Include 'Get-Date' ```</maml:para> <maml:para>€</maml:para> <maml:para>Imports `Microsoft.PowerShell.Utility` and uses `-Include` to explicitly pull in `Get-Date` (which would otherwise be excluded as a baseline command).</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 5 — Configure tools with CommandConfiguration and filter with wildcards ---------</maml:title> <maml:introduction> <maml:para>```powershell $toolConfig = @{ 'Get-Item' = New-McpToolConfig -Name 'list-items' -Property Name, FullName }</maml:para> <maml:para>€</maml:para> <maml:para>Start-McpServer -Module MyModule -Include 'Get-*' -Exclude 'Get-Secret' ` -CommandConfiguration $toolConfig ```</maml:para> <maml:para>€</maml:para> <maml:para>Imports `MyModule`, includes all `Get-*` commands (excluding `Get-Secret`), and renames `Get-Item` to `list-items` in the MCP protocol while restricting its output to the selected properties.</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> <command:example> <maml:title>--------- Example 6 — Increase JSON depth for deeply nested output ---------</maml:title> <maml:introduction> <maml:para>```powershell Start-McpServer -ScriptPath ./tools.ps1 -Depth 5 ```</maml:para> </maml:introduction> <dev:code /> <dev:remarks /> </command:example> </command:examples> <command:relatedLinks> <maml:navigationLink> <maml:linkText>Online Version</maml:linkText> <command:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Model Context Protocol specification</maml:linkText> <command:uri>https://spec.modelcontextprotocol.io</command:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>PowerCode.PsMcp on GitHub</maml:linkText> <command:uri>https://github.com/powercode/PowerCode.PsMcp</command:uri> </maml:navigationLink> </command:relatedLinks> </command:command> </helpItems> |