NAME

MCP::Run::Compress - Output compression for LLMs

VERSION

version 0.101

SYNOPSIS

use MCP::Run::Compress;

my $compressor = MCP::Run::Compress->new;
$compressor->register_filter(
  'command' => '^ls\b',
  'strip_lines_matching' => [qr(^\s*$), qr(^total\s+\d+)],
  'truncate_lines_at' => 120,
  'max_lines' => 50,
);

my ($compressed_stdout, $compressed_stderr) = $compressor->compress($command, $stdout, $stderr);

DESCRIPTION

Automatic output compression for LLM consumption. Applies command-specific filters to reduce token count while preserving essential information.

_parse_command

my $parsed = $self->_parse_command($command);

Parses a command string into structured components for filter matching:

program    - first word (e.g., 'git')
subcommand - second word if not a flag (e.g., 'diff' in 'git diff')
flags      - hashref of parsed flags (e.g., { stat => 1, w => 5 })
args       - remaining non-flag arguments

Supports git-style commands where the subcommand is the first non-flag word.

AUTHOR

Torsten Raudssus https://raudssus.de/

COPYRIGHT

Copyright 2026 Torsten Raudssus

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-mcp-run/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <getty@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.