MCP-Run

 view release on metacpan or  search on metacpan

.claude/skills/perl-mcp/SKILL.md  view on Meta::CPAN

    name => 'query_data',
    description => 'Query records from a table',
    input_schema => {
        type => 'object',
        properties => {
            table  => { type => 'string', description => 'Table name' },
            filter => { type => 'object', description => 'WHERE conditions' },
        },
        required => ['table'],
    },
    code => sub {
        my ($self, $args) = @_;
        my $rs = eval { $db->resultset($args->{table}) };
        return $self->text_result("Unknown table: $args->{table}", 1) unless $rs;

        my @rows = $rs->search($args->{filter} // {})->all;
        my @data = map { { $_->get_columns } } @rows;
        return $self->text_result($json->encode(\@data));
    },
);
```
</common-patterns>

<async-integration>
## Async Integration with Langertha

```perl
use IO::Async::Loop;
use Net::Async::MCP;
use MCP::Server;
use Langertha::Engine::Anthropic;
use Langertha::Raider;
use Future::AsyncAwait;

# 1. Create server with tools
my $server = MCP::Server->new(name => 'demo', version => '1.0');
$server->tool(name => 'add', ...);

# 2. Wrap in async MCP client
my $loop = IO::Async::Loop->new;
my $mcp = Net::Async::MCP->new(server => $server);
$loop->add($mcp);

async sub main {
    await $mcp->initialize;

    # 3. Create engine with MCP
    my $engine = Langertha::Engine::Anthropic->new(
        api_key     => $ENV{ANTHROPIC_API_KEY},
        model       => 'claude-sonnet-4-6',
        mcp_servers => [$mcp],
    );

    # 4a. One-shot tool calling
    my $response = await $engine->chat_with_tools_f('Add 42 and 17');

    # 4b. Or Raider for multi-turn
    my $raider = Langertha::Raider->new(
        engine         => $engine,
        mission        => 'You are a calculator.',
        max_iterations => 10,
    );
    my $result = await $raider->raid_f('Add 42 and 17');
}

main()->get;
```
</async-integration>

<tool-description-tips>
## Writing Good Tool Descriptions

```perl
# BAD: Vague
$server->tool(name => 'do_stuff', description => 'Does stuff', ...);

# GOOD: Clear, specific, with usage guidance
$server->tool(
    name        => 'search_documents',
    description => 'Search documents by title or content. Returns matching documents '
                 . 'with their IDs and summaries. Use this when the user asks about '
                 . 'finding or looking up information.',
    input_schema => {
        type => 'object',
        properties => {
            query => {
                type        => 'string',
                description => 'Search query (2-10 words recommended for best results)',
            },
            limit => {
                type        => 'number',
                description => 'Max results to return (default: 10)',
            },
        },
        required => ['query'],
    },
    ...
);
```
</tool-description-tips>



( run in 3.091 seconds using v1.01-cache-2.11-cpan-5c0b1e786e0 )