sco-mcp
# sco-mcp
MCP server that exposes the [SenseCore SCO CLI](https://console.sensecore.cn) (`sco`)
as typed tools: ACP training jobs, CCI container apps, AEC2 clusters, AFS storage
and CCR images — without re-implementing any HTTP API.
The CLI stays the source of truth. Every tool composes an argv array, runs it
without a shell, and returns both human-readable text and structured output.
```
MCP host ── stdio ──▶ sco-mcp ── argv ──▶ sco ──▶ SenseCore APIs
```
## Requirements
- Node.js ≥ 20.11
- A working `sco` binary with credentials configured (`sco config list` succeeds)
Verified against SCO CLI 2.0.5 (`Runtime: launcher`) with `sco config list`
reporting an active profile.
> The CLI is not always on `PATH` — a self-updating install lives at
> `~/.sco/bin/sco`. Set `SCO_BIN` to the absolute path when in doubt.
### Known CLI quirks this server handles
| Behaviour | Handling |
| --- | --- |
| `sco` is a launcher that forks a runtime child | timeouts signal the whole process group, then settle on a deadline instead of waiting for EOF (a surviving child would otherwise hold the pipes open forever) |
| `sco version` reports on stderr, not stdout | `sco_doctor` reports both streams |
| `sco ccr images list` / `sco ccr labels list` can block on registry access | returns `SCO_TIMEOUT` after `SCO_TIMEOUT_MS` instead of hanging |
| `--container_name` uses an underscore in `acp jobs stream-logs` | mapped explicitly, not derived from the flag name |
## Install
```bash
npm install
npm run build
```
Point an MCP host at the built entry point. For OpenCode:
```jsonc
{
"mcp": {
"sco": {
"type": "local",
"command": ["node", "/absolute/path/to/sco-mcp/dist/src/index.js"],
"environment": {
"SCO_WORKSPACE": "e87cb6db-863c-4392-b6c7-31c04e91d462",
"SCO_AEC2": "e4a32c09-2eda-4b2e-a5ed-f73e11330a20"
}
}
}
}
```
For Claude Desktop, use the same command under `mcpServers` with
`"command": "node"` and `"args": ["/absolute/path/to/sco-mcp/dist/src/index.js"]`.
Check the wiring with the `sco_doctor` tool: it reports the binary, version,
config and available profiles in one call.
## Configuration
| Variable | Purpose | Default |
| --- | --- | --- |
| `SCO_BIN` | CLI executable (name or absolute path) | `sco` |
| `SCO_WORKSPACE` | default workspace id for workspace-scoped tools | unset |
| `SCO_AEC2` | default cluster name | unset |
| `SCO_PROFILE` | default `--profile` | unset |
| `SCO_SUBSCRIPTION` | default `--subscription` | unset |
| `SCO_RESOURCE_GROUP` | default `--resource-group` | unset |
| `SCO_TIMEOUT_MS` | per-invocation timeout | `120000` |
| `SCO_MAX_OUTPUT_BYTES` | captured stdout/stderr cap | `1048576` |
| `SCO_READ_ONLY` | reject every mutating tool | `false` |
| `SCO_ALLOW_RAW` | register the `sco_raw` pass-through | `false` |
Explicit tool arguments always win over environment defaults.
## Tools
All tools are prefixed `sco_`. Every result carries `structuredContent` with
`command`, `exitCode`, `stdout`, `stderr`, `truncated`, `dryRun`, `durationMs`
and, when stdout parses as JSON, the parsed `json` payload.
### Diagnostics (7)
`sco_version` · `sco_doctor` · `sco_capabilities` · `sco_config_list` ·
`sco_config_get` · `sco_config_profiles_list` · `sco_config_profiles_describe`
`sco_capabilities` probes `sco <group> --help` and reports which subcommands
this installation actually accepts. Reach for it when a documented command
fails: components ship independently, so `sco ccr builds` is absent on
sco-ccr v1.2.0 even though it exists in the docs.
### ACP jobs (9)
`sco_acp_job_create` · `sco_acp_job_list` · `sco_acp_job_describe` ·
`sco_acp_job_workers` · `sco_acp_job_logs` · `sco_acp_job_copy` ·
`sco_acp_job_start` · `sco_acp_job_stop` · `sco_acp_job_delete`
`acp_job_exec` is deliberately absent: it allocates a TTY and hands over an
interactive shell, which an MCP call cannot own. Use a CCI app when you need a
long-lived box to poke at.
### CCI apps (7)
`sco_cci_app_create` · `sco_cci_app_list` · `sco_cci_app_describe` ·
`sco_cci_app_update` · `sco_cci_app_start` · `sco_cci_app_stop` ·
`sco_cci_app_delete`
### AEC2 (3)
`sco_aec2_cluster_list` · `sco_aec2_cluster_describe` · `sco_aec2_workerspec_list`
Read-only on purpose: creating clusters or attaching nodes is a console task,
not something an agent should do unattended.
### AFS (8)
`sco_afs_volume_list` · `sco_afs_volume_ls` · `sco_afs_dir_quota_list` ·
`sco_afs_dir_quota_create` · `sco_afs_dir_quota_update` ·
`sco_afs_dir_quota_delete` · `sco_afs_dir_acl_list` · `sco_afs_dir_acl_create`
### CCR (10)
`sco_ccr_image_list` · `sco_ccr_namespace_list` · `sco_ccr_namespace_get` ·
`sco_ccr_build_create` · `sco_ccr_build_list` · `sco_ccr_build_get` ·
`sco_ccr_build_log` · `sco_ccr_label_list` · `sco_ccr_label_get` ·
`sco_ccr_label_update`
### Escape hatch (opt-in)
`sco_raw` is registered only when `SCO_ALLOW_RAW=1`. It takes an argv array,
never a shell string. Verbs are classified: anything mutating
(`create`, `delete`, `update`, `start`, `stop`, `copy`, `exec`, `activate`,
`rename`, node operations) requires `confirm: true` and is refused under
`SCO_READ_ONLY=1`. `--follow` is rejected because it would block until the
timeout.
## Safety model
- Mutating tools need `confirm: true`. Without it they return
`SCO_CONFIRM_REQUIRED` **and the exact argv that would have run**, so the
caller can show the user before retrying.
- `dryRun: true` returns the argv without executing anything, and works before
confirming (that is how a caller inspects what it is being asked to approve).
It also works under `SCO_READ_ONLY=1` and, for CCI app creation, echoes the
generated YAML.
- `SCO_READ_ONLY=1` rejects mutations before the process is spawned.
- Commands are spawned without a shell: no quoting bugs, no injection.
- Each call has a timeout (`SIGTERM`, then `SIGKILL`, then a final deadline) and
a byte cap per stream.
- Recognizable failures carry a `structuredContent.hint` naming the next step:
missing subcommand, missing subscription, rejected credentials, missing
permission.
## Examples
Submit a job, using the configured workspace and cluster:
```jsonc
{
"name": "sco_acp_job_create",
"arguments": {
"jobName": "train-llama",
"image": "registry.example.com/team/trainer:v1",
"trainingFramework": "pytorch",
"workerNodes": 4,
"workerSpec": "1x8-3090",
"command": "bash train.sh",
"storageMounts": [{ "volumeId": "vol-123", "path": "/data" }],
"confirm": true
}
}
```
Preview a CCI app before creating it:
```jsonc
{
"name": "sco_cci_app_create",
"arguments": {
"appName": "debug-box",
"dryRun": true,
"spec": {
"resourcePool": { "name": "pool-1" },
"resourceSpec": { "name": "1x8-3090" },
"containers": [
{
"name": "main",
"image": "registry.example.com/team/dev:latest",
"cpu": 8,
"memory": "32Gi",
"command": ["sleep", "infinity"],
"mounts": [{ "id": "vol-123", "mountPath": "/data" }]
}
]
}
}
}
```
## Development
```bash
npm run typecheck # tsc --noEmit
npm test # build, then node --test over dist/test
```
No `sco` installation is required for tests: `test/helpers/fake-sco.mjs` is a
controllable stub that records every argv to `$SCO_FAKE_LOG`. The suite covers
the arg builder, config resolution, process runner, every tool's argv, the
safety guards, and a full stdio round trip through a spawned server.
```
src/
cli/ argv builder, process runner, errors, YAML emitter
tools/ one module per SCO area + shared result/schema helpers
config.ts environment resolution
server.ts tool registration
index.ts stdio entry point
test/ unit, in-memory integration, stdio end-to-end
docs/PLAN.md feature plan and delivery log
```
## License
MIT
TDQS
Scored across 44 tools
Most tools map to a distinct resource+action pair within clearly separated product groups (acp jobs, cci apps, aec2 clusters, afs, ccr), so an agent can usually pick correctly. The main soft spots are sco_afs_volume_list (which also describes a volume when volumeId is given, with no separate describe tool) versus sco_afs_volume_ls (lists directories inside a volume), and the config quartet (sco_config_list, sco_config_get, sco_config_profiles_list, sco_config_profiles_describe) which requires careful reading to distinguish.
The dominant pattern is sco_<product>_<resource>_<verb> with the verb last (sco_acp_job_create, sco_cci_app_list, sco_aec2_cluster_describe, sco_afs_dir_quota_update), which is predictable and readable. Minor deviations exist: sco_version/sco_doctor/sco_capabilities are top-level with no group or verb, sco_config_get lacks a resource segment, and sco_afs_volume_ls uses 'ls' where every other listing tool uses 'list'.
44 tools is heavy for a single server and sits well past the comfortable range, but it is a faithful wrapper over a broad multi-product CLI (config, acp, cci, aec2, afs, ccr), so each tool corresponds to a real subcommand rather than filler. It is borderline: coverage of six product areas justifies breadth, yet an agent must carry a large surface just to do routine work.
Lifecycle coverage is strong in some areas (acp jobs have create/list/describe/workers/logs/copy/start/stop/delete; cci apps have full CRUD plus start/stop) but notable gaps remain elsewhere: config is read-only with no set, ccr has no namespace create/delete and no image get/delete, builds have no delete/cancel, and dir-acl supports list/create but no update/delete. These are workable gaps but will cause dead ends for common admin workflows.