Skip to content

Add-PodeMcpToolProperty

SYNOPSIS

Adds a property to an existing MCP tool, which will be included in the tool's input schema.

SYNTAX

Add-PodeMcpToolProperty [-Tool] <Hashtable> -Name <String> -Definition <Hashtable> [-Required] [-PassThru]
 [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Adds a property to an existing MCP tool, which will be included in the tool's input schema. This allows you to define the expected input for the tool, which can be used by MCP clients to understand how to call the tool and provide better user experiences.

EXAMPLES

EXAMPLE 1

# add a property to an MCP tool using the output from Add-PodeMcpTool
Add-PodeMcpTool -Name 'GreetPersonInLocation' -Description 'Returns a random greeting to a person in a location' -ScriptBlock {
    param(
        [string]$Name,
        [string]$Location
    )
    $greetings = @('Hello', 'Hi', 'Hey', 'Greetings', 'Salutations')
    $greeting = Get-Random -InputObject $greetings
    return New-PodeMcpTextContent -Value "$($greeting), $($Name) from $($Location)! via the Pode MCP tool!"
} -PassThru |
    Add-PodeMcpToolProperty -Name 'Name' -Required -Definition (
        New-PodeJsonSchemaString -Description 'The name of the person to greet'
    ) |
    Add-PodeMcpToolProperty -Name 'Location' -Required -Definition (
        New-PodeJsonSchemaString -Description 'The location of the person to greet'
    )

PARAMETERS

-Definition

The Definition of the property, which will be a JSON Schema built using the New-PodeJsonSchema* cmdlets.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Name

The Name of the property.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

If set, the function will return the tool after the property has been added to enable pipeline chaining.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Required

Indicates whether the property is required.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Tool

The Tool to which the property should be added; this will be the output of Add-PodeMcpTool if -PassThru is used.

Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Collections.Hashtable

NOTES

https://modelcontextprotocol.info/docs/concepts/tools/