merge-api 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. merge_api-0.1.0/LICENSE +21 -0
  2. merge_api-0.1.0/PKG-INFO +244 -0
  3. merge_api-0.1.0/README.md +213 -0
  4. merge_api-0.1.0/merge_api.egg-info/PKG-INFO +244 -0
  5. merge_api-0.1.0/merge_api.egg-info/SOURCES.txt +35 -0
  6. merge_api-0.1.0/merge_api.egg-info/dependency_links.txt +1 -0
  7. merge_api-0.1.0/merge_api.egg-info/entry_points.txt +2 -0
  8. merge_api-0.1.0/merge_api.egg-info/requires.txt +8 -0
  9. merge_api-0.1.0/merge_api.egg-info/top_level.txt +1 -0
  10. merge_api-0.1.0/merge_cli/__init__.py +3 -0
  11. merge_api-0.1.0/merge_cli/cli.py +76 -0
  12. merge_api-0.1.0/merge_cli/client.py +214 -0
  13. merge_api-0.1.0/merge_cli/commands/__init__.py +0 -0
  14. merge_api-0.1.0/merge_cli/commands/configure.py +48 -0
  15. merge_api-0.1.0/merge_cli/commands/execute_tool.py +72 -0
  16. merge_api-0.1.0/merge_cli/commands/get_tool_schema.py +69 -0
  17. merge_api-0.1.0/merge_cli/commands/list_tools.py +72 -0
  18. merge_api-0.1.0/merge_cli/commands/search_tools.py +92 -0
  19. merge_api-0.1.0/merge_cli/commands/setup.py +183 -0
  20. merge_api-0.1.0/merge_cli/commands/update.py +41 -0
  21. merge_api-0.1.0/merge_cli/common.py +26 -0
  22. merge_api-0.1.0/merge_cli/config.py +85 -0
  23. merge_api-0.1.0/merge_cli/output.py +39 -0
  24. merge_api-0.1.0/merge_cli/py.typed +0 -0
  25. merge_api-0.1.0/merge_cli/version_check.py +58 -0
  26. merge_api-0.1.0/pyproject.toml +61 -0
  27. merge_api-0.1.0/setup.cfg +4 -0
  28. merge_api-0.1.0/tests/test_client.py +241 -0
  29. merge_api-0.1.0/tests/test_config.py +119 -0
  30. merge_api-0.1.0/tests/test_configure.py +52 -0
  31. merge_api-0.1.0/tests/test_execute_tool.py +148 -0
  32. merge_api-0.1.0/tests/test_get_tool_schema.py +102 -0
  33. merge_api-0.1.0/tests/test_list_tools.py +124 -0
  34. merge_api-0.1.0/tests/test_output.py +49 -0
  35. merge_api-0.1.0/tests/test_search_tools.py +147 -0
  36. merge_api-0.1.0/tests/test_update.py +26 -0
  37. merge_api-0.1.0/tests/test_version_check.py +105 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Merge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.4
