@nicolasmondain/cli-agent 3.0.2 → 3.0.4

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 (2) hide show
  1. package/README.md +40 -111
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -2,20 +2,35 @@
2
2
 
3
3
  > Turn your scripts into AI-powered tools
4
4
 
5
- cli-agent is an MCP server that lets AI assistants like Claude execute your scripts through natural language.
5
+ `cli-agent` is an MCP server that lets AI assistants execute your scripts (JavaScript, TypeScript, or shell) through natural language.
6
+
7
+ ## Why cli-agent?
8
+
9
+ `cli-agent` turns your scripts into AI-powered tools without writing MCP boilerplate. Instead of manually registering each script as an MCP tool with its own schema, argument parsing, and error handling, you define them once in a simple JSON config (and both CLI and MCP interfaces are generated automatically). The more scripts you have, the more time you save: one config file replaces dozens of lines of repetitive TypeScript per command.
6
10
 
7
11
  ## How it works
8
12
 
9
13
  1. You define your scripts in `.cli-agent.json`
10
- 2. cli-agent exposes them as MCP tools
11
- 3. Claude understands what they do and runs them when needed
14
+ 2. `cli-agent` exposes them as MCP tools
15
+ 3. Your AI assistant understands what they do and runs them when needed
16
+
17
+ ```mermaid
18
+ graph TD
19
+ subgraph User
20
+ A[AI assistant, deploy to staging]
21
+ end
22
+
23
+ subgraph MCP_cli-agent[MCP cli-agent]
24
+ B[matches intent]
25
+ C[run the script]
26
+ end
27
+
28
+ D[results]
29
+
30
+ A --> B
31
+ B --> C
32
+ C --> D
12
33
 
13
- ```
14
- User: "Deploy to staging"
15
-
16
- Claude matches intent → deploy --env staging
17
-
18
- Your script runs → Result returned to Claude
19
34
  ```
20
35
 
21
36
  ## Quick Start
@@ -23,44 +38,48 @@ Your script runs → Result returned to Claude
23
38
  ### 1. Install
24
39
 
25
40
  ```bash
26
- npm install -g @nicolasmondain/cli-agent
41
+ npm install -d @nicolasmondain/cli-agent
27
42
  ```
28
-
29
43
  ### 2. Create `.cli-agent.json`
44
+ `cli-agent` looks for configuration in this order:
45
+
46
+ 1. `--config <path>` flag
47
+ 2. `.cli-agent.json` in current directory (prefered)
48
+ 3. `cli-agent` field in `package.json`
49
+ 4. `~/.cli-agent.json` (global)
30
50
 
31
51
  ```json
32
52
  {
33
53
  "name": "cli-agent",
34
54
  "commands": [
35
55
  {
36
- "name": "deploy",
37
- "description": "Deploy the app to staging or production",
38
- "script": "./scripts/deploy.sh",
56
+ "name": "command-name",
57
+ "description": "What this command does (helps AI assistants understand when to use it) by giving clear descriptions of arguments and options. You can also provide examples of usage.",
58
+ "script": "./path/to/script.js",
59
+ "arguments": [
60
+ { "name": "arg", "description": "Positional argument", "required": true }
61
+ ],
39
62
  "options": [
40
- { "flags": "-e, --env <env>", "choices": ["staging", "production"] }
63
+ { "flags": "-o, --option <value>", "description": "Named option", "default": "value" }
41
64
  ]
42
65
  }
43
66
  ]
44
67
  }
45
68
  ```
46
69
 
47
- ### 3. Configure Claude Code
48
-
49
- Add to your Claude Code MCP settings: `.claude/mcp.json`
70
+ ### 3. Configure your MCP settings
50
71
 
51
72
  ```json
52
73
  {
53
74
  "mcpServers": {
54
75
  "cli-agent": {
55
76
  "command": "npx",
56
- "args": ["cli-agent", "mcp:serve"]
77
+ "args": ["@nicolasmondain/cli-agent", "mcp:serve"]
57
78
  }
58
79
  }
59
80
  }
60
81
  ```
61
82
 
62
- For Zed, add to your settings:
63
-
64
83
  ```json
65
84
  {
66
85
  "context_servers": {
@@ -72,72 +91,6 @@ For Zed, add to your settings:
72
91
  }
73
92
  ```
74
93
 
75
- Done. Claude can now run your scripts.
76
-
77
- ## Writing Scripts
78
-
79
- Scripts can be JavaScript, TypeScript, or shell scripts.
80
-
81
- ### JavaScript (.js)
82
-
83
- ```javascript
84
- export default async function(context) {
85
- const env = context.options.env;
86
- // your logic here
87
- return { success: true, message: `Deployed to ${env}` };
88
- }
89
- ```
90
-
91
- ### TypeScript (.ts)
92
-
93
- ```typescript
94
- import type { ScriptContext, CommandResult } from '@nicolasmondain/cli-agent';
95
-
96
- export default async function(context: ScriptContext): Promise<CommandResult> {
97
- const env = context.options.env as string;
98
- return { success: true, message: `Deployed to ${env}` };
99
- }
100
- ```
101
-
102
- ### Shell (.sh)
103
-
104
- ```bash
105
- #!/bin/bash
106
- ENV="${CLI_AGENT_OPT_ENV}"
107
- echo "Deploying to $ENV..."
108
- echo '{"success": true}'
109
- ```
110
-
111
- ## Configuration
112
-
113
- ```json
114
- {
115
- "name": "cli-agent",
116
- "commands": [
117
- {
118
- "name": "command-name",
119
- "description": "What this command does (helps Claude understand when to use it)",
120
- "script": "./path/to/script.js",
121
- "arguments": [
122
- { "name": "arg", "description": "Positional argument", "required": true }
123
- ],
124
- "options": [
125
- { "flags": "-o, --option <value>", "description": "Named option", "default": "value" }
126
- ]
127
- }
128
- ]
129
- }
130
- ```
131
-
132
- ### Configuration locations
133
-
134
- cli-agent looks for configuration in this order:
135
-
136
- 1. `--config <path>` flag
137
- 2. `.cli-agent.json` in current directory
138
- 3. `cli-agent` field in `package.json`
139
- 4. `~/.cli-agent.json` (global)
140
-
141
94
  ## CLI Usage
142
95
 
143
96
  ```bash
@@ -154,30 +107,6 @@ cli-agent deploy --env staging
154
107
  cli-agent deploy --env staging --format json
155
108
  ```
156
109
 
157
- ## Script Context
158
-
159
- Scripts receive a context object with:
160
-
161
- ```typescript
162
- interface ScriptContext {
163
- args: Record<string, unknown>; // Positional arguments
164
- options: Record<string, unknown>; // Named options
165
- cwd: string; // Current working directory
166
- format: 'human' | 'json'; // Output format
167
- }
168
- ```
169
-
170
- Scripts must return:
171
-
172
- ```typescript
173
- interface CommandResult {
174
- success: boolean;
175
- message?: string; // Human-readable message
176
- data?: unknown; // Structured data
177
- error?: string; // Error message if success is false
178
- }
179
- ```
180
-
181
110
  ## License
182
111
 
183
112
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nicolasmondain/cli-agent",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "MCP server that turns your scripts into AI-powered tools for Claude and other AI assistants",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",