NAME
Punk::Command::Mcp - the punk mcp command
SYNOPSIS
punk mcp # the application found from here
punk mcp --dir /srv/acme --token "$TOKEN"
claude mcp add acme -- punk mcp --dir /srv/acme
DESCRIPTION
Serves an application's MCP endpoint over stdin and stdout, for an MCP client that launches its servers as subprocesses. Newline-delimited JSON-RPC, one message a line each way, and nothing else on stdout: a print in a controller goes to stderr, as do logs.
The application is found as every punk command finds one (--dir, or walking up for app.psgi), and must use plugin 'MCP', or the command exits 2 saying so.
Who may call
The endpoint's auth and oauth guards run on every message, with --token (or PUNK_MCP_TOKEN) as a Bearer token. stdio_trust, a plugin option, skips them over stdio: the process was started by whoever owns it, and nothing on a network reaches this path. principal runs as it does over HTTP.
What differs from HTTP
The process is the session: it keeps the negotiated version, the log level and its resource subscriptions, and a resource update is written as a line the moment it happens. Only updates made in this process arrive: it is not part of a running server's worker pool, so a change made through the web application does not reach it. Messages are handled one at a time, so a ping or a cancellation sent during a call is answered after it. The application's request hooks do not run, since a message is dispatched directly rather than as an HTTP request.
--env sets PUNK_ENV before the application loads.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)