2
+ Name: merge-api
3
+ Version: 0.1.0
4
+ Summary: CLI for Merge Agent Handler — search, discover, and execute tools from 122+ connectors
5
+ Author-email: Merge <support@merge.dev>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://merge.dev
8
+ Project-URL: Documentation, https://docs.merge.dev/merge-agent-handler/implementation-guides/merge-cli
9
+ Project-URL: Repository, https://github.com/merge-api/merge-cli
10
+ Project-URL: Bug Tracker, https://github.com/merge-api/merge-cli/issues
11
+ Project-URL: Changelog, https://github.com/merge-api/merge-cli/blob/main/CHANGELOG.md
12
+ Keywords: merge,cli,agent-handler,mcp,tools
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: click>=8.0
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: python-dotenv>=1.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: pytest-httpx>=0.30; extra == "dev"
29
+ Requires-Dist: ruff>=0.4; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ [![PyPI version](https://img.shields.io/pypi/v/merge-api.svg)](https://pypi.org/project/merge-api/)
33
+ [![Python versions](https://img.shields.io/pypi/pyversions/merge-api.svg)](https://pypi.org/project/merge-api/)
34
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
35
+
36
+ # merge-cli
37
+
38
+ CLI for [Merge Agent Handler](https://merge.dev) — search, discover, and execute tools from hundreds of connectors.
39
+
40
+ Designed for AI agents (Claude Code, Cursor) that need progressive tool discovery without clogging the context window.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pipx install merge-api # recommended (isolated env)
46
+ pip install merge-api # alternative
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ### 1. Configure credentials
52
+
53
+ ```bash
54
+ merge configure
55
+ ```
56
+
57
+ Or set environment variables:
58
+
59
+ ```bash
60
+ export MERGE_AH_API_KEY="pk_..."
61
+ export MERGE_AH_TOOL_PACK_ID="your-tool-pack-uuid"
62
+ export MERGE_AH_REGISTERED_USER_ID="your-registered-user-id"
63
+ ```
64
+
65
+ ### 2. Search for tools
66
+
67
+ ```bash
68
+ merge search-tools "send a Slack message"
69
+ ```
70
+
71
+ ```json
72
+ {
73
+ "tools": [
74
+ {
75
+ "name": "slack__post_message",
76
+ "description": "Post a message to a Slack channel",
77
+ "input_schema": { "type": "object", "properties": { "channel": { "type": "string" }, "text": { "type": "string" } } },
78
+ }
79
+ ],
80
+ "total_results": 1,
81
+ "hint": "To execute: merge execute-tool <tool_name> '<json_params>'"
82
+ }
83
+ ```
84
+
85
+ ### 3. Get a tool's input schema
86
+
87
+ ```bash
88
+ merge get-tool-schema slack__post_message
89
+ ```
90
+
91
+ ### 4. Execute a tool
92
+
93
+ ```bash
94
+ merge execute-tool slack__post_message '{"input": {"channel": "#general", "text": "Hello!"}}'
95
+ ```
96
+
97
+ ```json
98
+ {
99
+ "result": { "ok": true, "ts": "1234567890.123456" },
100
+ "status": "success",
101
+ "hint": "Tool executed successfully."
102
+ }
103
+ ```
104
+
105
+ ## Commands
106
+
107
+ | Command | Description |
108
+ |---|---|
109
+ | `merge search-tools <intent>` | Semantic search for tools by natural language |
110
+ | `merge execute-tool <tool> <params>` | Execute a tool with JSON parameters |
111
+ | `merge list-tools` | List all available tools (compact by default) |
112
+ | `merge get-tool-schema <tool>` | Get the input schema for a specific tool |
113
+ | `merge configure` | Interactive credential setup |
114
+ | `merge setup <target>` | Generate AI agent config (claude-code, cursor, agents-md) |
115
+ | `merge update` | Self-update to latest version |
116
+
117
+ ### Common Options
118
+
119
+ All API commands accept these flags:
120
+
121
+ | Flag | Env Variable | Description |
122
+ |---|---|---|
123
+ | `--api-key` | `MERGE_AH_API_KEY` | API key |
124
+ | `--tool-pack-id` | `MERGE_AH_TOOL_PACK_ID` | Tool pack ID |
125
+ | `--registered-user-id` | `MERGE_AH_REGISTERED_USER_ID` | Registered user ID |
126
+
127
+ | `--base-url` | `MERGE_AH_BASE_URL` | Base URL override |
128
+
129
+ ## Configuration
130
+
131
+ Priority (highest to lowest):
132
+
133
+ 1. **CLI flags**: `--api-key`, `--tool-pack-id`, `--registered-user-id`, `--base-url`
134
+ 2. **Environment variables**: `MERGE_AH_API_KEY`, `MERGE_AH_TOOL_PACK_ID`, `MERGE_AH_REGISTERED_USER_ID`, `MERGE_AH_BASE_URL`
135
+ 3. **Config file**: `~/.merge/config.json`
136
+
137
+ Example config file:
138
+
139
+ ```json
140
+ {
141
+ "agent_handler": {
142
+ "api_key": "pk_...",
143
+ "tool_pack_id": "your-tool-pack-uuid",
144
+ "registered_user_id": "your-registered-user-id",
145
+ "base_url": "https://ah-api.merge.dev"
146
+ }
147
+ }
148
+ ```
149
+
150
+ ## Output Format
151
+
152
+ All commands output JSON to stdout. Warnings go to stderr.
153
+
154
+ **Success response:**
155
+
156
+ ```json
157
+ {
158
+ "result": { ... },
159
+ "status": "success",
160
+ "hint": "Tool executed successfully."
161
+ }
162
+ ```
163
+
164
+ **Error response:**
165
+
166
+ ```json
167
+ {
168
+ "result": null,
169
+ "status": "error",
170
+ "error_type": "api_error",
171
+ "message": "Description of what went wrong",
172
+ "hint": "Suggested next step"
173
+ }
174
+ ```
175
+
176
+ Error types: `config_error`, `api_error`, `network_error`, `invalid_params`, `not_found`, `reauth_required`, `billing_limit_reached`
177
+
178
+ ## Usage with AI Agents
179
+
180
+ The fastest way to set up any AI agent is the `merge setup` command:
181
+
182
+ ### Claude Code
183
+
184
+ ```bash
185
+ merge setup claude-code
186
+ ```
187
+
188
+ 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.
189
+
190
+ ### Cursor
191
+
192
+ ```bash
193
+ merge setup cursor
194
+ ```
195
+
196
+ This appends merge CLI instructions to your `.cursorrules` (or creates it if it doesn't exist).
197
+
198
+ ### Any AI Agent (AGENTS.md)
199
+
200
+ ```bash
201
+ merge setup agents-md
202
+ ```
203
+
204
+ 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.
205
+
206
+ ### Manual Setup
207
+
208
+ If you prefer manual configuration, add this to your agent's system prompt or project instructions:
209
+
210
+ ```
211
+ For any task involving third-party services (Slack, Jira, GitHub, Salesforce, etc.),
212
+ use the `merge` CLI. Do not call APIs directly.
213
+
214
+ Workflow:
215
+ 1. merge search-tools "<intent>" — find the right tool
216
+ 2. merge get-tool-schema <tool> — get its input parameters
217
+ 3. merge execute-tool <tool> '<json_params>' — execute with JSON params
218
+ ```
219
+
220
+ ## Troubleshooting
221
+
222
+ | Problem | Solution |
223
+ |---|---|
224
+ | `config_error` | Run `merge configure` or set `MERGE_AH_*` environment variables |
225
+ | `api_error` with 401 | Check your API key. Ensure test keys are used with test users and production keys with production users |
226
+ | `not_found` | Use `merge search-tools <intent>` or `merge list-tools` to discover available tools |
227
+ | `reauth_required` | The user needs to re-authenticate the connector in the Merge dashboard |
228
+ | `billing_limit_reached` | Upgrade the account at the billing URL in the error response |
229
+ | `network_error` | Check your internet connection and `--base-url` setting |
230
+
231
+ ## Development
232
+
233
+ ```bash
234
+ git clone https://github.com/merge-api/merge-cli.git
235
+ cd merge-cli
236
+ pip install -e ".[dev]"
237
+ pytest # run tests
238
+ ruff check . # lint
239
+ ruff format --check . # format check
240
+ ```
241
+
242
+ ## License
243
+
244
+ [MIT](LICENSE)
@@ -0,0 +1,213 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/merge-api.svg)](https://pypi.org/project/merge-api/)
2
+ [![Python versions](https://img.shields.io/pypi/pyversions/merge-api.svg)](https://pypi.org/project/merge-api/)
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
4
+
5
+ # merge-cli
6
+
7
+ CLI for [Merge Agent Handler](https://merge.dev) — search, discover, and execute tools from hundreds of connectors.
8
+
9
+ Designed for AI agents (Claude Code, Cursor) that need progressive tool discovery without clogging the context window.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pipx install merge-api # recommended (isolated env)
15
+ pip install merge-api # alternative
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ### 1. Configure credentials
21
+
22
+ ```bash
23
+ merge configure
24
+ ```
25
+
26
+ Or set environment variables:
27
+
28
+ ```bash
29
+ export MERGE_AH_API_KEY="pk_..."
30
+ export MERGE_AH_TOOL_PACK_ID="your-tool-pack-uuid"
31
+ export MERGE_AH_REGISTERED_USER_ID="your-registered-user-id"
32
+ ```
33
+
34
+ ### 2. Search for tools
35
+
36
+ ```bash
37
+ merge search-tools "send a Slack message"
38
+ ```
39
+
40
+ ```json
41
+ {
42
+ "tools": [
43
+ {
44
+ "name": "slack__post_message",
45
+ "description": "Post a message to a Slack channel",
46
+ "input_schema": { "type": "object", "properties": { "channel": { "type": "string" }, "text": { "type": "string" } } },
47
+ }
48
+ ],
49
+ "total_results": 1,
50
+ "hint": "To execute: merge execute-tool <tool_name> '<json_params>'"
51
+ }
52
+ ```
53
+
54
+ ### 3. Get a tool's input schema
55
+
56
+ ```bash
57
+ merge get-tool-schema slack__post_message
58
+ ```
59
+
60
+ ### 4. Execute a tool
61
+
62
+ ```bash
63
+ merge execute-tool slack__post_message '{"input": {"channel": "#general", "text": "Hello!"}}'
64
+ ```
65
+
66
+ ```json
67
+ {
68
+ "result": { "ok": true, "ts": "1234567890.123456" },
69
+ "status": "success",
70
+ "hint": "Tool executed successfully."
71
+ }
72
+ ```
73
+
74
+ ## Commands
75
+
76
+ | Command | Description |
77
+ |---|---|
78
+ | `merge search-tools <intent>` | Semantic search for tools by natural language |
79
+ | `merge execute-tool <tool> <params>` | Execute a tool with JSON parameters |
80
+ | `merge list-tools` | List all available tools (compact by default) |
81
+ | `merge get-tool-schema <tool>` | Get the input schema for a specific tool |
82
+ | `merge configure` | Interactive credential setup |
83
+ | `merge setup <target>` | Generate AI agent config (claude-code, cursor, agents-md) |
84
+ | `merge update` | Self-update to latest version |
85
+
86
+ ### Common Options
87
+
88
+ All API commands accept these flags:
89
+
90
+ | Flag | Env Variable | Description |
91
+ |---|---|---|
92
+ | `--api-key` | `MERGE_AH_API_KEY` | API key |
93
+ | `--tool-pack-id` | `MERGE_AH_TOOL_PACK_ID` | Tool pack ID |
94
+ | `--registered-user-id` | `MERGE_AH_REGISTERED_USER_ID` | Registered user ID |
95
+
96
+ | `--base-url` | `MERGE_AH_BASE_URL` | Base URL override |
97
+
98
+ ## Configuration
99
+
100
+ Priority (highest to lowest):
101
+
102
+ 1. **CLI flags**: `--api-key`, `--tool-pack-id`, `--registered-user-id`, `--base-url`
103
+ 2. **Environment variables**: `MERGE_AH_API_KEY`, `MERGE_AH_TOOL_PACK_ID`, `MERGE_AH_REGISTERED_USER_ID`, `MERGE_AH_BASE_URL`
104
+ 3. **Config file**: `~/.merge/config.json`
105
+
106
+ Example config file:
107
+
108
+ ```json
109
+ {
110
+ "agent_handler": {
111
+ "api_key": "pk_...",
112
+ "tool_pack_id": "your-tool-pack-uuid",
113
+ "registered_user_id": "your-registered-user-id",
114
+ "base_url": "https://ah-api.merge.dev"
115
+ }
116
+ }
117
+ ```
118
+
119
+ ## Output Format
120
+
121
+ All commands output JSON to stdout. Warnings go to stderr.
122
+
123
+ **Success response:**
124
+
125
+ ```json
126
+ {
127
+ "result": { ... },
128
+ "status": "success",
129
+ "hint": "Tool executed successfully."
130
+ }
131
+ ```
132
+
133
+ **Error response:**
134
+
135
+ ```json
136
+ {
137
+ "result": null,
138
+ "status": "error",
139
+ "error_type": "api_error",
140
+ "message": "Description of what went wrong",
141
+ "hint": "Suggested next step"
142
+ }
143
+ ```
144
+
145
+ Error types: `config_error`, `api_error`, `network_error`, `invalid_params`, `not_found`, `reauth_required`, `billing_limit_reached`
146
+
147
+ ## Usage with AI Agents
148
+
149
+ The fastest way to set up any AI agent is the `merge setup` command:
150
+
151
+ ### Claude Code
152
+
153
+ ```bash
154
+ merge setup claude-code
155
+ ```
156
+
157
+ 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.
158
+
159
+ ### Cursor
160
+
161
+ ```bash
162
+ merge setup cursor
163
+ ```
164
+
165
+ This appends merge CLI instructions to your `.cursorrules` (or creates it if it doesn't exist).
166
+
167
+ ### Any AI Agent (AGENTS.md)
168
+
169
+ ```bash
170
+ merge setup agents-md
171
+ ```
172
+
173
+ 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.
174
+
175
+ ### Manual Setup
176
+
177
+ If you prefer manual configuration, add this to your agent's system prompt or project instructions:
178
+
179
+ ```
180
+ For any task involving third-party services (Slack, Jira, GitHub, Salesforce, etc.),
181
+ use the `merge` CLI. Do not call APIs directly.
182
+
183
+ Workflow:
184
+ 1. merge search-tools "<intent>" — find the right tool
185
+ 2. merge get-tool-schema <tool> — get its input parameters
186
+ 3. merge execute-tool <tool> '<json_params>' — execute with JSON params
187
+ ```
188
+
189
+ ## Troubleshooting
190
+
191
+ | Problem | Solution |
192
+ |---|---|
193
+ | `config_error` | Run `merge configure` or set `MERGE_AH_*` environment variables |
194
+ | `api_error` with 401 | Check your API key. Ensure test keys are used with test users and production keys with production users |
195
+ | `not_found` | Use `merge search-tools <intent>` or `merge list-tools` to discover available tools |
196
+ | `reauth_required` | The user needs to re-authenticate the connector in the Merge dashboard |
197
+ | `billing_limit_reached` | Upgrade the account at the billing URL in the error response |
198
+ | `network_error` | Check your internet connection and `--base-url` setting |
199
+
200
+ ## Development
201
+
202
+ ```bash
203
+ git clone https://github.com/merge-api/merge-cli.git
204
+ cd merge-cli
205
+ pip install -e ".[dev]"
206
+ pytest # run tests
207
+ ruff check . # lint
208
+ ruff format --check . # format check
209
+ ```
210
+
211
+ ## License
212
+
213
+ [MIT](LICENSE)