docstar-cli 0.0.0 → 1.0.1
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 +65 -414
- package/dist/commands/init.js +8 -1
- package/dist/commands/mcp.d.ts +6 -0
- package/dist/commands/mcp.js +56 -0
- package/dist/lib/types.d.ts +5 -0
- package/oclif.manifest.json +8 -35
- package/package.json +4 -2
- package/dist/commands/slack/list.js +0 -20
- package/dist/commands/slack/send-message-1.js +0 -30
package/README.md
CHANGED
|
@@ -1,456 +1,107 @@
|
|
|
1
|
-
docstar-cli
|
|
2
|
-
=================
|
|
1
|
+
# docstar-cli
|
|
3
2
|
|
|
4
|
-
A
|
|
3
|
+
A CLI for calling published DocStar API endpoints directly from your terminal, without leaving the shell to read docs. Point it at a DocStar docs site, pick which modules (e.g. "Slack") you want, and it turns each published endpoint into a real command you can run.
|
|
5
4
|
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<!-- toc -->
|
|
13
|
-
* [Usage](#usage)
|
|
14
|
-
* [Commands](#commands)
|
|
15
|
-
<!-- tocstop -->
|
|
16
|
-
# Usage
|
|
17
|
-
<!-- usage -->
|
|
18
|
-
```sh-session
|
|
19
|
-
$ npm install -g docstar-cli
|
|
20
|
-
$ docstar-cli COMMAND
|
|
21
|
-
running command...
|
|
22
|
-
$ docstar-cli (--version)
|
|
23
|
-
docstar-cli/0.0.0 darwin-arm64 node-v22.22.3
|
|
24
|
-
$ docstar-cli --help [COMMAND]
|
|
25
|
-
USAGE
|
|
26
|
-
$ docstar-cli COMMAND
|
|
27
|
-
...
|
|
28
|
-
```
|
|
29
|
-
<!-- usagestop -->
|
|
30
|
-
# Commands
|
|
31
|
-
<!-- commands -->
|
|
32
|
-
* [`docstar-cli hello PERSON`](#docstar-cli-hello-person)
|
|
33
|
-
* [`docstar-cli hello world`](#docstar-cli-hello-world)
|
|
34
|
-
* [`docstar-cli help [COMMAND]`](#docstar-cli-help-command)
|
|
35
|
-
* [`docstar-cli init DOMAIN`](#docstar-cli-init-domain)
|
|
36
|
-
* [`docstar-cli plugins`](#docstar-cli-plugins)
|
|
37
|
-
* [`docstar-cli plugins add PLUGIN`](#docstar-cli-plugins-add-plugin)
|
|
38
|
-
* [`docstar-cli plugins:inspect PLUGIN...`](#docstar-cli-pluginsinspect-plugin)
|
|
39
|
-
* [`docstar-cli plugins install PLUGIN`](#docstar-cli-plugins-install-plugin)
|
|
40
|
-
* [`docstar-cli plugins link PATH`](#docstar-cli-plugins-link-path)
|
|
41
|
-
* [`docstar-cli plugins remove [PLUGIN]`](#docstar-cli-plugins-remove-plugin)
|
|
42
|
-
* [`docstar-cli plugins reset`](#docstar-cli-plugins-reset)
|
|
43
|
-
* [`docstar-cli plugins uninstall [PLUGIN]`](#docstar-cli-plugins-uninstall-plugin)
|
|
44
|
-
* [`docstar-cli plugins unlink [PLUGIN]`](#docstar-cli-plugins-unlink-plugin)
|
|
45
|
-
* [`docstar-cli plugins update`](#docstar-cli-plugins-update)
|
|
46
|
-
* [`docstar-cli slack list`](#docstar-cli-slack-list)
|
|
47
|
-
* [`docstar-cli slack send-message-1`](#docstar-cli-slack-send-message-1)
|
|
48
|
-
|
|
49
|
-
## `docstar-cli hello PERSON`
|
|
50
|
-
|
|
51
|
-
Say hello
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
USAGE
|
|
55
|
-
$ docstar-cli hello PERSON -f <value>
|
|
56
|
-
|
|
57
|
-
ARGUMENTS
|
|
58
|
-
PERSON Person to say hello to
|
|
59
|
-
|
|
60
|
-
FLAGS
|
|
61
|
-
-f, --from=<value> (required) Who is saying hello
|
|
62
|
-
|
|
63
|
-
DESCRIPTION
|
|
64
|
-
Say hello
|
|
65
|
-
|
|
66
|
-
EXAMPLES
|
|
67
|
-
$ docstar-cli hello friend --from oclif
|
|
68
|
-
hello friend from oclif! (./src/commands/hello/index.ts)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
_See code: [src/commands/hello/index.ts](https://github.com/swayammaheshwari/docstar-cli/blob/v0.0.0/src/commands/hello/index.ts)_
|
|
72
|
-
|
|
73
|
-
## `docstar-cli hello world`
|
|
74
|
-
|
|
75
|
-
Say hello world
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
USAGE
|
|
79
|
-
$ docstar-cli hello world
|
|
80
|
-
|
|
81
|
-
DESCRIPTION
|
|
82
|
-
Say hello world
|
|
83
|
-
|
|
84
|
-
EXAMPLES
|
|
85
|
-
$ docstar-cli hello world
|
|
86
|
-
hello world! (./src/commands/hello/world.ts)
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
_See code: [src/commands/hello/world.ts](https://github.com/swayammaheshwari/docstar-cli/blob/v0.0.0/src/commands/hello/world.ts)_
|
|
90
|
-
|
|
91
|
-
## `docstar-cli help [COMMAND]`
|
|
92
|
-
|
|
93
|
-
Display help for docstar-cli.
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
USAGE
|
|
97
|
-
$ docstar-cli help [COMMAND...] [-n]
|
|
98
|
-
|
|
99
|
-
ARGUMENTS
|
|
100
|
-
[COMMAND...] Command to show help for.
|
|
101
|
-
|
|
102
|
-
FLAGS
|
|
103
|
-
-n, --nested-commands Include all nested commands in the output.
|
|
104
|
-
|
|
105
|
-
DESCRIPTION
|
|
106
|
-
Display help for docstar-cli.
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.58/src/commands/help.ts)_
|
|
110
|
-
|
|
111
|
-
## `docstar-cli init DOMAIN`
|
|
112
|
-
|
|
113
|
-
Discover published modules for a DocStar docs site, pick which ones to install, and register their CLI commands
|
|
114
|
-
|
|
115
|
-
```
|
|
116
|
-
USAGE
|
|
117
|
-
$ docstar-cli init DOMAIN [--collectionId <value>]
|
|
118
|
-
|
|
119
|
-
ARGUMENTS
|
|
120
|
-
DOMAIN DocStar docs domain, e.g. docs.msg91.com or localhost:3000
|
|
121
|
-
|
|
122
|
-
FLAGS
|
|
123
|
-
--collectionId=<value> Collection id (required when the domain is not a custom domain, e.g. localhost)
|
|
124
|
-
|
|
125
|
-
DESCRIPTION
|
|
126
|
-
Discover published modules for a DocStar docs site, pick which ones to install, and register their CLI commands
|
|
127
|
-
|
|
128
|
-
EXAMPLES
|
|
129
|
-
$ docstar-cli init docs.msg91.com
|
|
130
|
-
|
|
131
|
-
$ docstar-cli init localhost:3000 --collectionId paM4R4A26Hvb
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
_See code: [src/commands/init.ts](https://github.com/swayammaheshwari/docstar-cli/blob/v0.0.0/src/commands/init.ts)_
|
|
135
|
-
|
|
136
|
-
## `docstar-cli plugins`
|
|
137
|
-
|
|
138
|
-
List installed plugins.
|
|
139
|
-
|
|
140
|
-
```
|
|
141
|
-
USAGE
|
|
142
|
-
$ docstar-cli plugins [--json] [--core]
|
|
143
|
-
|
|
144
|
-
FLAGS
|
|
145
|
-
--core Show core plugins.
|
|
146
|
-
|
|
147
|
-
GLOBAL FLAGS
|
|
148
|
-
--json Format output as json.
|
|
149
|
-
|
|
150
|
-
DESCRIPTION
|
|
151
|
-
List installed plugins.
|
|
152
|
-
|
|
153
|
-
EXAMPLES
|
|
154
|
-
$ docstar-cli plugins
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.87/src/commands/plugins/index.ts)_
|
|
158
|
-
|
|
159
|
-
## `docstar-cli plugins add PLUGIN`
|
|
160
|
-
|
|
161
|
-
Installs a plugin into docstar-cli.
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
USAGE
|
|
165
|
-
$ docstar-cli plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
166
|
-
|
|
167
|
-
ARGUMENTS
|
|
168
|
-
PLUGIN... Plugin to install.
|
|
169
|
-
|
|
170
|
-
FLAGS
|
|
171
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
172
|
-
-h, --help Show CLI help.
|
|
173
|
-
-s, --silent Silences npm output.
|
|
174
|
-
-v, --verbose Show verbose npm output.
|
|
175
|
-
|
|
176
|
-
GLOBAL FLAGS
|
|
177
|
-
--json Format output as json.
|
|
178
|
-
|
|
179
|
-
DESCRIPTION
|
|
180
|
-
Installs a plugin into docstar-cli.
|
|
181
|
-
|
|
182
|
-
Uses npm to install plugins.
|
|
183
|
-
|
|
184
|
-
Installation of a user-installed plugin will override a core plugin.
|
|
185
|
-
|
|
186
|
-
Use the DOCSTAR_CLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
|
|
187
|
-
Use the DOCSTAR_CLI_NPM_REGISTRY environment variable to set the npm registry.
|
|
188
|
-
|
|
189
|
-
ALIASES
|
|
190
|
-
$ docstar-cli plugins add
|
|
191
|
-
|
|
192
|
-
EXAMPLES
|
|
193
|
-
Install a plugin from npm registry.
|
|
194
|
-
|
|
195
|
-
$ docstar-cli plugins add myplugin
|
|
196
|
-
|
|
197
|
-
Install a plugin from a github url.
|
|
198
|
-
|
|
199
|
-
$ docstar-cli plugins add https://github.com/someuser/someplugin
|
|
200
|
-
|
|
201
|
-
Install a plugin from a github slug.
|
|
202
|
-
|
|
203
|
-
$ docstar-cli plugins add someuser/someplugin
|
|
7
|
+
```sh
|
|
8
|
+
npm install
|
|
9
|
+
npm run build
|
|
10
|
+
npm link
|
|
204
11
|
```
|
|
205
12
|
|
|
206
|
-
|
|
13
|
+
`npm link` puts `docstar-cli` on your PATH. Alternatively, run it without linking via `node ./bin/run.js <command>` from the repo root.
|
|
207
14
|
|
|
208
|
-
|
|
15
|
+
## Quick start
|
|
209
16
|
|
|
210
|
-
|
|
211
|
-
USAGE
|
|
212
|
-
$ docstar-cli plugins inspect PLUGIN...
|
|
213
|
-
|
|
214
|
-
ARGUMENTS
|
|
215
|
-
PLUGIN... [default: .] Plugin to inspect.
|
|
216
|
-
|
|
217
|
-
FLAGS
|
|
218
|
-
-h, --help Show CLI help.
|
|
219
|
-
-v, --verbose
|
|
220
|
-
|
|
221
|
-
GLOBAL FLAGS
|
|
222
|
-
--json Format output as json.
|
|
223
|
-
|
|
224
|
-
DESCRIPTION
|
|
225
|
-
Displays installation properties of a plugin.
|
|
17
|
+
### 1. Discover and install modules
|
|
226
18
|
|
|
227
|
-
|
|
228
|
-
|
|
19
|
+
```sh
|
|
20
|
+
docstar-cli init docs.msg91.com
|
|
229
21
|
```
|
|
230
22
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
## `docstar-cli plugins install PLUGIN`
|
|
234
|
-
|
|
235
|
-
Installs a plugin into docstar-cli.
|
|
23
|
+
For a local/non-custom-domain docs site, pass the collection id explicitly:
|
|
236
24
|
|
|
25
|
+
```sh
|
|
26
|
+
docstar-cli init localhost:3000 --collectionId paM4R4A26Hvb
|
|
237
27
|
```
|
|
238
|
-
USAGE
|
|
239
|
-
$ docstar-cli plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
|
|
240
|
-
|
|
241
|
-
ARGUMENTS
|
|
242
|
-
PLUGIN... Plugin to install.
|
|
243
|
-
|
|
244
|
-
FLAGS
|
|
245
|
-
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
|
|
246
|
-
-h, --help Show CLI help.
|
|
247
|
-
-s, --silent Silences npm output.
|
|
248
|
-
-v, --verbose Show verbose npm output.
|
|
249
28
|
|
|
250
|
-
|
|
251
|
-
--json Format output as json.
|
|
29
|
+
This fetches the list of published modules for that site, shows an interactive checklist (all modules pre-checked — press `space` to toggle, `enter` to confirm), and for each selected module:
|
|
252
30
|
|
|
253
|
-
|
|
254
|
-
|
|
31
|
+
- saves its full endpoint contract to `~/.docstar/modules/<module>.json`
|
|
32
|
+
- registers a real CLI command for every endpoint in that module
|
|
33
|
+
- registers a `<module> list` command
|
|
255
34
|
|
|
256
|
-
|
|
35
|
+
Overall settings (domain, collection, installed modules) are saved to `~/.docstar/config.json`.
|
|
257
36
|
|
|
258
|
-
|
|
37
|
+
### 2. See what's available in a module
|
|
259
38
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
ALIASES
|
|
264
|
-
$ docstar-cli plugins add
|
|
265
|
-
|
|
266
|
-
EXAMPLES
|
|
267
|
-
Install a plugin from npm registry.
|
|
268
|
-
|
|
269
|
-
$ docstar-cli plugins install myplugin
|
|
270
|
-
|
|
271
|
-
Install a plugin from a github url.
|
|
272
|
-
|
|
273
|
-
$ docstar-cli plugins install https://github.com/someuser/someplugin
|
|
274
|
-
|
|
275
|
-
Install a plugin from a github slug.
|
|
276
|
-
|
|
277
|
-
$ docstar-cli plugins install someuser/someplugin
|
|
39
|
+
```sh
|
|
40
|
+
docstar-cli slack list
|
|
278
41
|
```
|
|
279
42
|
|
|
280
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.87/src/commands/plugins/install.ts)_
|
|
281
|
-
|
|
282
|
-
## `docstar-cli plugins link PATH`
|
|
283
|
-
|
|
284
|
-
Links a plugin into the CLI for development.
|
|
285
|
-
|
|
286
|
-
```
|
|
287
|
-
USAGE
|
|
288
|
-
$ docstar-cli plugins link PATH [-h] [--install] [-v]
|
|
289
|
-
|
|
290
|
-
ARGUMENTS
|
|
291
|
-
PATH [default: .] path to plugin
|
|
292
|
-
|
|
293
|
-
FLAGS
|
|
294
|
-
-h, --help Show CLI help.
|
|
295
|
-
-v, --verbose
|
|
296
|
-
--[no-]install Install dependencies after linking the plugin.
|
|
297
|
-
|
|
298
|
-
DESCRIPTION
|
|
299
|
-
Links a plugin into the CLI for development.
|
|
300
|
-
|
|
301
|
-
Installation of a linked plugin will override a user-installed or core plugin.
|
|
302
|
-
|
|
303
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
304
|
-
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
EXAMPLES
|
|
308
|
-
$ docstar-cli plugins link myplugin
|
|
309
43
|
```
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
Removes a plugin from the CLI.
|
|
316
|
-
|
|
317
|
-
```
|
|
318
|
-
USAGE
|
|
319
|
-
$ docstar-cli plugins remove [PLUGIN...] [-h] [-v]
|
|
320
|
-
|
|
321
|
-
ARGUMENTS
|
|
322
|
-
[PLUGIN...] plugin to uninstall
|
|
323
|
-
|
|
324
|
-
FLAGS
|
|
325
|
-
-h, --help Show CLI help.
|
|
326
|
-
-v, --verbose
|
|
327
|
-
|
|
328
|
-
DESCRIPTION
|
|
329
|
-
Removes a plugin from the CLI.
|
|
330
|
-
|
|
331
|
-
ALIASES
|
|
332
|
-
$ docstar-cli plugins unlink
|
|
333
|
-
$ docstar-cli plugins remove
|
|
334
|
-
|
|
335
|
-
EXAMPLES
|
|
336
|
-
$ docstar-cli plugins remove myplugin
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
## `docstar-cli plugins reset`
|
|
340
|
-
|
|
341
|
-
Remove all user-installed and linked plugins.
|
|
342
|
-
|
|
343
|
-
```
|
|
344
|
-
USAGE
|
|
345
|
-
$ docstar-cli plugins reset [--hard] [--reinstall]
|
|
346
|
-
|
|
347
|
-
FLAGS
|
|
348
|
-
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
|
|
349
|
-
--reinstall Reinstall all plugins after uninstalling.
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/5.4.87/src/commands/plugins/reset.ts)_
|
|
353
|
-
|
|
354
|
-
## `docstar-cli plugins uninstall [PLUGIN]`
|
|
355
|
-
|
|
356
|
-
Removes a plugin from the CLI.
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
USAGE
|
|
360
|
-
$ docstar-cli plugins uninstall [PLUGIN...] [-h] [-v]
|
|
361
|
-
|
|
362
|
-
ARGUMENTS
|
|
363
|
-
[PLUGIN...] plugin to uninstall
|
|
364
|
-
|
|
365
|
-
FLAGS
|
|
366
|
-
-h, --help Show CLI help.
|
|
367
|
-
-v, --verbose
|
|
368
|
-
|
|
369
|
-
DESCRIPTION
|
|
370
|
-
Removes a plugin from the CLI.
|
|
371
|
-
|
|
372
|
-
ALIASES
|
|
373
|
-
$ docstar-cli plugins unlink
|
|
374
|
-
$ docstar-cli plugins remove
|
|
375
|
-
|
|
376
|
-
EXAMPLES
|
|
377
|
-
$ docstar-cli plugins uninstall myplugin
|
|
44
|
+
send-message-1
|
|
45
|
+
send message
|
|
46
|
+
POST
|
|
47
|
+
required: MY_SECRET_KEY
|
|
378
48
|
```
|
|
379
49
|
|
|
380
|
-
|
|
50
|
+
### 3. Call an endpoint
|
|
381
51
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
Removes a plugin from the CLI.
|
|
52
|
+
Pass required parameters as flags:
|
|
385
53
|
|
|
54
|
+
```sh
|
|
55
|
+
docstar-cli slack send-message-1 --MY_SECRET_KEY "hello from the CLI"
|
|
386
56
|
```
|
|
387
|
-
USAGE
|
|
388
|
-
$ docstar-cli plugins unlink [PLUGIN...] [-h] [-v]
|
|
389
|
-
|
|
390
|
-
ARGUMENTS
|
|
391
|
-
[PLUGIN...] plugin to uninstall
|
|
392
57
|
|
|
393
|
-
|
|
394
|
-
-h, --help Show CLI help.
|
|
395
|
-
-v, --verbose
|
|
58
|
+
Or omit them and answer the prompts instead:
|
|
396
59
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
ALIASES
|
|
401
|
-
$ docstar-cli plugins unlink
|
|
402
|
-
$ docstar-cli plugins remove
|
|
403
|
-
|
|
404
|
-
EXAMPLES
|
|
405
|
-
$ docstar-cli plugins unlink myplugin
|
|
60
|
+
```sh
|
|
61
|
+
docstar-cli slack send-message-1
|
|
62
|
+
? Enter value for MY_SECRET_KEY
|
|
406
63
|
```
|
|
407
64
|
|
|
408
|
-
|
|
65
|
+
The command prints the response status and body from the actual API call.
|
|
409
66
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
```
|
|
413
|
-
USAGE
|
|
414
|
-
$ docstar-cli plugins update [-h] [-v]
|
|
67
|
+
## Use from an AI client (MCP)
|
|
415
68
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
-v, --verbose
|
|
69
|
+
`docstar-cli` can run as an [MCP](https://modelcontextprotocol.io) server, turning every installed
|
|
70
|
+
endpoint into a proper tool an AI client can call directly — no shell access required.
|
|
419
71
|
|
|
420
|
-
|
|
421
|
-
|
|
72
|
+
```sh
|
|
73
|
+
docstar-cli mcp
|
|
422
74
|
```
|
|
423
75
|
|
|
424
|
-
|
|
76
|
+
Register it with Claude Code (`.mcp.json`) or Claude Desktop (`claude_desktop_config.json`):
|
|
425
77
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
List installed APIs for the slack module
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"docstar": {
|
|
82
|
+
"command": "docstar-cli",
|
|
83
|
+
"args": ["mcp"]
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
436
87
|
```
|
|
437
88
|
|
|
438
|
-
|
|
89
|
+
Each installed endpoint becomes one tool named `<module>__<command>` (e.g. `slack__send-message-1`),
|
|
90
|
+
with required/optional parameters exposed in its schema. A prompt like "call the slack api and
|
|
91
|
+
send a message saying hi" resolves directly to that tool call — the AI client asks you for any
|
|
92
|
+
required value it can't infer, exactly like any other MCP tool. Run `docstar-cli init` first so
|
|
93
|
+
there's at least one installed module for `mcp` to expose.
|
|
439
94
|
|
|
440
|
-
##
|
|
95
|
+
## How it works
|
|
441
96
|
|
|
442
|
-
|
|
97
|
+
- `docstar-cli init` talks to `GET /p/module.json?collectionId=...` (list of modules) and `GET /p/<module>/module.json?collectionId=...` (a module's endpoint contract) on the docs site.
|
|
98
|
+
- Each endpoint's contract (method, url, base url, headers, body, and CLI parameter names) is saved locally and used to build the real HTTP request when you run its command — no network round-trip to the docs site is needed to run a command once a module is installed.
|
|
99
|
+
- Commands are generated as real files on disk under this repo's `dist/commands/<module>/`, which is why `npm run build` (it wipes `dist/`) requires re-running `docstar-cli init` afterwards to reinstall your modules.
|
|
443
100
|
|
|
444
|
-
|
|
445
|
-
USAGE
|
|
446
|
-
$ docstar-cli slack send-message-1 [--MY_SECRET_KEY <value>]
|
|
447
|
-
|
|
448
|
-
FLAGS
|
|
449
|
-
--MY_SECRET_KEY=<value> Required parameter
|
|
101
|
+
## Development
|
|
450
102
|
|
|
451
|
-
|
|
452
|
-
|
|
103
|
+
```sh
|
|
104
|
+
npm run build # compile TypeScript to dist/
|
|
105
|
+
npm run lint # eslint
|
|
106
|
+
npm test # mocha
|
|
453
107
|
```
|
|
454
|
-
|
|
455
|
-
_See code: [src/commands/slack/send-message-1.ts](https://github.com/swayammaheshwari/docstar-cli/blob/v0.0.0/src/commands/slack/send-message-1.ts)_
|
|
456
|
-
<!-- commandsstop -->
|
package/dist/commands/init.js
CHANGED
|
@@ -40,7 +40,14 @@ export default class Init extends Command {
|
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
const selectedPaths = await checkbox({
|
|
43
|
-
choices: listResponse.modules.map((module) =>
|
|
43
|
+
choices: listResponse.modules.map((module) => {
|
|
44
|
+
const count = module.endpointCount ?? module.endpoints?.length ?? 0;
|
|
45
|
+
return {
|
|
46
|
+
checked: true,
|
|
47
|
+
name: `${module.name} (${module.path}) — ${count} endpoint${count === 1 ? '' : 's'}`,
|
|
48
|
+
value: module.path,
|
|
49
|
+
};
|
|
50
|
+
}),
|
|
44
51
|
message: 'Select modules to install (space to toggle, enter to confirm)',
|
|
45
52
|
});
|
|
46
53
|
if (selectedPaths.length === 0) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { executeCliCommand, loadModule } from '../lib/http.js';
|
|
7
|
+
import { configPath } from '../lib/paths.js';
|
|
8
|
+
const sanitize = (value) => value.replaceAll(/[^a-zA-Z0-9_-]/g, '_');
|
|
9
|
+
const buildInputShape = (required, optional) => {
|
|
10
|
+
const shape = {};
|
|
11
|
+
for (const name of required)
|
|
12
|
+
shape[name] = z.string().describe(`Required parameter: ${name}`);
|
|
13
|
+
for (const name of optional)
|
|
14
|
+
shape[name] = z.string().optional().describe(`Optional parameter: ${name}`);
|
|
15
|
+
return shape;
|
|
16
|
+
};
|
|
17
|
+
export default class Mcp extends Command {
|
|
18
|
+
static description = 'Start an MCP server exposing every installed endpoint as a tool for AI clients (Claude Desktop, Claude Code, etc.)';
|
|
19
|
+
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
20
|
+
async run() {
|
|
21
|
+
let savedConfig;
|
|
22
|
+
try {
|
|
23
|
+
savedConfig = JSON.parse(await readFile(configPath(), 'utf8'));
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
this.error('No installed modules found. Run `docstar-cli init <domain>` first.');
|
|
27
|
+
}
|
|
28
|
+
const server = new McpServer({ name: 'docstar-cli', version: '1.0.0' });
|
|
29
|
+
let toolCount = 0;
|
|
30
|
+
for (const module of savedConfig.modules) {
|
|
31
|
+
// eslint-disable-next-line no-await-in-loop
|
|
32
|
+
const moduleJson = await loadModule(module.path);
|
|
33
|
+
for (const endpoint of moduleJson.endpoints) {
|
|
34
|
+
const { cli } = endpoint;
|
|
35
|
+
const toolName = sanitize(`${module.path}__${cli.command.name}`);
|
|
36
|
+
const description = cli.description || `${cli.command.name} (${module.path})`;
|
|
37
|
+
const inputShape = buildInputShape(cli.parameters.required, cli.parameters.optional);
|
|
38
|
+
server.tool(toolName, description, inputShape, async (args) => {
|
|
39
|
+
try {
|
|
40
|
+
const result = await executeCliCommand(module.path, cli.command.name, args);
|
|
41
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return { content: [{ type: 'text', text: error.message }], isError: true };
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
toolCount++;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (toolCount === 0) {
|
|
51
|
+
this.error('No installed endpoints found. Run `docstar-cli init <domain>` and select at least one module first.');
|
|
52
|
+
}
|
|
53
|
+
const transport = new StdioServerTransport();
|
|
54
|
+
await server.connect(transport);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/lib/types.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -38,43 +38,17 @@
|
|
|
38
38
|
"init.js"
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
|
-
"
|
|
41
|
+
"mcp": {
|
|
42
42
|
"aliases": [],
|
|
43
43
|
"args": {},
|
|
44
|
-
"description": "
|
|
44
|
+
"description": "Start an MCP server exposing every installed endpoint as a tool for AI clients (Claude Desktop, Claude Code, etc.)",
|
|
45
|
+
"examples": [
|
|
46
|
+
"<%= config.bin %> <%= command.id %>"
|
|
47
|
+
],
|
|
45
48
|
"flags": {},
|
|
46
49
|
"hasDynamicHelp": false,
|
|
47
50
|
"hiddenAliases": [],
|
|
48
|
-
"id": "
|
|
49
|
-
"pluginAlias": "docstar-cli",
|
|
50
|
-
"pluginName": "docstar-cli",
|
|
51
|
-
"pluginType": "core",
|
|
52
|
-
"strict": true,
|
|
53
|
-
"enableJsonFlag": false,
|
|
54
|
-
"isESM": true,
|
|
55
|
-
"relativePath": [
|
|
56
|
-
"dist",
|
|
57
|
-
"commands",
|
|
58
|
-
"slack",
|
|
59
|
-
"list.js"
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
"slack:send-message-1": {
|
|
63
|
-
"aliases": [],
|
|
64
|
-
"args": {},
|
|
65
|
-
"description": "send message",
|
|
66
|
-
"flags": {
|
|
67
|
-
"MY_SECRET_KEY": {
|
|
68
|
-
"description": "Required parameter",
|
|
69
|
-
"name": "MY_SECRET_KEY",
|
|
70
|
-
"hasDynamicHelp": false,
|
|
71
|
-
"multiple": false,
|
|
72
|
-
"type": "option"
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"hasDynamicHelp": false,
|
|
76
|
-
"hiddenAliases": [],
|
|
77
|
-
"id": "slack:send-message-1",
|
|
51
|
+
"id": "mcp",
|
|
78
52
|
"pluginAlias": "docstar-cli",
|
|
79
53
|
"pluginName": "docstar-cli",
|
|
80
54
|
"pluginType": "core",
|
|
@@ -84,8 +58,7 @@
|
|
|
84
58
|
"relativePath": [
|
|
85
59
|
"dist",
|
|
86
60
|
"commands",
|
|
87
|
-
"
|
|
88
|
-
"send-message-1.js"
|
|
61
|
+
"mcp.js"
|
|
89
62
|
]
|
|
90
63
|
},
|
|
91
64
|
"hello": {
|
|
@@ -153,5 +126,5 @@
|
|
|
153
126
|
]
|
|
154
127
|
}
|
|
155
128
|
},
|
|
156
|
-
"version": "
|
|
129
|
+
"version": "1.0.1"
|
|
157
130
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docstar-cli",
|
|
3
3
|
"description": "A new CLI generated with oclif",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"author": "Swayam Maheshwari",
|
|
6
6
|
"bin": {
|
|
7
7
|
"docstar-cli": "./bin/run.js"
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
"bugs": "https://github.com/swayammaheshwari/docstar-cli/issues",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@inquirer/prompts": "^8.5.2",
|
|
12
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
12
13
|
"@oclif/core": "^4",
|
|
13
14
|
"@oclif/plugin-help": "^6",
|
|
14
|
-
"@oclif/plugin-plugins": "^5"
|
|
15
|
+
"@oclif/plugin-plugins": "^5",
|
|
16
|
+
"zod": "^4.4.3"
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
17
19
|
"@eslint/compat": "^1",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {Command} from '@oclif/core'
|
|
2
|
-
import {loadModule} from '../../lib/http.js'
|
|
3
|
-
|
|
4
|
-
export default class GeneratedList extends Command {
|
|
5
|
-
static description = 'List installed APIs for the slack module'
|
|
6
|
-
|
|
7
|
-
async run() {
|
|
8
|
-
const moduleJson = await loadModule('slack')
|
|
9
|
-
|
|
10
|
-
for (const endpoint of moduleJson.endpoints) {
|
|
11
|
-
const {cli} = endpoint
|
|
12
|
-
this.log(`${cli.command.name}${cli.command.aliases.filter((alias) => alias !== cli.command.name).length > 0 ? ` (aliases: ${cli.command.aliases.filter((alias) => alias !== cli.command.name).join(', ')})` : ''}`)
|
|
13
|
-
if (cli.description) this.log(` ${cli.description}`)
|
|
14
|
-
this.log(` ${endpoint.method}`)
|
|
15
|
-
if (cli.parameters.required.length > 0) this.log(` required: ${cli.parameters.required.join(', ')}`)
|
|
16
|
-
if (cli.parameters.optional.length > 0) this.log(` optional: ${cli.parameters.optional.join(', ')}`)
|
|
17
|
-
this.log('')
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import {Command, Flags} from '@oclif/core'
|
|
2
|
-
import {executeCliCommand} from '../../lib/http.js'
|
|
3
|
-
import {promptForMissingParams} from '../../lib/prompt.js'
|
|
4
|
-
|
|
5
|
-
const REQUIRED_PARAMS = ["MY_SECRET_KEY"]
|
|
6
|
-
|
|
7
|
-
export default class Generated extends Command {
|
|
8
|
-
static description = "send message"
|
|
9
|
-
static aliases = []
|
|
10
|
-
static flags = {
|
|
11
|
-
'MY_SECRET_KEY': Flags.string({description: 'Required parameter'}),
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async run() {
|
|
15
|
-
const {flags} = await this.parse(Generated)
|
|
16
|
-
const params = {}
|
|
17
|
-
for (const [key, value] of Object.entries(flags)) {
|
|
18
|
-
if (value !== undefined) params[key] = value
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
Object.assign(params, await promptForMissingParams(REQUIRED_PARAMS, params))
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const result = await executeCliCommand('slack', 'send-message-1', params)
|
|
25
|
-
this.log(JSON.stringify(result, null, 2))
|
|
26
|
-
} catch (error) {
|
|
27
|
-
this.error(error.message)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|