.\" -*- mode: troff; coding: utf-8 -*-
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
.ie n \{\
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "MCP::Client 3pm"
.TH MCP::Client 3pm 2026-05-09 "perl v5.40.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH NAME
MCP::Server::Transport::HTTP \- HTTP transport for MCP servers
.SH SYNOPSIS
.IX Header "SYNOPSIS"
.Vb 1
\&  use MCP::Client;
\&
\&  my $client = MCP::Client\->new(url => \*(Aqhttp://localhost:3000/mcp\*(Aq);
\&  $client\->initialize_session;
\&  my $tools = $client\->list_tools;
.Ve
.SH DESCRIPTION
.IX Header "DESCRIPTION"
MCP::Client is a client for MCP (Model Context Protocol) that communicates with MCP servers over HTTP.
.SH ATTRIBUTES
.IX Header "ATTRIBUTES"
MCP::Client inherits all attributes from Mojo::Base and implements the following new ones.
.SS name
.IX Subsection "name"
.Vb 2
\&  my $name = $client\->name;
\&  $client  = $client\->name(\*(AqPerlClient\*(Aq);
.Ve
.PP
The name of the client, defaults to \f(CW\*(C`PerlClient\*(C'\fR.
.SS session_id
.IX Subsection "session_id"
.Vb 2
\&  my $session_id = $client\->session_id;
\&  $client        = $client\->session_id(\*(Aq12345\*(Aq);
.Ve
.PP
The session ID for the client, used to maintain state across requests.
.SS ua
.IX Subsection "ua"
.Vb 2
\&  my $ua  = $client\->ua;
\&  $client = $client\->ua(Mojo::UserAgent\->new);
.Ve
.PP
The user agent used for making HTTP requests, defaults to a new instance of Mojo::UserAgent.
.SS url
.IX Subsection "url"
.Vb 2
\&  my $url  = $client\->url;
\&  $client  = $client\->url(\*(Aqhttp://localhost:3000/mcp\*(Aq);
.Ve
.PP
The URL of the MCP server, defaults to \f(CW\*(C`http://localhost:3000/mcp\*(C'\fR.
.SS version
.IX Subsection "version"
.Vb 2
\&  my $version = $client\->version;
\&  $client     = $client\->version(\*(Aq1.0.0\*(Aq);
.Ve
.PP
The version of the client, defaults to \f(CW1.0.0\fR.
.SH METHODS
.IX Header "METHODS"
MCP::Client inherits all methods from Mojo::Base and implements the following new ones.
.SS build_request
.IX Subsection "build_request"
.Vb 1
\&  my $request = $client\->build_request(\*(Aqmethod_name\*(Aq, {param1 => \*(Aqvalue1\*(Aq});
.Ve
.PP
Builds a JSON-RPC request with the given method name and parameters.
.SS build_notification
.IX Subsection "build_notification"
.Vb 1
\&  my $notification = $client\->build_notification(\*(Aqmethod_name\*(Aq, {param1 => \*(Aqvalue1\*(Aq});
.Ve
.PP
Builds a JSON-RPC notification with the given method name and parameters.
.SS call_tool
.IX Subsection "call_tool"
.Vb 2
\&  my $result = $client\->call_tool(\*(Aqtool_name\*(Aq);
\&  my $result = $client\->call_tool(\*(Aqtool_name\*(Aq, {arg1 => \*(Aqvalue1\*(Aq});
.Ve
.PP
Calls a tool on the MCP server with the specified name and arguments, returning the result.
.SS delete_session
.IX Subsection "delete_session"
.Vb 1
\&  my $bool = $client\->delete_session;
.Ve
.PP
Send a \f(CW\*(C`DELETE\*(C'\fR request to terminate the current session on the MCP server, and clear the local
"session_id". Returns true on success, or \f(CW\*(C`undef\*(C'\fR if no session is active. The server only honors this when it
was configured with \f(CW\*(C`streaming => 1\*(C'\fR.
.SS get_prompt
.IX Subsection "get_prompt"
.Vb 2
\&  my $result = $client\->get_prompt(\*(Aqprompt_name\*(Aq);
\&  my $result = $client\->get_prompt(\*(Aqprompt_name\*(Aq, {arg1 => \*(Aqvalue1\*(Aq});
.Ve
.PP
Get a prompt from the MCP server with the specified name and arguments, returning the result.
.SS initialize_session
.IX Subsection "initialize_session"
.Vb 1
\&  my $result = $client\->initialize_session;
.Ve
.PP
Initializes a session with the MCP server, setting up the protocol version and client information.
.SS list_prompts
.IX Subsection "list_prompts"
.Vb 1
\&  my $prompts = $client\->list_prompts;
.Ve
.PP
Lists all available prompts on the MCP server.
.SS list_resources
.IX Subsection "list_resources"
.Vb 1
\&  my $resources = $client\->list_resources;
.Ve
.PP
Lists all available resources on the MCP server.
.SS list_tools
.IX Subsection "list_tools"
.Vb 1
\&  my $tools = $client\->list_tools;
.Ve
.PP
Lists all available tools on the MCP server.
.SS ping
.IX Subsection "ping"
.Vb 1
\&  my $result = $client\->ping;
.Ve
.PP
Sends a ping request to the MCP server to check connectivity.
.SS read_resource
.IX Subsection "read_resource"
.Vb 1
\&  my $result = $client\->read_resource(\*(Aqfile:///path/to/resource.txt\*(Aq);
.Ve
.PP
Reads a resource from the MCP server with the specified URI, returning the result.
.SS send_request
.IX Subsection "send_request"
.Vb 1
\&  my $response = $client\->send_request($request);
.Ve
.PP
Sends a JSON-RPC request to the MCP server and returns the response.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
MCP, <https://mojolicious.org>, <https://modelcontextprotocol.io>.
