Starter template for building a MetaMask Agent Wallet plugin. A plugin is an npm package that adds native mm commands, discoverable in mm help and the REPL.
The template has one working command:
mm hello ping [name]
-
Click "Use this template" on GitHub or clone this repo, then rename things:
package.json→name,description, and themm.commands[].identriessrc/commands/<topic>/<command>.ts→ the file path defines the command. For example,src/commands/hello/ping.tsbecomesmm hello pingwith idhello:ping.
-
Install and build. The examples below use npm. You can use your preferred package manager.
npm install npm run build # tsc + oclif manifest -
Enable the plugin beta in the CLI and install your plugin locally:
mm config set experimentalPlugins true mm config set experimentalAllowUnverifiedInstalls true # allows local file: installs mm plugins install "file:$PWD" --accept-permissions
Install from the directory, not a packed tarball. The CLI reads
package.json#mmfrom the directory to persist capability approvals for local installs. -
Try it:
mm hello ping Alice mm plugins uninstall mm-plugin-hello # remove between iterations -
Publish to npm when ready. Users then install with
mm plugins install <your-package>and review a consent screen listing your commands, data access, and requested capabilities.
- Extend
PluginCommandfrom@metamask/agent-wallet/pluginand implementexecute(). The rest of the lifecycle, such as auth gates, analytics, rendering, and isolation, is sealed by the host. pluginCommandIdmust match the command'sidinpackage.json#mm.commands.requiresAuthandrequiresInitgate sign-in and wallet setup. Both default totrue.- Declare inputs once as a schema.
schemaToFlagsandschemaToArgsgenerate the oclif surface, andio.resolveInputs(inputs)resolves flags, positionals, and interactive prompts. - The base flags
--json,--format,--toon, and--verboseare inherited automatically. oclif.manifest.jsonis generated on build and must ship with the package.
Declare what each command needs in package.json#mm.commands[].capabilities. Users consent at
install time. Keep the plugin-wide mm.capabilities list empty because it is merged into every
command.
The template's hello:ping declares no capabilities. It is a pure command that runs for anyone
with the plugin installed. The session, CLI token, and Secret Recovery Phrase are host-only and
never exposed to plugins.
