Skip to main content

PyPI version Python versions License: MIT

merge-cli

CLI for Merge Agent Handler — search, discover, and execute thousands of tools.

Designed for AI agents (Claude Code, Cursor) that need progressive tool discovery without clogging the context window.

Install

pipx install merge-api   # recommended (isolated env)
pip install merge-api     # alternative

Quick Start

Option A: Login via browser (recommended)

merge login

Opens your browser to authenticate via OAuth. After consent, tokens are saved locally. No API key or tool pack ID needed.

Option B: Configure with API key

Note: merge configure is on a deprecation path. Use merge login instead.

merge configure

Or set environment variables:

export MERGE_AH_API_KEY="pk_..."
export MERGE_AH_TOOL_PACK_ID="your-tool-pack-uuid"
export MERGE_AH_REGISTERED_USER_ID="your-registered-user-id"

2. Search for tools

merge search-tools "send a Slack message"
{
  "tools": [
    {
      "name": "slack__post_message",
      "description": "Post a message to a Slack channel",
      "input_schema": { "type": "object", "properties": { "channel": { "type": "string" }, "text": { "type": "string" } } },
    }
  ],
  "total_results": 1,
  "hint": "To execute: merge execute-tool <tool_name> '<json_params>'"
}

3. Execute a tool

merge execute-tool slack__post_message '{"input": {"channel": "#general", "text": "Hello!"}}'
{
  "result": { "ok": true, "ts": "1234567890.123456" },
  "status": "success",
  "hint": "Tool executed successfully."
}

Commands

Command Description
merge search-tools <intent> Semantic search for tools by natural language (returns compact schemas)
merge execute-tool <tool> <params> Execute a tool with JSON parameters
merge list-tools List all available tools (compact by default)
merge get-tool-schema <tool> Get the input schema for a specific tool
merge login Log in via browser (OAuth)
merge logout Log out and clear OAuth tokens
merge configure Interactive API key setup (on deprecation path — use merge login)
merge setup <target> Generate AI agent config (claude-code, cursor, agents-md)
merge update Self-update to latest version

Common Options

All API commands accept these flags:

Flag Env Variable Description
--api-key MERGE_AH_API_KEY API key
--tool-pack-id MERGE_AH_TOOL_PACK_ID Tool pack ID
--registered-user-id MERGE_AH_REGISTERED_USER_ID Registered user ID

| --base-url | MERGE_AH_BASE_URL | Base URL override |

Authentication

Two auth modes, auto-detected:

Mode Setup Endpoint Use case
OAuth (recommended) merge login /mcp/ Human users, interactive
API key merge configure /api/v1/tool-packs/.../mcp CI/CD, automation

If both are configured, OAuth takes priority.

Configuration

Priority (highest to lowest):

  1. CLI flags: --api-key, --tool-pack-id, --registered-user-id, --base-url
  2. Environment variables: MERGE_AH_API_KEY, MERGE_AH_TOOL_PACK_ID, MERGE_AH_REGISTERED_USER_ID, MERGE_AH_BASE_URL
  3. Config file: ~/.merge/config.json

Example config file:

{
  "agent_handler": {
    "api_key": "pk_...",
    "tool_pack_id": "your-tool-pack-uuid",
    "registered_user_id": "your-registered-user-id"
  },
  "oauth": {
    "access_token": "...",
    "refresh_token": "...",
    "client_id": "merge-cli"
  }
}

Output Format

All commands output JSON to stdout. Warnings go to stderr.

Success response:

{
  "result": { ... },
  "status": "success",
  "hint": "Tool executed successfully."
}

Error response:

{
  "result": null,
  "status": "error",
  "error_type": "api_error",
  "message": "Description of what went wrong",
  "hint": "Suggested next step"
}

Error types: config_error, api_error, network_error, invalid_params, not_found, reauth_required, billing_limit_reached

Usage with AI Agents

The fastest way to set up any AI agent is the merge setup command:

Claude Code

merge setup claude-code

This appends merge CLI instructions to your CLAUDE.md (or creates it if it doesn't exist) and adds Bash(merge *) to .claude/settings.json. Safe to run multiple times — it won't duplicate content.

Cursor

merge setup cursor

This appends merge CLI instructions to your .cursorrules (or creates it if it doesn't exist).

Any AI Agent (AGENTS.md)

merge setup agents-md

This appends merge CLI instructions to your AGENTS.md (or creates it if it doesn't exist) — the cross-tool standard supported by Claude Code, Cursor, Codex, Windsurf, and more.

Manual Setup

If you prefer manual configuration, add this to your agent's system prompt or project instructions:

For any task involving third-party services (Slack, Jira, GitHub, Salesforce, etc.),
use the `merge` CLI. Do not call APIs directly.

Workflow:
1. merge search-tools "<intent>"        — find tools (returns compact schemas)
2. merge execute-tool <tool> '<json>'   — execute with JSON params

Troubleshooting

Problem Solution
config_error Run merge login (or merge configure for API key auth)
api_error with 401 Check your API key. Ensure test keys are used with test users and production keys with production users
not_found Use merge search-tools <intent> or merge list-tools to discover available tools
reauth_required The user needs to re-authenticate the connector in the Merge dashboard
billing_limit_reached Upgrade the account at the billing URL in the error response
network_error Check your internet connection and --base-url setting

Development

git clone https://github.com/merge-api/merge-cli.git
cd merge-cli
pip install -e ".[dev]"
pytest                    # run tests
ruff check .              # lint
ruff format --check .     # format check

License

MIT

Metadata

Release files for merge-api 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for merge-api 0.4.0
File Size Uploaded Provenance
merge_api-0.4.0.tar.gz 35.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for merge-api 0.4.0
File Interpreter ABI Platform
merge_api-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.3 kB

Release files / merge_api-0.4.0.tar.gz

Download URL merge_api-0.4.0.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
64d84cd0022c70cb82ec5478e5bf070a062ddac01f2ba4b75728fa115dd3080e
BLAKE2b-256 checksum
How to use checksums
2ba1ab5e3ea97ee713ba64e4303748f83f74365c81b2c522f2f99582a16197d6
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 9, 2026.

Transparency log

Release files / merge_api-0.4.0-py3-none-any.whl

Download URL merge_api-0.4.0-py3-none-any.whl
Size 32.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
102781ef87d4c3781092443de8022e0d64401847d8c635a95490c77cf2e4778b
BLAKE2b-256 checksum
How to use checksums
246b26e3dd789b96911d2fc243c9c896c89417cbf5f74dbebbc57dac65a14666
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 9, 2026.

Transparency log

Security for merge-api 0.4.0

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.

Select from 2 files

Attestation for merge_api-0.4.0.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 9, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page