Init and configuration
Create gma.config.json and configure the gma 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.jsonHow 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.jsongma.config.jsgma.config.cjsgma.config.mjsgma.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.
| Field | Type | Description |
|---|---|---|
$schema | string | JSON Schema URL for editor validation; ignored by the CLI. |
packageName | string | npm package name for the generated bindings. |
packageVersion | string | npm package version for the generated bindings. |
projectName | string | Project name embedded in metadata. |
framework | auto | foundry | hardhat | abis | Selects how ABIs are collected. |
abis | string[] | Files, directories, or globs (used when framework: 'abis'). |
output | string | Output directory. Default ./gma-out. |
tar | string | Path to the .tgz used by gma publish. If unset, the publish command resolves <output>/<name>-<version>.tgz. |
target | viem | Codegen target. |
generateMcp | boolean | Also emit a companion MCP server package alongside the bindings. |
mcpAllowWrites | boolean | When true, the MCP server includes write tools; default is read-only. |
includeEmptyAbis | boolean | Keep contracts with empty ABIs (interfaces, libraries). |
registry | URL | Default registry URL for publishing. |
access | public | restricted | npm access flag. |
tag | string | Default dist-tag for publishing. |
tokenEnv | string | Environment 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
- CLI overview
What the gma CLI does and when to use it.
- Generate bindings with the CLI
Use gma generate to produce a typed bindings tarball.
- Publish bindings with the CLI
Use gma publish to upload a bindings tarball to npm.
- Environment variables
Environment variables the gma CLI reads.
- Configuration
Project, build, and publishing configuration options.