NAME

App::MCP::CLI::Command::call - Invoke a specific tool on an MCP server

VERSION

This module is distributed as part of App::MCP::CLI v0.0.1.

SYNOPSIS

# Invoke a tool with inline key=value arguments
mcpcli call add_numbers --server perl-math-server a=10 b=5

# Invoke a tool and be prompted for each argument
mcpcli call add_numbers --server perl-math-server

# Against a script, a raw command, or an SSE URL
mcpcli call add_numbers --server ./stdio_server.pl a=3 b=4
mcpcli call get_mock_weather --server http://localhost:8080/sse location=London

DESCRIPTION

App::MCP::CLI::Command::call implements the call sub-command of the mcpcli application. It connects to an MCP server over stdio or HTTP/SSE (through App::MCP::CLI::Client), performs the handshake, and dispatches a tools/call request.

Argument handling

Arguments are supplied on the command line as key=value pairs after the tool name. Anything that is not a key=value pair is a usage error.

mcpcli call mytool param1=hello param2=42

The command asks the server for the tool's input schema and uses it to give each value the right JSON type:

  • string properties are always sent as strings, so 007 stays "007" and 1.0 stays "1.0".

  • integer and number properties are sent as numbers when the value looks numeric.

  • boolean properties accept true/false, yes/no and 1/0.

  • array and object properties are parsed as JSON.

  • Properties without a declared type (or tools whose schema is not available) fall back to a conservative rule: plain decimal numbers without leading zeros become JSON numbers, everything else stays a string.

Required properties that were not supplied cause an error before anything is sent to the server.

When no arguments are given at all, the command enters an interactive prompt mode: it presents each property of the tool's schema in the terminal (prompts go to STDERR), labelling required fields in red when STDERR is a terminal. Entering an empty value for a required field aborts with an error.

Output

Only the tool's result is written to STDOUT, so it can be piped. Text blocks are printed as-is. Other block types are not dropped: images and audio become a one-line placeholder with their MIME type and size, resources are printed (or described), and structuredContent is pretty-printed when there is no other content. Progress messages and errors go to STDERR.

Exit status

0 - the tool ran and reported success.
1 - connection or configuration failure, timeout, unknown tool, missing argument, a JSON-RPC error from the server, or a tool result with isError: true (its text is printed to STDERR).

USAGE

mcpcli call <tool_name> [key=value ...] [--server <name|path|url|command>]
            [--config <file>] [--timeout <seconds>]

OPTIONS

--server|-s name

Server name from the config file, a .pl script, a URL, or a command. May be omitted when the config file defines exactly one server.

--config|-c path

Path to the JSON configuration file. See App::MCP::CLI::Config.

--timeout|-t seconds

How long to wait for each server reply (default 30; 0 waits forever).

INTERNAL METHODS

opt_spec

Defines the command-line option specification passed to Getopt::Long::Descriptive via App::Cmd.

description

Returns a one-line human-readable description of the command, used in the top-level mcpcli help listing.

usage_desc

Returns the usage string shown by mcpcli help call.

validate_args

Validates that a tool name was supplied and that every further argument is a key=value pair; calls usage_error otherwise.

execute( $opt, $args )

Main entry point invoked by App::Cmd. Connects to the configured MCP server, performs the protocol handshake, collects tool arguments (inline or interactively), submits the tools/call request, and prints the response.

_coerce_value( $value, $property_schema )

Plain function (not a method). Converts the command-line string $value to the JSON type declared by $property_schema (the property's entry in the tool's inputSchema, may be undef). See "Argument handling" for the rules. Values that do not fit the declared type are passed through unchanged so that the server can report a precise validation error.

SEE ALSO

AUTHOR

Mohammad Sajid Anwar, <mohammad.anwar at yahoo.com>

REPOSITORY

https://github.com/manwar/App-MCP-CLI

BUGS

Please report any bugs or feature requests through the web interface at https://github.com/manwar/App-MCP-CLI/issues. I will be notified and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc App::MCP::CLI

You can also look for information at:

LICENSE AND COPYRIGHT

Copyright (C) 2026 Mohammad Sajid Anwar.

This program is free software; you can redistribute it and / or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License.By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.

If your Modified Version has been derived from a Modified Version made by someone other than you,you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.

This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.

This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement,then this Artistic License to you shall terminate on the date that such litigation is filed.

Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.