close-crm-cli 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # close-crm-cli
2
+
3
+ > Full-featured CLI and MCP server for the [Close CRM](https://close.com) platform. Every API endpoint available as a terminal command **and** as an MCP tool for AI agents.
4
+
5
+ ## Features
6
+
7
+ - **160+ commands** across 30 resource groups — full Close API coverage
8
+ - **MCP server built-in** — run `close mcp` to expose all commands as Claude/Cursor tools
9
+ - **JSON output** by default — pipe to `jq`, script freely, or feed directly to AI agents
10
+ - **Authentication** via env var, flag, or stored config (`close login`)
11
+ - **HTTP Basic Auth** — Close's native auth method, handled automatically
12
+ - **Pagination** — offset-based `_limit`/`_skip` pagination with `has_more`
13
+ - **Retry + rate limit handling** — automatic exponential backoff on 429/5xx
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install -g close-crm-cli
19
+ ```
20
+
21
+ Or use without installing:
22
+ ```bash
23
+ npx close-crm-cli leads list
24
+ ```
25
+
26
+ ## Authentication
27
+
28
+ Get your API key from **https://app.close.com/settings/api**
29
+
30
+ ```bash
31
+ # Option 1: Environment variable (recommended)
32
+ export CLOSE_API_KEY="your-api-key"
33
+
34
+ # Option 2: Interactive login (stores in ~/.close/config.json)
35
+ close login
36
+
37
+ # Option 3: Per-command flag
38
+ close leads list --api-key "your-api-key"
39
+ ```
40
+
41
+ ## Quick Start
42
+
43
+ ```bash
44
+ # Get your user profile
45
+ close users me
46
+
47
+ # List leads
48
+ close leads list
49
+
50
+ # Create a lead
51
+ close leads create --name "Acme Corp" --url "https://acme.com"
52
+
53
+ # Create a contact on a lead
54
+ close contacts create --lead-id lead_abc123 --name "Jane Doe" \
55
+ --emails '[{"email":"jane@acme.com","type":"office"}]'
56
+
57
+ # Log a call
58
+ close calls create --lead-id lead_abc123 --direction outbound --duration 900 \
59
+ --note "Discussed Q2 priorities"
60
+
61
+ # Create a follow-up task
62
+ close tasks create --lead-id lead_abc123 --text "Send proposal" \
63
+ --type email --due-date "2025-04-07T09:00:00"
64
+
65
+ # Move opportunity to next stage
66
+ close opportunities update oppo_abc123 --status-id "stat_demo_scheduled"
67
+ ```
68
+
69
+ ## Output Options
70
+
71
+ ```bash
72
+ # Default: compact JSON (machine-readable)
73
+ close leads list
74
+
75
+ # Pretty-printed JSON
76
+ close leads list --pretty
77
+
78
+ # Select specific fields
79
+ close leads list --fields id,display_name,status_label
80
+
81
+ # Suppress output (exit codes only: 0=success, 1=error)
82
+ close leads list --quiet
83
+ ```
84
+
85
+ ## Command Groups
86
+
87
+ | Group | Commands | Description |
88
+ |-------|----------|-------------|
89
+ | `leads` | list, get, create, update, delete, merge, search | CRM leads |
90
+ | `contacts` | list, get, create, update, delete | Contacts within leads |
91
+ | `opportunities` | list, get, create, update, delete | Pipeline opportunities |
92
+ | `tasks` | list, get, create, update, delete, bulk-update | Tasks & follow-ups |
93
+ | `activities` | list | Unified activity stream |
94
+ | `calls` | list, get, create, update, delete | Call logs |
95
+ | `notes` | list, get, create, update, delete | Notes |
96
+ | `emails` | list, get, create, update, delete | Email activities |
97
+ | `sms` | list, get, create, delete | SMS activities |
98
+ | `meetings` | list, get, update, delete | Meetings |
99
+ | `users` | me, list, get, availability | Users |
100
+ | `pipelines` | list, get, create, update, delete | Sales pipelines |
101
+ | `lead-statuses` | list, get, create, update, delete | Lead status labels |
102
+ | `opportunity-statuses` | list, get, create, update, delete | Pipeline stages |
103
+ | `custom-fields` | list/get/create/update/delete-{lead\|contact\|opportunity\|activity\|shared} | Custom fields |
104
+ | `webhooks` | list, get, create, update, delete | Webhook subscriptions |
105
+ | `sequences` | list, get, create, update, delete, subscribe, list-subscriptions | Outreach sequences |
106
+ | `email-templates` | list, get, create, update, delete, render | Email templates |
107
+ | `sms-templates` | list, get, create, update, delete | SMS templates |
108
+ | `smart-views` | list, get, create, update, delete | Saved views |
109
+ | `reports` | activity-metrics, activity-report, funnel | Analytics |
110
+ | `phone-numbers` | list, get, update, delete | Phone numbers |
111
+ | `connected-accounts` | list, get | Connected email accounts |
112
+ | `organizations` | get, update | Organization settings |
113
+ | `groups` | list, get, create, update, delete | User groups |
114
+ | `roles` | list, get | User roles |
115
+ | `exports` | list, get, create-lead, create-opportunity | Data exports |
116
+ | `unsubscribe` | list, add, delete | Email unsubscribe list |
117
+
118
+ ## MCP Server
119
+
120
+ Expose all commands as tools for Claude, Cursor, Windsurf, or any MCP-compatible AI:
121
+
122
+ ```bash
123
+ close mcp
124
+ ```
125
+
126
+ ### Claude Desktop / Cursor Configuration
127
+
128
+ Add to your MCP config (`~/.claude/config.json` or Cursor settings):
129
+
130
+ ```json
131
+ {
132
+ "mcpServers": {
133
+ "close": {
134
+ "command": "npx",
135
+ "args": ["close-crm-cli", "mcp"],
136
+ "env": {
137
+ "CLOSE_API_KEY": "your-api-key"
138
+ }
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ Or with a global install:
145
+
146
+ ```json
147
+ {
148
+ "mcpServers": {
149
+ "close": {
150
+ "command": "close",
151
+ "args": ["mcp"],
152
+ "env": {
153
+ "CLOSE_API_KEY": "your-api-key"
154
+ }
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ Once configured, Claude can call any Close CRM action directly. Example prompts:
161
+ - "List all leads with status Potential"
162
+ - "Create a new opportunity for Acme Corp worth $50k"
163
+ - "Log a 15-minute outbound call to lead_abc123"
164
+ - "Enroll Jane Doe in the Q1 follow-up sequence"
165
+ - "Show me this week's activity metrics"
166
+
167
+ ## Pagination
168
+
169
+ ```bash
170
+ # First page
171
+ close leads list --limit 50
172
+
173
+ # Next page
174
+ close leads list --limit 50 --skip 50
175
+ ```
176
+
177
+ ## Custom Fields
178
+
179
+ ```bash
180
+ # List available custom fields
181
+ close custom-fields list-lead
182
+
183
+ # Set custom fields on create/update
184
+ close leads create --name "Acme Corp" --custom '{"cf_budget":"500000","cf_industry":"SaaS"}'
185
+ close leads update lead_abc123 --custom '{"cf_stage":"Pilot"}'
186
+ ```
187
+
188
+ ## Advanced Search
189
+
190
+ ```bash
191
+ # Simple query string
192
+ close leads list --query "Acme"
193
+
194
+ # Advanced DSL via POST /data/search/
195
+ close leads search --query '{
196
+ "type": "and",
197
+ "queries": [
198
+ {"type":"field","field":{"type":"regular","field_name":"status_label"},"negate":false,"condition":{"type":"text","mode":"equals","value":"Potential"}}
199
+ ]
200
+ }' --limit 100
201
+ ```
202
+
203
+ ## Development
204
+
205
+ ```bash
206
+ git clone https://github.com/bcharleson/close-crm-cli
207
+ cd close-crm-cli
208
+ npm install
209
+
210
+ # Run in dev mode
211
+ npm run dev -- leads list
212
+
213
+ # Build
214
+ npm run build
215
+
216
+ # Type check
217
+ npm run typecheck
218
+ ```
219
+
220
+ ## Architecture
221
+
222
+ The CLI is built on a `CommandDefinition` pattern — one object per API endpoint that serves as the single source of truth for both the CLI subcommand and the MCP tool:
223
+
224
+ ```typescript
225
+ interface CommandDefinition {
226
+ name: string; // MCP tool name (e.g. "leads_create")
227
+ group: string; // CLI group (e.g. "leads")
228
+ subcommand: string; // CLI subcommand (e.g. "create")
229
+ description: string; // Used in --help and MCP tool description
230
+ inputSchema: ZodObject; // Shared input validation
231
+ cliMappings: CliMapping; // How fields map to CLI args/options
232
+ endpoint: { method, path }; // HTTP endpoint
233
+ fieldMappings: Record<string, 'path'|'query'|'body'>; // Where fields go
234
+ handler: Function; // Executes the request
235
+ }
236
+ ```
237
+
238
+ See [AGENTS.md](AGENTS.md) for the full AI agent integration guide.
239
+
240
+ ## License
241
+
242
+ MIT