Add-PodeMcpTool
SYNOPSIS
Adds a new MCP tool to the server.
SYNTAX
Add-PodeMcpTool [-Name] <String> [-Description] <String> [-ScriptBlock] <ScriptBlock> [-Group] <String[]>
[-AutoSchema] [-PassThru] [-ProgressAction <ActionPreference>] [<CommonParameters>]
DESCRIPTION
Adds a new MCP tool to the server, optionally inside a custom Group.
EXAMPLES
EXAMPLE 1
# add a simple MCP tool to a default group
Add-PodeMcpGroup -Name 'default'
Add-PodeMcpTool -Name 'Greet' -Description 'Returns a random greeting' -Group 'default' -ScriptBlock {
$greetings = @('Hello', 'Hi', 'Hey', 'Greetings', 'Salutations')
$greeting = Get-Random -InputObject $greetings
return New-PodeMcpTextContent -Value "$($greeting) from the Pode MCP tool!"
}
EXAMPLE 2
# add a simple MCP tool to a custom group with auto-generated schema
Add-PodeMcpGroup -Name 'custom'
Add-PodeMcpTool -Name 'GreetPerson' -Description 'Returns a random greeting to a person' -Group 'custom' -AutoSchema -ScriptBlock {
param(
[Parameter(Mandatory = $true, HelpMessage = 'The name of the person to greet')]
[string]$Name
)
$greetings = @('Hello', 'Hi', 'Hey', 'Greetings', 'Salutations')
$greeting = Get-Random -InputObject $greetings
return New-PodeMcpTextContent -Value "$($greeting), $($Name)! from the Pode MCP tool!"
}
EXAMPLE 3
# add a simple MCP tool to a custom group, and return the tool for chaining
Add-PodeMcpGroup -Name 'custom'
Add-PodeMcpTool -Name 'GreetPersonInLocation' -Description 'Returns a random greeting to a person' -Group 'custom' -ScriptBlock {
param(
[string]$Name
)
$greetings = @('Hello', 'Hi', 'Hey', 'Greetings', 'Salutations')
$greeting = Get-Random -InputObject $greetings
return New-PodeMcpTextContent -Value "$($greeting), $($Name)! via the Pode MCP tool!"
} -PassThru |
Add-PodeMcpToolProperty -Name 'Name' -Required -Definition (
New-PodeJsonSchemaString -Description 'The name of the person to greet'
)
PARAMETERS
-AutoSchema
If set, the input schema for the tool will attempt to be automatically generated based on the parameters of the provided ScriptBlock - using parameter attributes for additional context.
This only supports basic parameter types: string, int, long, double, float, and bool (including arrays of these types).
If supplied you don't need to manually define properties via Add-PodeMcpToolProperty, but you can still do so if you want to and override the auto-generated schema for specific properties.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-Description
A brief description of the MCP tool, this is required to help MCP clients understand what the tool does.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Group
The Group(s) to which the MCP tool belongs.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: 4
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Name
The name of the MCP tool.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-PassThru
If set, the function will return the tool after it 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
-ScriptBlock
The ScriptBlock that defines the MCP tool's functionality.
Type: ScriptBlock
Parameter Sets: (All)
Aliases:
Required: True
Position: 3
Default value: None
Accept pipeline input: False
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.