A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mojolicious/mojo-mcp below:

mojolicious/mojo-mcp: Perl SDK for Model Context Protocol servers and clients

Model Context Protocol support for Perl and the Mojolicious real-time web framework.

Please be aware that this module is still in development and will be changing rapidly. Additionally the MCP specification is getting regular updates which we will implement. Breaking changes are very likely.

All you need is Perl 5.20 or newer. Just install from CPAN.

We recommend the use of a Perlbrew environment.

Streamable HTTP Transport

Use the to_action method to add an MCP endpoint to any Mojolicious application.

use Mojolicious::Lite -signatures;

use MCP::Server;

my $server = MCP::Server->new;
$server->tool(
  name         => 'echo',
  description  => 'Echo the input text',
  input_schema => {type => 'object', properties => {msg => {type => 'string'}}, required => ['msg']},
  code         => sub ($tool, $args) {
    return "Echo: $args->{msg}";
  }
);

any '/mcp' => $server->to_action;

app->start;

Authentication can be added by the web application, just like for any other route.

Build local command line applications and use the stdio transport for testing with the to_stdio method.

use Mojo::Base -strict, -signatures;

use MCP::Server;

my $server = MCP::Server->new;
$server->tool(
  name         => 'echo',
  description  => 'Echo the input text',
  input_schema => {type => 'object', properties => {msg => {type => 'string'}}, required => ['msg']},
  code         => sub ($tool, $args) {
    return "Echo: $args->{msg}";
  }
);

$server->to_stdio;

Just run the script and type requests on the command line.

$ perl examples/echo_stdio.pl
{"jsonrpc":"2.0","id":"1","method":"tools/list"}
{"jsonrpc":"2.0","id":"2","method":"tools/call","params":{"name":"echo","arguments":{"msg":"hello perl"}}}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4