App-MCP-CLI
view release on metacpan or search on metacpan
script/mcpcli view on Meta::CPAN
=item 3. C<$HOME/.config/mcp-cli/config.json>.
=back
=item B<--server|-s> I<name>
The name of an MCP server as defined in the C<mcpServers> section of the
configuration file. May also be a path to a C<.pl> script, an
C<http://>/C<https://> URL (SSE mode), or a bare shell command string. May be
omitted when the configuration file defines exactly one server.
=item B<--timeout|-t> I<seconds> (default: 30)
How long to wait for each reply from the MCP server (C<list>, C<call>,
C<chat>). C<0> waits forever.
=item B<--provider|-p> I<name> (default: C<ollama>)
The LLM provider to use for the C<interactive>/C<chat> commands. Only
C<ollama> is currently supported.
=item B<--model|-m> I<name> (default: C<qwen2.5:1.5b>)
The model tag to pass to the LLM provider.
=back
=head1 CONFIGURATION FILE
The JSON configuration file has the following structure:
{
"confirmTools": true,
"mcpServers": {
"perl-math-server": {
"command": "perl",
"args": ["stdio_server.pl"],
"env": { "DEBUG": "1" }
},
"remote-server": {
"url": "http://mcp.example.com/sse"
}
}
}
=over 4
=item C<mcpServers> (object)
A map of server alias names to server descriptor objects. Each descriptor
supports:
=over 4
=item C<command> (string) - executable to launch (stdio mode).
=item C<args> (array) - additional arguments for the executable.
=item C<env> (object) - environment variables to set before launching.
=item C<url> (string) - SSE endpoint URL (SSE mode).
=item C<transport> (string) - set to C<"sse"> to force SSE mode.
=back
=item C<confirmTools> (boolean, default: C<true>)
When true, the C<interactive>/C<chat> command pauses before executing any tool
call and asks the user for explicit confirmation. Set to C<false> to allow
autonomous execution.
=back
=head1 TRANSPORT MODES
=head2 stdio
The server is launched as a child process. Messages are exchanged as
newline-delimited JSON on its stdin/stdout. This is the default mode when a
C<command> key is present in the server descriptor.
=head2 HTTP/SSE
When the server descriptor contains a C<url> key, or when C<--server> is
given an C<http://>/C<https://> URL directly, the client connects in SSE mode
(MCP protocol revision 2024-11-05). It opens the event stream with a C<GET>,
reads the C<endpoint> event to learn the C<POST> URL, then sends all JSON-RPC
messages as C<POST> requests to that URL. Responses are accepted either in the
C<POST> reply body or as C<message> events on the stream. This works for
C<list>, C<call> and C<chat>. C<https://> URLs need L<IO::Socket::SSL>.
=head1 ENVIRONMENT
=over 4
=item C<HOME> / C<USERPROFILE>
Used to locate the default configuration file at
C<$HOME/.config/mcp-cli/config.json> when no C<--config> option is given and
no local config file is found.
=item C<OLLAMA_HOST>
Address of the Ollama server used by C<chat> (default
C<http://localhost:11434>).
=item C<MCPCLI_DEBUG>
When set to a true value, every JSON-RPC message sent to or received from the
server is printed to STDERR.
=back
=head1 DEPENDENCIES
=over 4
=item * L<App::MCP::CLI> - application framework and command dispatcher.
=item * L<App::Cmd> - sub-command dispatch framework.
=item * L<HTTP::Tiny> - HTTP client for the Ollama API and SSE C<POST> requests.
=item * L<IO::Socket::IP> (or L<IO::Socket::INET>) - the SSE event stream; L<IO::Socket::SSL> is needed for C<https://> servers.
=item * L<IPC::Open2> - bidirectional pipe to stdio MCP server processes.
=item * L<JSON::MaybeXS> - JSON encoding and decoding.
=item * L<Text::Table::Tiny> - ASCII table rendering for C<list> and C<servers>.
=back
A running L<Ollama|https://ollama.com> instance (C<http://localhost:11434>
unless C<OLLAMA_HOST> is set) is required for the C<interactive>/C<chat> commands.
=head1 EXIT STATUS
=over 4
=item C<0> - success.
=item C<1> - any error: usage error or missing argument, invalid configuration,
the server could not be started or reached, a timeout, an unknown tool, a
JSON-RPC error, or (for C<call>) a tool result flagged C<isError>. The message
is printed to STDERR.
( run in 1.425 second using v1.01-cache-2.11-cpan-eb134014566 )