@qodalis/cli-server-node 1.0.0-beta.6 → 1.0.0-beta.8
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 +227 -2
- package/dist/package.json +77 -0
- package/dist/src/abstractions/index.d.ts +1 -1
- package/dist/src/abstractions/index.d.ts.map +1 -1
- package/dist/src/abstractions/index.js +6 -1
- package/dist/src/abstractions/index.js.map +1 -1
- package/dist/src/auth/cli-server-auth-gate.d.ts +2 -0
- package/dist/src/auth/cli-server-auth-gate.d.ts.map +1 -1
- package/dist/src/auth/cli-server-auth-gate.js +3 -0
- package/dist/src/auth/cli-server-auth-gate.js.map +1 -1
- package/dist/src/auth/cli-server-auth.d.ts +2 -0
- package/dist/src/auth/cli-server-auth.d.ts.map +1 -1
- package/dist/src/auth/cli-server-auth.js.map +1 -1
- package/dist/src/create-cli-server.d.ts +26 -0
- package/dist/src/create-cli-server.d.ts.map +1 -1
- package/dist/src/create-cli-server.js +77 -2
- package/dist/src/create-cli-server.js.map +1 -1
- package/dist/src/extensions/cli-builder.d.ts +10 -0
- package/dist/src/extensions/cli-builder.d.ts.map +1 -1
- package/dist/src/extensions/cli-builder.js +14 -0
- package/dist/src/extensions/cli-builder.js.map +1 -1
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +28 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts +10 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +34 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/mcp-controller.d.ts +54 -0
- package/dist/src/mcp/mcp-controller.d.ts.map +1 -0
- package/dist/src/mcp/mcp-controller.js +358 -0
- package/dist/src/mcp/mcp-controller.js.map +1 -0
- package/dist/src/mcp/mcp-render.d.ts +10 -0
- package/dist/src/mcp/mcp-render.d.ts.map +1 -0
- package/dist/src/mcp/mcp-render.js +66 -0
- package/dist/src/mcp/mcp-render.js.map +1 -0
- package/dist/src/mcp/mcp-schema.d.ts +8 -0
- package/dist/src/mcp/mcp-schema.d.ts.map +1 -0
- package/dist/src/mcp/mcp-schema.js +64 -0
- package/dist/src/mcp/mcp-schema.js.map +1 -0
- package/dist/src/mcp/mcp-types.d.ts +70 -0
- package/dist/src/mcp/mcp-types.d.ts.map +1 -0
- package/dist/src/mcp/mcp-types.js +21 -0
- package/dist/src/mcp/mcp-types.js.map +1 -0
- package/dist/src/mcp/providers/commands-provider.d.ts +30 -0
- package/dist/src/mcp/providers/commands-provider.d.ts.map +1 -0
- package/dist/src/mcp/providers/commands-provider.js +145 -0
- package/dist/src/mcp/providers/commands-provider.js.map +1 -0
- package/dist/src/mcp/providers/data-explorer-provider.d.ts +15 -0
- package/dist/src/mcp/providers/data-explorer-provider.d.ts.map +1 -0
- package/dist/src/mcp/providers/data-explorer-provider.js +83 -0
- package/dist/src/mcp/providers/data-explorer-provider.js.map +1 -0
- package/dist/src/mcp/providers/filesystem-provider.d.ts +15 -0
- package/dist/src/mcp/providers/filesystem-provider.d.ts.map +1 -0
- package/dist/src/mcp/providers/filesystem-provider.js +166 -0
- package/dist/src/mcp/providers/filesystem-provider.js.map +1 -0
- package/dist/src/mcp/providers/jobs-provider.d.ts +23 -0
- package/dist/src/mcp/providers/jobs-provider.d.ts.map +1 -0
- package/dist/src/mcp/providers/jobs-provider.js +121 -0
- package/dist/src/mcp/providers/jobs-provider.js.map +1 -0
- package/dist/src/mcp/providers/server-provider.d.ts +19 -0
- package/dist/src/mcp/providers/server-provider.d.ts.map +1 -0
- package/dist/src/mcp/providers/server-provider.js +73 -0
- package/dist/src/mcp/providers/server-provider.js.map +1 -0
- package/dist/src/processors/cli-base64-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-base64-command-processor.js +5 -2
- package/dist/src/processors/cli-base64-command-processor.js.map +1 -1
- package/dist/src/processors/cli-echo-command-processor.d.ts +2 -1
- package/dist/src/processors/cli-echo-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-echo-command-processor.js +8 -3
- package/dist/src/processors/cli-echo-command-processor.js.map +1 -1
- package/dist/src/processors/cli-hash-command-processor.d.ts +1 -0
- package/dist/src/processors/cli-hash-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-hash-command-processor.js +3 -1
- package/dist/src/processors/cli-hash-command-processor.js.map +1 -1
- package/dist/src/processors/cli-http-command-processor.d.ts.map +1 -1
- package/dist/src/processors/cli-http-command-processor.js +7 -4
- package/dist/src/processors/cli-http-command-processor.js.map +1 -1
- package/dist/src/processors/index.d.ts +1 -1
- package/dist/src/processors/index.d.ts.map +1 -1
- package/dist/src/processors/index.js +2 -1
- package/dist/src/processors/index.js.map +1 -1
- package/dist/src/services/session-bound-sockets.d.ts +1 -1
- package/dist/src/services/session-bound-sockets.d.ts.map +1 -1
- package/dist/src/services/session-bound-sockets.js +2 -2
- package/dist/src/services/session-bound-sockets.js.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -294,12 +294,15 @@ Every processor receives a `CliProcessCommand` with the parsed command input:
|
|
|
294
294
|
| Property | Type | Description |
|
|
295
295
|
|----------|------|-------------|
|
|
296
296
|
| `command` | `string` | Command name (e.g., `"time"`) |
|
|
297
|
-
| `value` | `string \| undefined` | Positional
|
|
297
|
+
| `value` | `string \| undefined` | Positional text as typed, quotes included (e.g., `"hello"` in `echo hello`) |
|
|
298
|
+
| `positionals` | `string[] \| undefined` | Positional arguments split like a shell: quotes removed, backslash escapes applied (`base64 encode "a b"` -> `["a b"]`). Sent by newer browsers |
|
|
298
299
|
| `args` | `Record<string, any>` | Named parameters (e.g., `--format "HH:mm"`) |
|
|
299
300
|
| `chainCommands` | `string[]` | Sub-command chain (e.g., `["add"]` in `math add`) |
|
|
300
301
|
| `rawCommand` | `string` | Original unprocessed input |
|
|
301
302
|
| `data` | `any` | Arbitrary data payload from the client |
|
|
302
303
|
|
|
304
|
+
Read positional input with `getPositionals(command)` (a `string[]`) or `getPositionalText(command)` (joined by one space). Both use `positionals` when the browser sends it and otherwise split `value` with the same rules (`splitShellWords`), so quotes never leak into what a processor reads.
|
|
305
|
+
|
|
303
306
|
## API Endpoints
|
|
304
307
|
|
|
305
308
|
The server exposes versioned endpoints:
|
|
@@ -311,11 +314,227 @@ The server exposes versioned endpoints:
|
|
|
311
314
|
| GET | `/api/v1/qcli/commands` | V1 commands (all processors) |
|
|
312
315
|
| POST | `/api/v1/qcli/execute` | V1 execute |
|
|
313
316
|
| POST | `/api/v1/qcli/execute/stream` | V1 SSE streaming execute |
|
|
317
|
+
| POST | `/api/qcli/mcp` | MCP endpoint (when the `mcp` option is on, see [MCP Endpoint](#mcp-endpoint)) |
|
|
314
318
|
| WS | `/ws/qcli/events` | WebSocket events (also `/ws/v1/qcli/events`) |
|
|
315
319
|
| WS | `/ws/v1/qcli/shell` | Interactive PTY shell session |
|
|
316
320
|
|
|
317
321
|
`GET /capabilities` reports `shell: true|false` and, when the shell is enabled, `shellAuth: 'users' | 'token' | 'custom' | 'anonymous' | 'locked'`.
|
|
318
322
|
|
|
323
|
+
## MCP Endpoint
|
|
324
|
+
|
|
325
|
+
The server can expose **the whole system** to AI clients such as Claude Code over the [Model Context Protocol](https://modelcontextprotocol.io): CLI commands, the filesystem API, the data explorer, jobs and tools contributed by plugins, each with the same permissions as a CLI user. It works with or without the users plugin.
|
|
326
|
+
|
|
327
|
+
### Enabling
|
|
328
|
+
|
|
329
|
+
MCP is off by default. Enable it with the `mcp` option:
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
const { app, mcp } = createCliServer({
|
|
333
|
+
mcp: true, // or an options object:
|
|
334
|
+
// mcp: {
|
|
335
|
+
// tools: ['weather_*', 'echo'], // allow-list (trailing * = prefix); default: every tool
|
|
336
|
+
// exclude: ['fs_delete'], // deny-list, applied after `tools`
|
|
337
|
+
// token: process.env.MCP_TOKEN, // only WITHOUT an auth provider: required bearer token
|
|
338
|
+
// instructions: 'Each tool runs one command of this server.', // returned by initialize
|
|
339
|
+
// enabled: true, // default true when the object is given
|
|
340
|
+
// },
|
|
341
|
+
configure: (builder) => builder.addProcessor(new CliEchoCommandProcessor()),
|
|
342
|
+
});
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### Route and transport
|
|
346
|
+
|
|
347
|
+
- `POST /api/qcli/mcp` (`{basePath}/mcp`): MCP *Streamable HTTP*, **stateless** (no `Mcp-Session-Id`) and **JSON responses only** (no SSE). `GET`/`DELETE` → `405` with `Allow: POST`.
|
|
348
|
+
- JSON-RPC 2.0: notifications → `202` with an empty body; malformed JSON → `-32700`, invalid request (including batches) → `-32600`, unknown method → `-32601`, bad params → `-32602` (JSON-RPC errors use HTTP 200).
|
|
349
|
+
- Methods: `initialize` (protocol versions `2025-11-25`, `2025-06-18`, `2025-03-26`; the client's version is echoed when supported, otherwise the newest), `ping`, `tools/list`, `tools/call`.
|
|
350
|
+
- An `Origin` header, when present, must be in `allowedOrigins` or same-origin, otherwise `403` (DNS-rebinding protection; checked before authentication).
|
|
351
|
+
|
|
352
|
+
### Authentication
|
|
353
|
+
|
|
354
|
+
| Server | Access |
|
|
355
|
+
|---|---|
|
|
356
|
+
| users plugin mounted (`protectServer`) | a session or an [API token](plugins/users/README.md#api-tokens) (`Authorization: Bearer qcli_pat_…`) holding `commands:execute`; `401`/`403` as plain `{ "error": … }` responses. `tools/list` and `tools/call` only show the tools whose permissions the caller holds. `mcp.token` is ignored. |
|
|
357
|
+
| no auth provider, `mcp.token` set | `Authorization: Bearer <token>` (constant-time compare), else `401` |
|
|
358
|
+
| no auth provider, no token | open, like `/execute` |
|
|
359
|
+
|
|
360
|
+
### Tools
|
|
361
|
+
|
|
362
|
+
Tools are collected from **tool providers** on every request, so new registrations, enabled features and the caller's permissions are always current. The `tools`/`exclude` lists apply to every tool.
|
|
363
|
+
|
|
364
|
+
| Provider | Tools | Permissions | Annotations |
|
|
365
|
+
|---|---|---|---|
|
|
366
|
+
| server | `server_info` (version, capabilities, enabled features, command names) | — | read-only |
|
|
367
|
+
| commands | one tool per command (below) | `commands:execute` + `requiredPermissions` along the chain | — |
|
|
368
|
+
| filesystem (when a file storage provider is configured) | `fs_list {path}`, `fs_stat {path}`, `fs_read {path, maxBytes?=262144}` | `files:read` | read-only |
|
|
369
|
+
| | `fs_write {path, content}`, `fs_mkdir {path}` | `files:write` | — |
|
|
370
|
+
| | `fs_delete {path, recursive?=false}` | `files:write` | destructive |
|
|
371
|
+
| data explorer (when sources are registered) | `data_sources`, `data_schema {source}` | `data:query` | read-only |
|
|
372
|
+
| | `data_query {source, query, parameters?}` | `data:query` | — |
|
|
373
|
+
| jobs (when the jobs plugin is mounted) | `jobs_list`, `jobs_get {id}`, `jobs_history {id, limit?=20}` | `jobs:read` | read-only |
|
|
374
|
+
| | `jobs_trigger`, `jobs_pause`, `jobs_resume`, `jobs_stop`, `jobs_cancel` `{id}` | `jobs:manage` | `jobs_stop`/`jobs_cancel` destructive |
|
|
375
|
+
|
|
376
|
+
The jobs tools' `id` accepts a job id or a unique job name (exact, then case-insensitive; an ambiguous name is an error).
|
|
377
|
+
|
|
378
|
+
Feature tools use the same services as the HTTP routes (the storage provider and its path checks, the data explorer executor with its timeouts and row limits, the job scheduler); their errors become `isError: true` results. `fs_read` returns UTF-8 text (binary files → `isError` `binary file, N bytes`). Paths outside the provider's allow-list are rejected exactly as by `/api/qcli/fs` (symlinks are resolved first, so on macOS allow `/private/tmp` rather than `/tmp`).
|
|
379
|
+
|
|
380
|
+
**Command tools**: every root command and sub-command that has no sub-commands, declares parameters or takes a value (`valueRequired`, or `acceptsValue` for an optional one) becomes a tool named after its path joined with `_` (`weather`, `weather_current`), lower-cased, other characters than `[a-z0-9_-]` replaced by `-`, at most 64 characters. The input schema has one property per parameter (`string`, `number`, `boolean`, `array` of strings; anything else is a string) plus `value` (the positional input) when the command takes one: required with `valueRequired`, optional with `acceptsValue` (set it on processors that read `command.value` without requiring it; the built-in `hash`, `base64 encode|decode`, `http get|post` and the weather commands do). A call builds the same command the CLI would send and runs it through the **same executor as `/execute`**; the outputs are rendered as text (tables as `a | b` rows, lists one item per line, JSON pretty-printed, key-value as `key: value`), `isError` is `exitCode != 0`, and a single JSON-object output is also returned as `structuredContent`. Unknown tools and invalid arguments (wrong type, unknown or missing property) are JSON-RPC `-32602` errors.
|
|
381
|
+
|
|
382
|
+
Name collisions (a warning is logged): built-in feature tools win, then plugin/host provider tools in registration order, then command tools. The interactive shell is never a tool.
|
|
383
|
+
|
|
384
|
+
### Adding tools (providers)
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import { McpToolProvider, mcpObjectSchema } from '@qodalis/cli-server-node';
|
|
388
|
+
|
|
389
|
+
const provider: McpToolProvider = {
|
|
390
|
+
name: 'inventory',
|
|
391
|
+
getTools: () => [
|
|
392
|
+
{
|
|
393
|
+
name: 'inventory_count',
|
|
394
|
+
description: 'Count the items of a warehouse',
|
|
395
|
+
inputSchema: mcpObjectSchema({ warehouse: { type: 'string' } }, ['warehouse']),
|
|
396
|
+
requiredPermissions: ['inventory:read'], // checked for list and call (with an auth provider)
|
|
397
|
+
annotations: { readOnlyHint: true },
|
|
398
|
+
call: async (args, { auth, signal }) => ({ text: `42 items in ${args.warehouse}`, isError: false }),
|
|
399
|
+
},
|
|
400
|
+
],
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const server = createCliServer({ mcp: true });
|
|
404
|
+
server.mcp.addProvider(provider); // or builder.addMcpToolProvider(provider) in `configure`
|
|
405
|
+
// plugins can also return `mcpProviders: [provider]` from their build result (picked up by mountPlugin)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Arguments are validated against `inputSchema` before `call` runs. Return `structured` to also send `structuredContent`.
|
|
409
|
+
|
|
410
|
+
### Using the MCP endpoint from an MCP client
|
|
411
|
+
|
|
412
|
+
This guide connects [Claude Code](https://docs.claude.com/en/docs/claude-code) to a server. The commands use the demo server (`cd demo && npm start`: port 8047, users plugin, user `root` / password `admin`); replace the URL and credentials with yours.
|
|
413
|
+
|
|
414
|
+
#### 1. Enable MCP on the server
|
|
415
|
+
|
|
416
|
+
MCP is enabled with the `mcp` option of `createCliServer` (`mcp: true`, or an options object).
|
|
417
|
+
|
|
418
|
+
With the users plugin (sessions, permissions, API tokens):
|
|
419
|
+
|
|
420
|
+
```typescript
|
|
421
|
+
import { createCliServer, CliEchoCommandProcessor } from '@qodalis/cli-server-node';
|
|
422
|
+
import { CliUsersBuilder } from '@qodalis/cli-server-plugin-users';
|
|
423
|
+
|
|
424
|
+
const { app, eventSocketManager, mountPlugin } = createCliServer({
|
|
425
|
+
mcp: { instructions: 'Each tool runs one command of this server.' },
|
|
426
|
+
configure: (builder) => builder.addProcessor(new CliEchoCommandProcessor()),
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
const usersPlugin = new CliUsersBuilder()
|
|
430
|
+
.setDefaultAdminPassword('admin')
|
|
431
|
+
.build((msg) => eventSocketManager.broadcastMessage(msg));
|
|
432
|
+
mountPlugin(usersPlugin);
|
|
433
|
+
|
|
434
|
+
app.listen(8047);
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Without the users plugin, protect the endpoint with a static bearer token (without `token` it is as open as `/execute`):
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
const { app } = createCliServer({
|
|
441
|
+
mcp: { token: process.env.QCLI_MCP_TOKEN },
|
|
442
|
+
configure: (builder) => builder.addProcessor(new CliEchoCommandProcessor()),
|
|
443
|
+
});
|
|
444
|
+
app.listen(8047);
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
The endpoint is `http://localhost:8047/api/qcli/mcp` (`{basePath}/mcp`).
|
|
448
|
+
|
|
449
|
+
#### 2. Get a token
|
|
450
|
+
|
|
451
|
+
With the users plugin, sign in and create an API token with the session token (requires `jq`; otherwise copy the `token` field of each response):
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
SESSION=$(curl -s -X POST http://localhost:8047/api/v1/qcli/sessions \
|
|
455
|
+
-H "Content-Type: application/json" \
|
|
456
|
+
-d '{"username":"root","password":"admin"}' | jq -r .token)
|
|
457
|
+
|
|
458
|
+
TOKEN=$(curl -s -X POST http://localhost:8047/api/v1/qcli/tokens \
|
|
459
|
+
-H "Authorization: Bearer $SESSION" \
|
|
460
|
+
-H "Content-Type: application/json" \
|
|
461
|
+
-d '{"name":"claude","expiresInDays":30}' | jq -r .token)
|
|
462
|
+
|
|
463
|
+
echo "$TOKEN"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
The API token (`qcli_pat_…`) is shown only once. In the web CLI connected to the server, `token create claude` does the same. Add `"permissions": ["commands:execute", "files:read"]` to the body to give the token only part of your permissions; tokens are listed with `GET /api/v1/qcli/tokens` and revoked with `DELETE /api/v1/qcli/tokens/<id>` (see [API tokens](plugins/users/README.md#api-tokens)).
|
|
467
|
+
|
|
468
|
+
Without the users plugin, the token is the `mcp.token` value.
|
|
469
|
+
|
|
470
|
+
#### 3. Connect Claude Code
|
|
471
|
+
|
|
472
|
+
**(a) Directly over HTTP** with the token:
|
|
473
|
+
|
|
474
|
+
```bash
|
|
475
|
+
claude mcp add --transport http qcli http://localhost:8047/api/qcli/mcp --header "Authorization: Bearer <token>"
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**(b) Through the [`@qodalis/mcp-cli`](https://github.com/qodalis-solutions/mcp-cli) bridge**, a local MCP server configured with environment variables:
|
|
479
|
+
|
|
480
|
+
```bash
|
|
481
|
+
claude mcp add qcli -e QCLI_URL=http://localhost:8047 -e QCLI_TOKEN=<token> -- npx -y @qodalis/mcp-cli
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Use `QCLI_USER` / `QCLI_PASSWORD` instead of `QCLI_TOKEN` to sign in with a user, and `QCLI_READ_ONLY=true` to expose only read-only tools.
|
|
485
|
+
|
|
486
|
+
Check the connection with `claude mcp list` (or `/mcp` inside Claude Code); `qcli` should be listed as connected, with the tools of step 4.
|
|
487
|
+
|
|
488
|
+
#### 4. Check the endpoint with curl
|
|
489
|
+
|
|
490
|
+
Every request is one JSON-RPC message sent with `POST`; the server is stateless, so no session header is needed between calls.
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
# initialize
|
|
494
|
+
curl -s http://localhost:8047/api/qcli/mcp \
|
|
495
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
496
|
+
-H "Content-Type: application/json" \
|
|
497
|
+
-H "Accept: application/json, text/event-stream" \
|
|
498
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"1.0"}}}'
|
|
499
|
+
|
|
500
|
+
# list the tools
|
|
501
|
+
curl -s http://localhost:8047/api/qcli/mcp \
|
|
502
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
503
|
+
-H "Content-Type: application/json" \
|
|
504
|
+
-H "Accept: application/json, text/event-stream" \
|
|
505
|
+
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
|
|
506
|
+
|
|
507
|
+
# call a tool
|
|
508
|
+
curl -s http://localhost:8047/api/qcli/mcp \
|
|
509
|
+
-H "Authorization: Bearer $TOKEN" \
|
|
510
|
+
-H "Content-Type: application/json" \
|
|
511
|
+
-H "Accept: application/json, text/event-stream" \
|
|
512
|
+
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"echo","arguments":{"value":"hello from MCP"}}}'
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
Responses (shortened):
|
|
516
|
+
|
|
517
|
+
```json
|
|
518
|
+
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":false}},"serverInfo":{"name":"qodalis-cli-server","version":"1.0.0-beta.7"},"instructions":"…"}}
|
|
519
|
+
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"server_info","description":"…","inputSchema":{"type":"object","properties":{},"required":[],"additionalProperties":false},"annotations":{"readOnlyHint":true}},{"name":"echo", …}, …]}}
|
|
520
|
+
{"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"hello from MCP"}],"isError":false}}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
A failed command is a normal result with `"isError": true`; an unknown tool or invalid arguments is a JSON-RPC error (`-32602`).
|
|
524
|
+
|
|
525
|
+
#### 5. Troubleshooting
|
|
526
|
+
|
|
527
|
+
| Symptom | Cause and fix |
|
|
528
|
+
|---|---|
|
|
529
|
+
| `claude mcp list` / `/mcp` shows `qcli` as failed | Run the curl checks of step 4 with the same URL and token to see the HTTP error below. |
|
|
530
|
+
| `401 {"error":"unauthorized"}` or `{"error":"invalid or expired token"}` | No `Authorization: Bearer …` header, or the token is wrong, expired or revoked, or its user is disabled or deleted: create a new token (step 2). Without the users plugin, check `mcp.token`. |
|
|
531
|
+
| `403 {"error":"forbidden: origin not allowed"}` | The request has an `Origin` header that is neither in `allowedOrigins` nor the server's own origin (DNS-rebinding protection). Claude Code sends no `Origin`; for browser-based clients add the origin to `allowedOrigins`. |
|
|
532
|
+
| `403 {"error":"forbidden: missing permission commands:execute"}` | The user, or the token's scope, lacks `commands:execute`, which the endpoint requires. Add it to one of the user's groups, or create a token whose scope includes it. |
|
|
533
|
+
| `403 {"error":"password change required"}` | The user must change their password first. |
|
|
534
|
+
| `404` | MCP is not enabled (`mcp` option) or the URL is not `{basePath}/mcp`. |
|
|
535
|
+
| `405` with `Allow: POST` | The endpoint only accepts `POST` (MCP clients that probe with `GET` handle this). |
|
|
536
|
+
| A tool is missing from `tools/list`, or `-32602 Unknown tool` | The user lacks one of the tool's permissions (`commands:execute` plus the command's `requiredPermissions`, `files:read`/`files:write`, `data:query`, `jobs:read`/`jobs:manage`); the token's scope narrows them further; `mcp.tools` / `mcp.exclude` filter it out; or the feature is not enabled on the server (file storage, data explorer sources, jobs plugin). A command whose parameters all live on its sub-commands appears only as `<command>_<sub>` tools. |
|
|
537
|
+
|
|
319
538
|
## Remote Shell Security
|
|
320
539
|
|
|
321
540
|
The PTY shell (`/ws/v1/qcli/shell`, `/ws/qcli/shell`) gives OS-level access to the server. It is **off** unless `enableShell: true`. When enabled, exactly one access mode applies:
|
|
@@ -417,6 +636,7 @@ Refusals are sent as *accept, then close* so browsers can read them (a foreign `
|
|
|
417
636
|
| `processors` | `ICliCommandProcessor[]` | `undefined` | Sub-commands |
|
|
418
637
|
| `allowUnlistedCommands` | `boolean` | `undefined` | Accept sub-commands not in `processors` |
|
|
419
638
|
| `valueRequired` | `boolean` | `undefined` | Require a positional value |
|
|
639
|
+
| `acceptsValue` | `boolean` | `undefined` | Reads an optional positional value (`command.value`); MCP exposes it as an optional `value` argument |
|
|
420
640
|
| `version` | `string` | `'1.0.0'` | Processor version string |
|
|
421
641
|
| `author` | `ICliCommandAuthor` | default author | Author metadata (name, email) |
|
|
422
642
|
|
|
@@ -431,6 +651,7 @@ interface CliServerOptions {
|
|
|
431
651
|
shell?: CliShellOptions; // Shell access mode, limits, timeouts, env (see Remote Shell Security)
|
|
432
652
|
trustProxy?: boolean | number; // Trusted proxy hops for X-Forwarded-* (true = 1; default false = none)
|
|
433
653
|
auth?: ICliServerAuth; // Protect the whole server (e.g. usersPlugin.serverAuth)
|
|
654
|
+
mcp?: boolean | CliMcpOptions; // MCP endpoint at {basePath}/mcp (default off, see MCP Endpoint)
|
|
434
655
|
configure?: (builder: CliBuilder) => void; // Processor registration
|
|
435
656
|
}
|
|
436
657
|
```
|
|
@@ -455,6 +676,7 @@ When the users plugin is mounted (`mountPlugin(usersPlugin)`) or passed as `auth
|
|
|
455
676
|
logSocketManager: CliLogSocketManager; // WebSocket log manager
|
|
456
677
|
mountPlugin(plugin: MountablePlugin): void; // Mount a plugin with its routes (installs plugin.serverAuth)
|
|
457
678
|
setAuth(auth?: ICliServerAuth): void; // Install/remove the server auth provider
|
|
679
|
+
mcp: CliServerMcp; // MCP endpoint: { enabled, path, addProvider(provider) }
|
|
458
680
|
}
|
|
459
681
|
```
|
|
460
682
|
|
|
@@ -745,6 +967,7 @@ Once mounted, every server route and socket requires a users session (login, ver
|
|
|
745
967
|
|---|---|
|
|
746
968
|
| `GET /commands` | authenticated |
|
|
747
969
|
| `POST /execute`, `/execute/stream` | `commands:execute` + the processor's `requiredPermissions` |
|
|
970
|
+
| `POST /api/qcli/mcp` | `commands:execute` (each tool then checks its own permissions) |
|
|
748
971
|
| fs `ls`/`cat`/`stat`/`download` | `files:read` |
|
|
749
972
|
| fs `upload`/`mkdir`/`rm` | `files:write` |
|
|
750
973
|
| data explorer | `data:query` |
|
|
@@ -756,7 +979,9 @@ WebSockets authenticate with a single-use ticket: `POST /api/v1/qcli/sessions/ws
|
|
|
756
979
|
|
|
757
980
|
Events and logs sockets authenticated with a stored session are bound to it: when the session ends (logout, revoke/kick, user disabled or deleted, a password change becoming required, idle/absolute expiry) the socket is closed with **4401** `session ended`; for a revoke the events socket first receives `session-kicked`. Bound sockets are re-checked on every session/user/group change and after each expired-session sweep (`setCleanupInterval`, default 5 minutes). Sockets authenticated by an external auth adapter have no stored session and are not re-checked.
|
|
758
981
|
|
|
759
|
-
|
|
982
|
+
API tokens (`qcli_pat_…`) are long-lived, revocable bearer tokens for MCP clients, CI and scripts; they are accepted wherever a session token is (see [API tokens](plugins/users/README.md#api-tokens)). Sockets opened with a token identity close with 4401 when the token is revoked or expires, or the user is disabled.
|
|
983
|
+
|
|
984
|
+
See [`plugins/users/README.md`](plugins/users/README.md) for options, endpoints, API tokens, custom storage and external auth adapters.
|
|
760
985
|
|
|
761
986
|
## Built-in Processors
|
|
762
987
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qodalis/cli-server-node",
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
4
|
+
"description": "Node.js CLI server for Qodalis CLI ecosystem — use as a library in existing Express apps or run standalone",
|
|
5
|
+
"main": "dist/src/index.js",
|
|
6
|
+
"types": "dist/src/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"qodalis-cli-server": "dist/src/server.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"!dist/src/__tests__",
|
|
13
|
+
"!dist/plugins",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"start": "tsx src/server.ts",
|
|
20
|
+
"dev": "tsx watch src/server.ts",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:watch": "vitest"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"cli",
|
|
26
|
+
"qodalis",
|
|
27
|
+
"terminal",
|
|
28
|
+
"commands",
|
|
29
|
+
"cli-server",
|
|
30
|
+
"command-processor"
|
|
31
|
+
],
|
|
32
|
+
"author": "Nicolae Lupei <nicolae.lupei@qodalis.com>",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/qodalis-solutions/cli-server-node"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://qodalis.com/",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@qodalis/cli-server-abstractions": "file:packages/abstractions",
|
|
41
|
+
"@qodalis/cli-server-plugin-data-explorer": "file:plugins/data-explorer",
|
|
42
|
+
"@qodalis/cli-server-plugin-filesystem": "file:plugins/filesystem",
|
|
43
|
+
"@qodalis/cli-server-plugin-jobs": "file:plugins/jobs",
|
|
44
|
+
"cors": "^2.8.5",
|
|
45
|
+
"express": "^4.21.0",
|
|
46
|
+
"multer": "^2.1.0",
|
|
47
|
+
"node-pty": "^1.1.0",
|
|
48
|
+
"ws": "^8.18.0"
|
|
49
|
+
},
|
|
50
|
+
"optionalDependencies": {
|
|
51
|
+
"@elastic/elasticsearch": "^8.16.0",
|
|
52
|
+
"@qodalis/cli-server-plugin-filesystem-json": "file:plugins/filesystem-json",
|
|
53
|
+
"@qodalis/cli-server-plugin-filesystem-s3": "file:plugins/filesystem-s3",
|
|
54
|
+
"@qodalis/cli-server-plugin-filesystem-sqlite": "file:plugins/filesystem-sqlite",
|
|
55
|
+
"better-sqlite3": "^11.10.0",
|
|
56
|
+
"ioredis": "^5.4.0",
|
|
57
|
+
"mongodb": "^6.0.0",
|
|
58
|
+
"mssql": "^11.0.0",
|
|
59
|
+
"mysql2": "^3.11.0",
|
|
60
|
+
"pg": "^8.13.0"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
64
|
+
"@types/cors": "^2.8.17",
|
|
65
|
+
"@types/express": "^4.17.21",
|
|
66
|
+
"@types/mssql": "^9.1.9",
|
|
67
|
+
"@types/multer": "^2.0.0",
|
|
68
|
+
"@types/node": "^22.0.0",
|
|
69
|
+
"@types/pg": "^8.0.0",
|
|
70
|
+
"@types/supertest": "^7.2.0",
|
|
71
|
+
"@types/ws": "^8.5.13",
|
|
72
|
+
"supertest": "^7.2.2",
|
|
73
|
+
"tsx": "^4.19.0",
|
|
74
|
+
"typescript": "^5.6.0",
|
|
75
|
+
"vitest": "^4.0.18"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ICliCommandAuthor, CliCommandAuthor, DefaultLibraryAuthor, CliProcessCommand, ICliCommandParameterDescriptor, CliCommandParameterDescriptor, ICliCommandProcessor, CliCommandProcessor, ICliModule, CliModule, ICliJob, ICliJobExecutionContext, ICliJobLogger, CliJobOptions, JobOverlapPolicy, ICliJobStorageProvider, JobExecution, JobExecutionStatus, JobState, JobStatus, JobLogEntry, JobLogLevel, CliStructuredOutput, CliStructuredResponse, IDataExplorerProvider, DataExplorerProviderOptions, DataExplorerLanguage, DataExplorerOutputFormat, DataExplorerTemplate, DataExplorerParameterDescriptor, DataExplorerExecutionContext, DataExplorerResult, DataExplorerExecuteRequest, DataExplorerSourceInfo, ICliProcessorFilter, ICliStreamCommandProcessor, isStreamCapable, } from '@qodalis/cli-server-abstractions';
|
|
1
|
+
export { ICliCommandAuthor, CliCommandAuthor, DefaultLibraryAuthor, CliProcessCommand, splitShellWords, joinShellWords, getPositionals, getPositionalText, quoteShellWord, ICliCommandParameterDescriptor, CliCommandParameterDescriptor, ICliCommandProcessor, CliCommandProcessor, ICliModule, CliModule, ICliJob, ICliJobExecutionContext, ICliJobLogger, CliJobOptions, JobOverlapPolicy, ICliJobStorageProvider, JobExecution, JobExecutionStatus, JobState, JobStatus, JobLogEntry, JobLogLevel, CliStructuredOutput, CliStructuredResponse, IDataExplorerProvider, DataExplorerProviderOptions, DataExplorerLanguage, DataExplorerOutputFormat, DataExplorerTemplate, DataExplorerParameterDescriptor, DataExplorerExecutionContext, DataExplorerResult, DataExplorerExecuteRequest, DataExplorerSourceInfo, ICliProcessorFilter, ICliStreamCommandProcessor, isStreamCapable, } from '@qodalis/cli-server-abstractions';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/abstractions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,8BAA8B,EAC9B,6BAA6B,EAC7B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,4BAA4B,EAC5B,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,GAClB,MAAM,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/abstractions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,8BAA8B,EAC9B,6BAA6B,EAC7B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,OAAO,EACP,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,QAAQ,EACR,SAAS,EACT,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,EACpB,+BAA+B,EAC/B,4BAA4B,EAC5B,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,GAClB,MAAM,kCAAkC,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isStreamCapable = exports.DataExplorerOutputFormat = exports.DataExplorerLanguage = exports.CliModule = exports.CliCommandProcessor = exports.CliCommandParameterDescriptor = exports.DefaultLibraryAuthor = exports.CliCommandAuthor = void 0;
|
|
3
|
+
exports.isStreamCapable = exports.DataExplorerOutputFormat = exports.DataExplorerLanguage = exports.CliModule = exports.CliCommandProcessor = exports.CliCommandParameterDescriptor = exports.quoteShellWord = exports.getPositionalText = exports.getPositionals = exports.joinShellWords = exports.splitShellWords = exports.DefaultLibraryAuthor = exports.CliCommandAuthor = void 0;
|
|
4
4
|
var cli_server_abstractions_1 = require("@qodalis/cli-server-abstractions");
|
|
5
5
|
Object.defineProperty(exports, "CliCommandAuthor", { enumerable: true, get: function () { return cli_server_abstractions_1.CliCommandAuthor; } });
|
|
6
6
|
Object.defineProperty(exports, "DefaultLibraryAuthor", { enumerable: true, get: function () { return cli_server_abstractions_1.DefaultLibraryAuthor; } });
|
|
7
|
+
Object.defineProperty(exports, "splitShellWords", { enumerable: true, get: function () { return cli_server_abstractions_1.splitShellWords; } });
|
|
8
|
+
Object.defineProperty(exports, "joinShellWords", { enumerable: true, get: function () { return cli_server_abstractions_1.joinShellWords; } });
|
|
9
|
+
Object.defineProperty(exports, "getPositionals", { enumerable: true, get: function () { return cli_server_abstractions_1.getPositionals; } });
|
|
10
|
+
Object.defineProperty(exports, "getPositionalText", { enumerable: true, get: function () { return cli_server_abstractions_1.getPositionalText; } });
|
|
11
|
+
Object.defineProperty(exports, "quoteShellWord", { enumerable: true, get: function () { return cli_server_abstractions_1.quoteShellWord; } });
|
|
7
12
|
Object.defineProperty(exports, "CliCommandParameterDescriptor", { enumerable: true, get: function () { return cli_server_abstractions_1.CliCommandParameterDescriptor; } });
|
|
8
13
|
Object.defineProperty(exports, "CliCommandProcessor", { enumerable: true, get: function () { return cli_server_abstractions_1.CliCommandProcessor; } });
|
|
9
14
|
Object.defineProperty(exports, "CliModule", { enumerable: true, get: function () { return cli_server_abstractions_1.CliModule; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/abstractions/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/abstractions/index.ts"],"names":[],"mappings":";;;AAAA,4EA2C0C;AAzCtC,2HAAA,gBAAgB,OAAA;AAChB,+HAAA,oBAAoB,OAAA;AAEpB,0HAAA,eAAe,OAAA;AACf,yHAAA,cAAc,OAAA;AACd,yHAAA,cAAc,OAAA;AACd,4HAAA,iBAAiB,OAAA;AACjB,yHAAA,cAAc,OAAA;AAEd,wIAAA,6BAA6B,OAAA;AAE7B,8HAAA,mBAAmB,OAAA;AAEnB,oHAAA,SAAS,OAAA;AAiBT,+HAAA,oBAAoB,OAAA;AACpB,mIAAA,wBAAwB,OAAA;AASxB,0HAAA,eAAe,OAAA"}
|
|
@@ -17,6 +17,8 @@ export interface ServerAuthGateOptions {
|
|
|
17
17
|
cliPrefixes: string[];
|
|
18
18
|
/** Extra public routes as `"METHOD /path"` (e.g. a plugin's own login). */
|
|
19
19
|
publicRoutes: Set<string>;
|
|
20
|
+
/** MCP endpoint paths (normalized), requiring `commands:execute`. */
|
|
21
|
+
mcpPaths?: string[];
|
|
20
22
|
}
|
|
21
23
|
/** Collects `requiredPermissions` along the resolved processor chain. */
|
|
22
24
|
export declare function processorPermissions(registry: ICliCommandRegistry, command: unknown, chain: unknown): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-server-auth-gate.d.ts","sourceRoot":"","sources":["../../../src/auth/cli-server-auth-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAA6B,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKpG,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QACd,UAAU,OAAO;YACb,6EAA6E;YAC7E,cAAc,CAAC,EAAE,oBAAoB,CAAC;SACzC;KACJ;CACJ;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD;AAgBD,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,2EAA2E;IAC3E,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-server-auth-gate.d.ts","sourceRoot":"","sources":["../../../src/auth/cli-server-auth-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAA6B,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKpG,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QACd,UAAU,OAAO;YACb,6EAA6E;YAC7E,cAAc,CAAC,EAAE,oBAAoB,CAAC;SACzC;KACJ;CACJ;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD;AAgBD,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,6EAA6E;IAC7E,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,2EAA2E;IAC3E,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,GACf,MAAM,EAAE,CAkBV;AAED,2DAA2D;AAC3D,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,EAAE,CAoB3H;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,MAAM,cAAc,GAAG,SAAS,EACzC,OAAO,EAAE,qBAAqB,GAC/B,cAAc,CAkDhB"}
|
|
@@ -53,6 +53,9 @@ function requiredServerPermissions(method, path, body, options) {
|
|
|
53
53
|
return [cli_server_auth_1.CliServerPermissions.CommandsExecute, ...processorPermissions(options.registry, body?.command, body?.chainCommands)];
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
if (options.mcpPaths?.includes(path)) {
|
|
57
|
+
return [cli_server_auth_1.CliServerPermissions.CommandsExecute];
|
|
58
|
+
}
|
|
56
59
|
if (path === '/api/qcli/fs' || path.startsWith('/api/qcli/fs/')) {
|
|
57
60
|
const op = path.slice('/api/qcli/fs/'.length);
|
|
58
61
|
return [method === 'GET' && FS_READ.has(op) ? cli_server_auth_1.CliServerPermissions.FilesRead : cli_server_auth_1.CliServerPermissions.FilesWrite];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-server-auth-gate.js","sourceRoot":"","sources":["../../../src/auth/cli-server-auth-gate.ts"],"names":[],"mappings":";;AAkBA,sCAGC;
|
|
1
|
+
{"version":3,"file":"cli-server-auth-gate.js","sourceRoot":"","sources":["../../../src/auth/cli-server-auth-gate.ts"],"names":[],"mappings":";;AAkBA,sCAGC;AA2BD,oDAsBC;AAGD,8DAoBC;AAOD,oDAqDC;AAtJD,uDAAoG;AACpG,4CAA+C;AAE/C,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,YAAY,CAAC,CAAC;AAW1C,mGAAmG;AACnG,SAAgB,aAAa,CAAC,IAAY;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzE,OAAO,CAAC,IAAI,GAAG,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACvB,oBAAoB;IACpB,mBAAmB;IACnB,wBAAwB;IACxB,mBAAmB;IACnB,sBAAsB;IACtB,2BAA2B;IAC3B,SAAS;IACT,UAAU;IACV,aAAa;CAChB,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AA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MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,iCAAiC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvF,OAAO;YACX,CAAC;YACD,GAAG,CAAC,cAAc,GAAG,GAAG,CAAC;YACzB,IAAI,EAAE,CAAC;QACX,CAAC,EACD,CAAC,GAA0C,EAAE,EAAE;YAC3C,IAAI,OAAO,GAAG,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAClC,qEAAqE;gBACrE,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,GAAG,CAAC,CAAC;gBACzD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;gBACzD,OAAO;YACX,CAAC;YACD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;YAC1B,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC,CAAC;QACpH,CAAC,CACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -6,6 +6,8 @@ export interface CliServerAuthContext {
|
|
|
6
6
|
userName: string;
|
|
7
7
|
/** Absent for host-authenticated (adapter) callers. */
|
|
8
8
|
sessionId?: string;
|
|
9
|
+
/** Set when the caller authenticated with an API token (no session). */
|
|
10
|
+
tokenId?: string;
|
|
9
11
|
/** Effective permissions (`resource:action`, `*` wildcards). */
|
|
10
12
|
permissions: string[];
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-server-auth.d.ts","sourceRoot":"","sources":["../../../src/auth/cli-server-auth.ts"],"names":[],"mappings":"AAAA,OAA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C,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,EAC3G,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GACzC,MAAM,CAER;AAED,oGAAoG;AACpG,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACvD,MAAM,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChE,yEAAyE;IACzE,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;KAAE,CAAC;CAC7C;AAsCD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,kBAAkB,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAKxG;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,kBAAkB,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAWxH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-server-auth.js","sourceRoot":"","sources":["../../../src/auth/cli-server-auth.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cli-server-auth.js","sourceRoot":"","sources":["../../../src/auth/cli-server-auth.ts"],"names":[],"mappings":";;;AAwGA,0CAWC;AAOD,4CAMC;AAmBD,sCAKC;AAsDD,sCAKC;AAOD,oCAWC;AA9ID,6EAA6E;AAChE,QAAA,oBAAoB,GAAG;IAChC,eAAe,EAAE,kB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AAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC3C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC;AACrC,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { CliCommandRegistry, CliCommandExecutorService, CliEventSocketManager, C
|
|
|
4
4
|
import { CliBuilder } from './extensions';
|
|
5
5
|
import { ICliServerAuth } from './auth/cli-server-auth';
|
|
6
6
|
import { CliShellOptions } from './services/cli-shell-options';
|
|
7
|
+
import { CliMcpOptions, McpToolProvider } from './mcp';
|
|
7
8
|
/**
|
|
8
9
|
* Generic interface for plugin results that can be auto-mounted.
|
|
9
10
|
* Plugins expose a `prefix` and `router`; some also have a
|
|
@@ -22,6 +23,22 @@ export interface MountablePlugin {
|
|
|
22
23
|
serverAuth?: ICliServerAuth;
|
|
23
24
|
/** Routes that stay public under server protection, as `"METHOD /path"` (e.g. a plugin's login). */
|
|
24
25
|
publicRoutes?: string[];
|
|
26
|
+
/** MCP tool providers contributed by the plugin (used when the `mcp` option is on). */
|
|
27
|
+
mcpProviders?: McpToolProvider[];
|
|
28
|
+
/** Job scheduler (the jobs plugin): enables the `jobs_*` MCP tools. */
|
|
29
|
+
scheduler?: unknown;
|
|
30
|
+
}
|
|
31
|
+
/** MCP extension point of a server instance. */
|
|
32
|
+
export interface CliServerMcp {
|
|
33
|
+
/** True when the MCP endpoint is enabled. */
|
|
34
|
+
readonly enabled: boolean;
|
|
35
|
+
/** The endpoint path (`{basePath}/mcp`). */
|
|
36
|
+
readonly path: string;
|
|
37
|
+
/**
|
|
38
|
+
* Registers a tool provider. On a name collision built-in feature tools win,
|
|
39
|
+
* then providers in registration order, then command tools.
|
|
40
|
+
*/
|
|
41
|
+
addProvider(provider: McpToolProvider): void;
|
|
25
42
|
}
|
|
26
43
|
/** Options for creating a standalone CLI server instance. */
|
|
27
44
|
export interface CliServerOptions {
|
|
@@ -61,6 +78,13 @@ export interface CliServerOptions {
|
|
|
61
78
|
* Can also be installed later with `setAuth()` or by `mountPlugin(usersPlugin)`.
|
|
62
79
|
*/
|
|
63
80
|
auth?: ICliServerAuth;
|
|
81
|
+
/**
|
|
82
|
+
* MCP endpoint (`POST {basePath}/mcp`, off by default): AI clients call the
|
|
83
|
+
* registered commands as MCP tools. `true` enables it with defaults; the object
|
|
84
|
+
* form sets an allow/deny list of tools, a static bearer `token` (only without
|
|
85
|
+
* an auth provider) and `instructions` returned by `initialize`.
|
|
86
|
+
*/
|
|
87
|
+
mcp?: boolean | CliMcpOptions;
|
|
64
88
|
/** Configure processors via the builder. */
|
|
65
89
|
configure?: (builder: CliBuilder) => void;
|
|
66
90
|
}
|
|
@@ -92,6 +116,8 @@ export interface CliServerResult {
|
|
|
92
116
|
mountPlugin(plugin: MountablePlugin): void;
|
|
93
117
|
/** Installs (or removes) the auth provider protecting server routes and sockets. */
|
|
94
118
|
setAuth(auth: ICliServerAuth | undefined): void;
|
|
119
|
+
/** MCP endpoint: register tool providers (`mcp.addProvider(p)`). */
|
|
120
|
+
mcp: CliServerMcp;
|
|
95
121
|
}
|
|
96
122
|
export declare function createCliServer(options?: CliServerOptions): CliServerResult;
|
|
97
123
|
//# sourceMappingURL=create-cli-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cli-server.d.ts","sourceRoot":"","sources":["../../src/create-cli-server.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,C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