Init and configuration

Create gma.config.json and configure the gma CLI.

CLI

gma init creates a gma.config.json in the current directory. It detects whether the project is a Foundry, Hardhat, or raw-ABI project and pre-fills the config from package.json when available.

Run init

gma init
gma init --force # overwrite an existing gma.config.json

How config is discovered

The CLI uses cosmiconfig and searches upwards from the current working directory in this order:

  • package.json (the "gma" key)
  • gma.config.json
  • gma.config.js
  • gma.config.cjs
  • gma.config.mjs
  • gma.config.ts
  • .gmarc
  • .gmarc.json

Framework detection

With framework: 'auto' (the default for gma generate), the CLI inspects the working directory and chooses Foundry, Hardhat, or raw ABIs. You can pin this with framework in the config or --framework on the command line. Test contracts (*.t.sol) and script contracts (*.s.sol) are filtered out automatically; pass --include-empty-abis to include interfaces and libraries with empty ABIs.

Project config schema

All fields are optional.

FieldTypeDescription
$schemastringJSON Schema URL for editor validation; ignored by the CLI.
packageNamestringnpm package name for the generated bindings.
packageVersionstringnpm package version for the generated bindings.
projectNamestringProject name embedded in metadata.
frameworkauto | foundry | hardhat | abisSelects how ABIs are collected.
abisstring[]Files, directories, or globs (used when framework: 'abis').
outputstringOutput directory. Default ./gma-out.
tarstringPath to the .tgz used by gma publish. If unset, the publish command resolves <output>/<name>-<version>.tgz.
targetviemCodegen target.
generateMcpbooleanAlso emit a companion MCP server package alongside the bindings.
mcpAllowWritesbooleanWhen true, the MCP server includes write tools; default is read-only.
includeEmptyAbisbooleanKeep contracts with empty ABIs (interfaces, libraries).
registryURLDefault registry URL for publishing.
accesspublic | restrictednpm access flag.
tagstringDefault dist-tag for publishing.
tokenEnvstringEnvironment variable name to read the registry token from (the init template uses NPM_TOKEN).

Init template

Running gma init writes defaults that include output: "./gma-out", target: "viem", generateMcp: true, registry: "https://registry.npmjs.org", access: "public", and tokenEnv: "NPM_TOKEN". The detected framework is recorded; for the raw-ABI case, the template includes "abis": ["./abis/**/*.json"].

When a root package.json exists, packageName, packageVersion, projectName, and the registry from publishConfig.registry are pre-filled when valid; if private: true, access is set to restricted.

Precedence

For values used by gma generate and gma publish, command-line flags win, then the project config, then the active profile from ~/.gma/config.json (registry and npm token only). Tokens specifically resolve as: --token $tokenEnv (if set in config) → NPM_TOKEN → the profile's saved npmToken.

Related