AnyEvent-MCP
view release on metacpan or search on metacpan
lib/AnyEvent/MCP/Intro.pod view on Meta::CPAN
changedtick and do not save files to disk.
To pass arguments directly, use C<PREFIX --- PROGRAM ARG... --->:
mcp-multibroker --stdio \
vim --- mcp-vim --name editor --bind :: --- --eager \
code --- mcp-fs --name code '/home/alice/project with spaces' ---
Only the invoking shell processes quoting. The broker passes all arguments
between the delimiters unchanged, including empty arguments and child options.
Use C<stdio:COMMAND> for shell syntax or a literal C<---> child argument.
An empty command or missing closing delimiter is an error.
C<--eager> belongs immediately after its stdio URL or closing C<--->.
An eager connection failure is logged; the broker does not continuously
restart the child. Later tool use can try connecting again.
=head2 Ask the client's human a question
To let the assistant ask you questions, configure its MCP client to launch:
mcp-ask-user --stdio
Or add the question server to a multibroker:
mcp-multibroker --stdio \
code 'stdio:mcp-fs --name code /home/alice/src/project' \
questions 'stdio:mcp-ask-user'
The LLM can call C<ask-user> (C<questions.ask-user> through the multibroker)
with a question, up to three suggested answers and room for free text.
For example, tell it to use that tool if choosing among several possible
tasks needs your input. For several fields or other value types,
C<ask-form> (C<questions.ask-form> through the multibroker) accepts
C<message> and C<requestedSchema> directly and returns the standard
elicitation response. Both tools use the same configured presentation mode.
Decline and cancel are distinct results; neither supplies an answer.
By default the multibroker displays questions locally, using YAD or a terminal.
Add C<--ask mcp> before the broker entries to use the client's native forms,
or C<--ask auto> to select by advertised capability. This also works with
C<mcp-ask-user> started separately: give that server C<--ask mcp> so it
delegates presentation to its connecting multibroker.
C<anyevent-mcp-form-elicitation> is the standalone form renderer. It reads standard MCP
form parameters as UTF-8 JSON on stdin and writes an accept/decline/cancel
response as JSON on stdout. C<PERL_ANYEVENT_MCP_ELICITATION_HELPER> selects
a replacement executable. See L<anyevent-mcp-form-elicitation> for supported fields
and L<mcp-ask-user> for question arguments and result fields.
=head1 MAIL AND HTTP TOOLS
=head2 Read and organize mail
Configure an IMAP account interactively before starting its MCP server.
Look up provider setup instructions and candidate login commands:
mcp-imap --name personal providers alice@example.net
Replace the example address. Provider OAuth client registrations may not
be usable by unrelated applications. For ordinary password or app-password
authentication, a manual login looks like:
mcp-imap --name personal login method password \
server imap.example.net user alice@example.net tls connect port 993
The password is requested on the terminal, never as a command argument.
For OAuth2, use a provider-approved registration and the suggested
C<login method oauth2> parameters. Authorize the intended mail account in
a browser, then paste the entire final redirect URL in the terminal.
An error page at the unserved loopback redirect is expected. See
L<mcp-imap> for OAuth options, refresh tokens and other restrictions.
After login, configure your MCP client to launch:
mcp-imap --stdio --name personal
Or combine it with other servers:
mcp-multibroker --stdio mail --- mcp-imap --name personal --stdio ---
The prefix C<mail> produces tools such as C<mail.lsub> and
C<mail.messages>; C<personal> selects the account and its permission rules.
For example, ask your assistant:
List my subscribed mailboxes, then show five recent messages in INBOX,
with their senders and subjects. Do not change any flags.
C<lsub> lists subscriptions; C<mailboxes> lists all available folders.
The C<mailbox> tool can subscribe and unsubscribe, without changing access
rights or deleting messages.
To search, pass a C<filter> to C<messages>, for example:
{
"mailbox": "INBOX",
"limit": 20,
"filter": {
"since": "1-Nov-2026",
"any": [
{"from": "alice@example.net"},
{"subject": "invoice"}
],
"not": {"deleted": true}
}
}
Filter keys are ANDed; C<any> adds OR, C<all> groups AND, and C<not>
negates a group. Searches scan at most 20000 UID values per call, not
20000 existing messages. Whenever C<next_cursor> is present, continue
with it as C<cursor> and preserve C<filter>, even on an empty page.
C<more> means continuation is needed; C<incomplete> means the scan limit
was reached. For targeted whole-mailbox lookups, use C<threads>.
Use the returned mailbox, UIDVALIDITY and UID together for later operations.
Read tools never mark messages Seen.
Changing flags, moving messages and expunging require separate permissions.
Marking C<\\Deleted> does not remove a message permanently; expunging does.
After an interrupted write, inspect the mailbox before attempting it again.
APPEND stores mail (including drafts) but does not send it. See
L<mcp-imap/TOOLS> for complete operations and limits.
=head2 Use an HTTP request tool
Launch C<mcp-http --stdio> or combine it as C<web --- mcp-http --stdio --->.
For example, ask your assistant:
( run in 1.197 second using v1.01-cache-2.11-cpan-f5f21f1076c )