Merge CLI

Search, discover, and execute Agent Handler tools from the command line.

The Merge CLI is a lightweight command-line tool for interacting with Agent Handler. It provides semantic tool search, schema inspection, and tool execution — purpose-built for AI coding agents like Claude Code and Cursor that need progressive tool discovery without overwhelming the context window.

Prerequisites

  1. Tool Pack ID: The ID of the tool pack to use. Found in the Agent Handler dashboard or via the GET /tool-packs endpoint.
  2. Registered User ID: The ID of the user who will interact with your agent. Found in the dashboard or created via API.
  3. Production Access Key: Your Merge Agent Handler API key for authentication.

Test access keys must be paired with test registered users, and production keys with production users.

Getting Started

1

Install the CLI

Install with pipx (recommended) or pip:

$pipx install merge-api
$pip install merge-api

Verify your installation:

$merge --version
2

Configure credentials

Run the interactive setup:

$merge configure

This saves your credentials to ~/.merge/config.json.

Alternatively, 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"
3

Search for tools

Find tools using natural language:

$merge search-tools "send a Slack message"

Output:

1{
2 "tools": [
3 {
4 "name": "slack__post_message",
5 "description": "Post a message to a Slack channel",
6 "input_schema": { ... },
7 }
8 ],
9 "total_results": 1,
10 "hint": "To execute: merge execute-tool <tool_name> '<json_params>'"
11}

Use --no-schema to reduce output size, or --connector slack to filter by connector.

4

Get a tool's input schema

Before executing, inspect the required parameters:

$merge get-tool-schema slack__post_message

This returns the full JSON Schema for the tool’s input parameters.

5

Execute a tool

Run the tool with JSON parameters:

$merge execute-tool slack__post_message '{"input": {"channel": "#general", "text": "Hello!"}}'

Output:

1{
2 "result": { "ok": true, "ts": "1234567890.123456" },
3 "status": "success",
4 "hint": "Tool executed successfully."
5}

Commands

CommandDescription
merge search-tools <intent>Semantic search for tools by natural language
merge execute-tool <tool> <params>Execute a tool with JSON parameters
merge list-toolsList all available tools (compact by default)
merge get-tool-schema <tool>Get the input schema for a specific tool
merge configureInteractive credential setup
merge setup <target>Generate AI agent config (claude-code, cursor, agents-md)
merge updateSelf-update to latest version

Key Options

  • --connector <slug>: Filter search or list results by connector (e.g., slack, jira, github)
  • --no-schema: Omit input schemas from search results to reduce context size
  • --full: Include full schemas when listing tools
  • --max-results <n>: Limit number of search results (default: 2, max: 50)

Configuration

Credentials are resolved in this priority order (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:

1{
2 "agent_handler": {
3 "api_key": "pk_...",
4 "tool_pack_id": "your-tool-pack-uuid",
5 "registered_user_id": "your-registered-user-id"
6 }
7}

Using with AI Agents

The CLI outputs structured JSON to stdout with hint fields that guide agents on next steps. Warnings go to stderr so they never contaminate the JSON output.

The fastest way to configure your AI agent is the merge setup command:

Claude Code

$merge setup claude-code

This automatically:

  • Appends merge CLI workflow instructions to your CLAUDE.md (creates it if it doesn’t exist)
  • Adds Bash(merge *) permission 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.

Agent Workflow

Once configured, your agent follows this workflow:

  1. merge search-tools "<intent>" — find the right tool
  2. merge get-tool-schema <tool> — get its input parameters
  3. merge execute-tool <tool> '<json_params>' — execute with JSON params

Output Format

All commands return JSON with a consistent structure.

Success:

1{
2 "result": { ... },
3 "status": "success",
4 "hint": "Tool executed successfully."
5}

Error:

1{
2 "result": null,
3 "status": "error",
4 "error_type": "api_error",
5 "message": "Description of what went wrong",
6 "hint": "Suggested next step"
7}

Troubleshooting

ErrorCauseSolution
config_errorMissing credentialsRun merge configure or set MERGE_AH_* environment variables
api_error (401)Invalid API keyVerify your key in the Merge dashboard. Test keys work with test users only
not_foundTool doesn’t existUse merge search-tools or merge list-tools to discover available tools
reauth_requiredConnector auth expiredRe-authenticate the connector in the Merge dashboard
billing_limit_reachedAccount limit hitUpgrade at the billing URL in the error response
network_errorConnection failedCheck your internet connection and --base-url setting

Keep your API key secure. Never commit it to version control. Use environment variables or merge configure to store credentials safely.