Merge for Workforce CLI (mfw)
A command-line tool for Merge for Workforce employees: log in with your IdP, get a Gateway credential, and use your provisioned models and tools from the terminal.
Install
pipx install merge-workforce # recommended (isolated env, puts `mfw` on PATH)
pip install merge-workforce # alternative
pipx keeps the tool in its own environment and avoids the
"externally-managed-environment" error a plain pip install hits on modern
Python. One-time setup: brew install pipx && pipx ensurepath (macOS) or
python3 -m pip install --user pipx && pipx ensurepath (Linux). Update later
with pipx upgrade merge-workforce. Requires Python 3.10+.
To install an unreleased/dev build straight from the repo instead:
pipx install git+ssh://git@github.com/merge-api/merge-workforce-cli.git.
Quickstart
mfw login --gateway-url https://ah-api.merge.dev # opens your browser to sign in
mfw setup # provision this device's Gateway credential
mfw models # list the models you can use
mfw ask -m openai/gpt-4o-mini "hello" # one prompt to a chosen model
mfw chat -m openai/gpt-4o-mini "use my tools to …" # an agent that can call your provisioned tools
Set MFW_GATEWAY_URL once and you can drop --gateway-url from every command.
You must be a provisioned employee.
mfw setupmints your key only once your admin has activated Merge for Workforce and your group has a Gateway project. Ifsetupreturns "your admin has not finished setting up Merge Gateway for your group yet", that setup isn't complete — it's not a CLI error.
Commands
Run mfw --help, or mfw <command> --help for details on any one.
| Command | What it does |
|---|---|
mfw login |
Browser IdP login; stores a short-lived access token. |
mfw setup |
Provision this device's Gateway credential (per-device, revocable). |
mfw models |
List the models served for you. The id is what you pass as --model. |
mfw ask -m <id> "…" |
Send one prompt to a chosen model through the Gateway. |
mfw chat -m <id> "…" |
Run an agent that can call your provisioned tools (MCP tool loop). |
mfw mcp [--write .mcp.json] |
Emit an MCP config so an external client (Claude Code, Cursor) can use your tools. |
mfw env [--no-trace] |
Print export lines that route an AI tool through the Gateway (eval "$(mfw env)"). |
mfw run [--no-trace] -- <cmd> … |
Run a command with the Gateway credential injected as env (OpenAI- and Anthropic-compatible). |
mfw creds [--export] |
Show (or export) the provisioned Gateway credential. |
mfw whoami / mfw logout |
Show login state / clear the stored token. |
mfw admin <cmd> |
Workforce-admin operations (requires the manage_workforce role). See Admin operations. |
The Gateway routes and bills every call and enforces your allowlist, so a model or tool you aren't provisioned for comes back as a request error, never a silent fallback.
Admin operations (mfw admin)
For workforce admins — these provision and manage the org from the terminal.
They require the manage_workforce role and run against your mfw login
token, so no mfw setup is needed (admin commands don't use the Gateway
credential). Without the role they return a permission error.
mfw admin groups # list the org's groups (id + name)
mfw admin employees # list employees (id, name, origin id)
# add an employee to a group, then remove one (removal revokes their Gateway keys)
mfw admin add-employee --group <group-id> --name "Jane Doe" --origin-id "jane@corp.com"
mfw admin remove-employee <employee-id>
# a group's model allowlist — a full replace (repeat -m), or clear it
mfw admin set-models <group-id> -m anthropic/claude-haiku-4-5-20251001 -m amazon/nova-micro
mfw admin set-models <group-id> --unrestricted # allow every model
Run mfw admin --help, or mfw admin <command> --help, for details on any one.
Usage with AI agents
Two ways to give an AI agent your provisioned models and tools, both governed by your org:
-
mfw chatis a built-in agent — it drives a model through the Gateway and calls your provisioned tools over MCP, no other client needed. Every prompt carries oneX-Merge-Turn-Idon its model requests and its tool calls, so the Gateway request log and the Agent Handler tool call log join onturn_id. -
mfw mcphands your tools to an external MCP client (Claude Code, Cursor, any SDK agent). Write the config where the client reads it:mfw mcp --write .mcp.json # Claude Code picks this up from the project root
The config points the client at the backend's MCP endpoint with a short-lived token, so the agent calls tools as you, exactly as the console governs them. Re-run when the token lapses.
-
mfw envandmfw runpoint an AI tool at the Gateway. Both set the credential under its Merge, OpenAI-SDK (OPENAI_API_KEY/OPENAI_BASE_URL) and Anthropic-SDK (ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN) spellings, so Claude Code, Codex, or any SDK tool routes through the Gateway unchanged:eval "$(mfw env)" && claude # this shell mfw run -- claude # one process
By default both also turn on Claude Code's trace propagation (
CLAUDE_CODE_ENABLE_TELEMETRY,CLAUDE_CODE_ENHANCED_TELEMETRY_BETA,CLAUDE_CODE_PROPAGATE_TRACEPARENT,OTEL_TRACES_EXPORTER=otlpwith the Gateway's/v1/tracesas the OTLP endpoint). With those set, every model request and every MCP tool call in one prompt carries the same trace id, which Gateway logs asclient_trace_idand Agent Handler logs on the tool call, so one prompt joins across both logs. Variables you already export win; pass--no-traceto skip that block entirely.
How it works
- Login is OAuth 2.0 Authorization Code + PKCE with a loopback redirect
(RFC 8252): the public client
merge-workforce-cli(no secret on the laptop), your browser →<gateway>/o/authorize/→ IdP login + consent → code returns tohttp://localhost:{9410-9419}/callback→ exchanged at<gateway>/o/token/. The access token is stored in~/.mfw/credentials.json(0600). - Setup exchanges that token for a per-device Gateway API key
(
~/.mfw/gateway_credential.json), the same per-device path the desktop client uses — independently revocable, with spend attributed to you. - Models are the maintained
/v1/responsessurface;chatconnects your provisioned tools over the backend's OAuth-authed/mcp/endpoint and runs the function-calling loop for you.
Metadata
Release files for merge-workforce 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| merge_workforce-0.1.2.tar.gz | 24.4 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| merge_workforce-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.0 kB
Release files / merge_workforce-0.1.2.tar.gz
| Download URL | merge_workforce-0.1.2.tar.gz |
|---|---|
| Size | 24.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58a809bcc2f7b53bd7d14982648404329c2d809cc92586ab1cd371bdf49f10ad
|
|
BLAKE2b-256 checksum How to use checksums |
6f418e303fcdcec93be25b5bb94bfe635d6da2c45acc70a970867d7a1b046815
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logRelease files / merge_workforce-0.1.2-py3-none-any.whl
| Download URL | merge_workforce-0.1.2-py3-none-any.whl |
|---|---|
| Size | 25.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a28fbf96039e2178ef8d9cc597b3637217b7f7a97d69dba1ce149d0c4e2d947
|
|
BLAKE2b-256 checksum How to use checksums |
6c825ab77f425e4d435e9368213a92dfbdeb331799db0c7c830b02022663a3e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logSecurity for merge-workforce 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for merge_workforce-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.