# CLI

> The threefold command line: install the MCP server into your coding agents, run the i18n readiness check, sign in, and discover, describe and call endpoints.

```sh
npx threefold <command>
```

The CLI is a thin client. Apart from `check`, which runs locally, it only talks to the API and builds each call from the server's own schema. It uses `https://api.threefold.eco` unless you point it elsewhere.

<div class="note">

The npm package is not published yet, so `npx threefold` does not run today. Use the per-client settings in [Install and connect](https://threefold.eco/docs/install.md) instead.

</div>

## Commands

| Command | What it does |
|---|---|
| `threefold init [path] [--markets <locales>] [--no-mcp] [--dry-run] [--json]` | First run in a Swift, Kotlin, React Native, Expo or Next.js repository, in under a minute: finds the languages you ship, names the top three target countries, lists your biggest local gaps and connects the MCP server to the coding agents on this machine. Source code stays on your machine. |
| `threefold skills install [--agent <name>] [--global] [--dir <folder>] [--dry-run]` | Copies the threefold skills into Claude Code, Cursor, Codex or Windsurf and checks every file |
| `threefold mcp install [--client <name>] [--key <k>] [--oauth] [--url <url>] [--dry-run]` | Writes the threefold MCP entry for Claude Code, Codex, Cursor, Gemini CLI, OpenCode, VS Code and Windsurf. See [Install and connect](https://threefold.eco/docs/install.md). `threefold mcp` on its own prints this usage; it does not start a server. |
| `threefold check [path] --markets <locales> [--runtime web --url <url>] [--full] [--json] [--legal] [--upload] [--pr-comment [--baseline <report.json>]]` | Runs the [i18n readiness check](https://threefold.eco/docs/i18n-check.md) on your machine. `--pr-comment` prints the Markdown that the GitHub Action posts on a pull request. |
| `threefold login [--url <base>]` | Browser sign-in (OAuth 2.1 with PKCE). Every other command then uses the saved login, and the token is refreshed when it expires. |
| `threefold login --key <api-key> [--url <base>]` | Saves an API key (`tf_live_…` or `tf_test_…`) instead, with no browser |
| `threefold whoami` | Shows who the saved login or environment key belongs to |
| `threefold discover "<task>" [--limit N]` | Ranked endpoints for a task in plain language |
| `threefold schema <endpoint-id>` | Inputs, coverage, limits and price for one endpoint |
| `threefold call <endpoint-id> --<input> <value> ...` | Calls an endpoint. Lists are comma-separated. |

The login is saved in `~/.config/threefold/credentials.json` (or under `$XDG_CONFIG_HOME`) with owner-only permissions, and it is only ever sent to the server it was issued for. With an API key the CLI uses the REST API. With a browser login it calls the same endpoints as MCP tools over `/mcp`, so `call` takes the MCP tool's argument names (`schema` lists them under `mcp_input_schema`).

`threefold mcp install` defaults to `--client all`, which writes every supported client config, even for clients not yet installed. Use `--client <name>` to select one. New configs, configs changed to add a key, and backups have owner-only permissions on Unix. `--dry-run` prints only the proposed entry and does not print existing credentials.

## Environment

| Variable | Meaning |
|---|---|
| `THREEFOLD_BASE_URL` | API base URL. Default: the server you logged in to, else `https://api.threefold.eco`. |
| `THREEFOLD_API_KEY` or `THREEFOLD_TOKEN` | A Bearer credential that overrides the saved login. With neither and no login, library reads go through the keyless tier. |

## Example

```sh
npx threefold login
npx threefold discover "which finance apps win in Mexico but not Spain"
npx threefold schema compare_markets
npx threefold call compare_markets --from es --to mx --niche finance
```

`call` prints the response body. Exit codes: `0` on success, `1` on an HTTP error or a bad command, `2` on a usage error (an unknown command: the reason and the usage text go to stderr). `threefold --help` and `threefold <command> --help` print the usage text and exit `0`. `check` exits `1` when the verdict is `incomplete` and `2` when it cannot read the project.

## Local MCP server

`threefold` has no command that starts an MCP server. The local stdio server is `node mcp/server.mjs`, run from a checkout of the threefold repository. It is the server where the `check` tool with `what: "repo"` scans local files on the machine it runs on; on the hosted server at `https://api.threefold.eco/mcp`, `check` returns the readiness criteria for the agent to apply directly (see [Agent tools](https://threefold.eco/docs/agent-tools.md)).
