For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Plugins

Reference for MetaMask Agent Wallet plugin authors. See the plugins overview for concepts and the build a plugin guide.

Plugin manifest

Every plugin declares an mm block in its package.json. Agent Wallet validates the manifest at install time and shows its contents on the consent screen.

The package must also declare the oclif-plugin keyword, an oclif block pointing at the compiled commands, and a generated oclif.manifest.json shipped in the package.

Packages that declare oclif.hooks or oclif.plugins are rejected because hooks run outside the plugin boundary.

"mm": {
"schemaVersion": 1,
"minCliVersion": "^6.1.0",
"capabilities": [],
"commands": [
{
"id": "hello:balance",
"capabilities": ["wallet-read"],
"dataAccess": ["balances"],
"targetChains": "any"
}
]
}
FieldRequiredDescription
schemaVersionYesManifest schema version. Must be 1.
minCliVersionYesSemver range of Agent Wallet versions the plugin supports, such as ^6.1.0.
capabilitiesNoPlugin-wide capabilities merged into every command. Keep this empty to avoid over-granting.
commandsYesOne entry per command. At least one command is required.
commands[].idYesCommand id matching the command's pluginCommandId, such as hello:balance.
commands[].capabilitiesNoCapabilities this command needs. Defaults to none.
commands[].dataAccessNoData categories the command reads, shown on the consent screen. Defaults to none.
commands[].targetChainsNo"any" or a list of EVM chain ids the command targets. Defaults to "any".

Capability types

Capabilities gate what a command can reach on the plugin context. Users consent to them at install time.

The capabilities mnemonic-read and config-write are reserved. Manifests that declare them are rejected.

A command that uses a gated member without declaring the matching capability fails at runtime with PERMISSION_DENIED.

CapabilityGrants
wallet-readRead services and the authenticated per-chain EVM RPC client. See the table below.
wallet-submitctx.walletExecutor for signing and transaction submission, still policy-gated by MetaMask.
network-managectx.networkRegistry. Reserved for future network management.

Plugin context

Commands access the host through this.ctx, a curated context the host restricts per command based on its granted capabilities.

The session, CLI token, and mnemonic store are host-only. Accessing them from a plugin always fails with PERMISSION_DENIED.

Context memberRequiresDescription
logger, args, flags, argvNoneAlways available.
accountServicewallet-readAccount and balance queries.
authServicewallet-readAuthentication state queries.
priceServicewallet-readSpot and historical prices.
tokenServicewallet-readToken metadata and discovery.
walletStateManagerwallet-readLocal wallet state snapshot, including wallets and the selection.
feesServicewallet-readFee estimates.
swapQuoteStorewallet-readPersisted swap quotes.
publicClient(chainId)wallet-readAuthenticated per-chain viem public client for raw EVM reads.
walletExecutor(io, source)wallet-submitExecutor for transactions, message signing, and typed-data signing.
networkRegistrynetwork-manageSupported network registry.

Raw EVM reads

With wallet-read, call ctx.publicClient(chainId) for an authenticated viem public client backed by the same RPC gateway the host uses:

const client = this.ctx.publicClient(1)
const balance = await client.getBalance({ address })

Signing and submission

With wallet-submit, call ctx.walletExecutor(io, "<command-id>") to get an executor. The executor accepts three request kinds and routes every request through MetaMask policy:

Request kindDescriptionResult
transactionSubmit an EVM transaction on a chainTransaction hash and status
messageSign a plaintext messageSignature
typed-dataSign an EIP-712 typed-data payloadSignature

PluginCommand class

A plugin command extends PluginCommand and implements execute. The security-critical lifecycle is sealed. A subclass that overrides run, runLifecycle, beforeExecute, init, prepareForRepl, withPluginIsolation, or the requiresAuth, requiresInit, and requiresFees getters throws PLUGIN_SEALED_OVERRIDE before it can run. Fee-cache warmup is host-only and always off for plugin commands.

MemberRole
execute(io)Required. The command's logic. Its return value is rendered by the host.
pluginCommandIdRequired. Must match the command's manifest id.
description, examples, flags, argsStatic configuration shown in help output.
requiresAuthStatic. Gates the sign-in check. Defaults to true.
requiresInitStatic. Gates the wallet setup check. Defaults to true.
afterExecute, successHint, analyticsOutcomeOptional hooks.

Plugin SDK surface

Import from @metamask/agent-wallet/plugin:

ExportDescription
PluginCommandBase class for plugin commands.
PluginCommandContextType of the curated context available as this.ctx.
PluginManifest, definePluginManifest, PluginManifestSchemaManifest type, authoring helper, and schema.
CommandIOInteraction surface passed to execute.
CommandError, ok, result helpersError and result envelope helpers.
schemaToFlags, schemaToArgs, resolveInputs, mergeArgsIntoFlags, enumFlag, trimKeyDeclarative input engine.
InputFieldType, InputSchema, InputField, ResolvedInputs, SelectOption, AskerInput types.
PublicClientviem public client type returned by ctx.publicClient.

Data access categories

commands[].dataAccess labels the data a command reads. The categories appear on the consent screen and are informational.

accounts, balances, prices, tokens, network, fees, swap-quotes, session, mnemonic

Storage locations

DataLocation
Plugin codeThe oclif data directory. On macOS ~/Library/Application Support/mm/, on Linux ~/.local/share/mm/.
Approvals and configuration~/.metamask/config.json under the plugins key.