Skip to content

In v0.12 Register-MCPTool uses the cmdlet name as description for the tools/list endpoint #7

@ddemeyer

Description

@ddemeyer

In v0.12 Register-MCPTool uses the cmdlet name as description for the tools/list endpoint

Cmdlet Register-MCPTool uses

$results[$CommandInfo.Name] = [ordered]@{ # Keep using CommandInfo.Name as key for internal logic
            name        = $CommandInfo.Name # Use original name for output
            description = $CommandInfo.Name # Use original name for output description
            inputSchema = $inputSchema
            returns     = $returns

which I would suggest to replace with

$results[$CommandInfo.Name] = [ordered]@{ # Keep using CommandInfo.Name as key for internal logic
            name        = $CommandInfo.Name # Use original name for output
            description = $description
            inputSchema = $inputSchema
            returns     = $returns

Note that $description is initialized higher-up in the function with synopsis (where I would prefer description).

Next I would actually provide more context like examples to every MCP Tool as described on https://modelcontextprotocol.info/docs/concepts/tools/, so I experimented also with replacing

Write-Log -LogEntry @{ Level = 'Verbose'; Message = "Getting help for function '$($CommandInfo.Name)'"; TargetFunction = $CommandInfo.Name }
$help = Get-Help $CommandInfo.Name
$description = $help.Synopsis | Out-String
if (-not $description) {
    $description = $help.Description.Text | Out-String
}
$description = $description.Trim()
if (-not $description) {
    Write-Log -LogEntry @{ Level = 'Error'; Message = "Function '$($CommandInfo.Name)' does not have a description (Synopsis or Description in comment-based help)."; TargetFunction = $CommandInfo.Name }
    Write-Error "Function '$($CommandInfo.Name)' does not have a description (Synopsis or Description in comment-based help). Aborting." -ErrorAction Stop
    continue
}

with

Write-Log -LogEntry @{ Level = 'Verbose'; Message = "Getting EXTENDED help for function '$($CommandInfo.Name)'"; TargetFunction = $CommandInfo.Name }
$help = Get-Help $CommandInfo.Name -Detailed
# Prefer Description over Synopsis
$description = $help.Description.Text | Out-String
if (-not $description) {
    $description = $help.Synopsis | Out-String
}
$description = $description.Trim()
if (-not $description) {
    Write-Log -LogEntry @{ Level = 'Error'; Message = "Function '$($CommandInfo.Name)' does not have a description (Synopsis or Description in comment-based help)."; TargetFunction = $CommandInfo.Name }
    Write-Error "Function '$($CommandInfo.Name)' does not have a description (Synopsis or Description in comment-based help). Aborting." -ErrorAction Stop
    continue
}
# Adding all syntax of parameter sets
$description = $description + "`n`nThis PowerShell cmdlet has the following parameter sets to choose form:`n" + ($help.syntax | Out-String).Trim()
# Adding all parameters
$description = $description + "`n`nThe PowerShell cmdlet uses the following parameters in the parameter sets:`n" + ($help.parameters | Out-String).Trim()
# Adding all examples
$description = $description + "`n`nThe PowerShell cmdlet has the following examples as inspiration:`n" + ($help.examples | Out-String).Trim()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions