AnyEvent-MCP
view release on metacpan or search on metacpan
bin/anyevent-mcp view on Meta::CPAN
#!/opt/bin/perl
=head1 NAME
anyevent-mcp - initialize MCP configuration and manage users and permissions
=head1 SYNOPSIS
anyevent-mcp init
anyevent-mcp manage-rules fs-default
anyevent-mcp create-user chatgpt
anyevent-mcp revoke-user chatgpt
anyevent-mcp edit-rules-file /path/to/rules.ini
=head1 DESCRIPTION
C<anyevent-mcp> sets up the shared AnyEvent::MCP configuration and manages
permission rules saved by its servers. Use it to review permissions you have
allowed or denied permanently, remove a rule, or change the order in which
rules are checked.
C<manage-rules> opens a graphical rule manager; C<edit-rules> opens the
rule file in your text editor. Both take a rule profile name. For example,
C<anyevent-mcp manage-rules fs-default> manages the default filesystem
server's rules. The corresponding C<*-file> commands accept a pathname
when an application stores its rules elsewhere.
C<init> creates the private global configuration and its master secret,
from which servers can derive their connection credentials. You normally
do not need to run it: a server creates a missing secret when it loads its
configuration. Use C<init> when you want to create the configuration
explicitly; it refuses to overwrite an existing file.
See L<AnyEvent::MCP::Intro> for setting up and connecting to the servers,
L<AnyEvent::MCP/GLOBAL CONFIGURATION> for the configuration file format,
and L<AnyEvent::MCP::Server::Permissions/RULE FILES> for permission rules.
=head1 COMMANDS
=over
=item init
Create the private global configuration and master secret. Unlike ordinary
configuration loading, this fails rather than overwriting an existing file.
C<--config FILE> selects a different configuration file for this command.
=item manage-rules NAME
Open the YAD rule deletion and reordering interface for the named profile.
For a filesystem server started with C<--name code>, use profile C<fs-code>.
=item edit-rules NAME
Open the named profile's rule file in a text editor.
=item manage-rules-file $file
Open the rule manager for the explicit pathname C<$file>.
=item edit-rules-file $file
Open C<$file> in a text editor. Use these explicit-file commands for
applications whose rule files do not use the named-profile convention.
=item create-user USER
Enable a new named user; rotate a revoked user at the next generation.
Use --program or --instance for a scoped override.
=item revoke-user USER
Disable a user, preserving the generation for later rotation. In a narrower
scope, a negative definition also blocks inherited credentials. Implicit
global:default is revocable. Restart affected servers after changes; these
commands do not print secrets. Use server --print-url[=USER] for URLs.
=back
Named profiles use
C<anyevent-mcp/rules/NAME.ini> in the user configuration directory.
Editing uses C<$VISUAL>, C<$EDITOR>, C<sensible-editor> or C<vi>.
For server URLs, use each server's C<--print-url> option.
=head1 OPTIONS
=over
=item --config FILE
Use FILE instead of default global configuration
(C<$XDG_CONFIG_HOME/anyevent-mcp/global.ini>, or
C<~/.config/anyevent-mcp/global.ini>). Relevant to C<init> and user
management; rule management uses its own profile or pathname.
=item --program NAME
Select C<[program NAME]> for user management.
=item --instance NAME
Select C<[instance NAME]> for user management. Cannot combine with --program.
=item --help
Print command synopsis, available commands and configuration defaults,
then exit without running a command.
=back
=cut
use common::sense;
use Getopt::Long ();
use AnyEvent::MCP ();
use AnyEvent::MCP::Config ();
use AnyEvent::MCP::File ();
sub usage {
print <<'EOF';
Usage: anyevent-mcp [OPTIONS] COMMAND [ARGUMENTS]
manage-rules NAME delete/reorder rules in YAD
edit-rules NAME edit rules with VISUAL, EDITOR, sensible-editor, vi
manage-rules-file FILE manage an explicit rules file
edit-rules-file FILE edit an explicit rules file
init create a private configuration and master secret
create-user USER enable or rotate a managed user
revoke-user USER revoke a managed user
Options (before COMMAND):
--config FILE use a different global configuration file
( run in 1.381 second using v1.01-cache-2.11-cpan-3f962061493 )