Move netx URL/token into DSH host settings and credentials.

Mount MCP from dsh-netxops instead of OS env in the agent preset.
This commit is contained in:
hansjone 2026-09-04 22:01:04 +08:00
parent 6677e36424
commit 45922ffd29
11 changed files with 374 additions and 117 deletions

View file

@ -2,7 +2,7 @@
## Prerequisites
1. **DeepSeek Harness** (`dsh`) installed or a local checkout (see [local debug](../examples/local-debug/README.md)).
1. **DeepSeek Harness** (`dsh`) installed or a local checkout.
2. **netx API** reachable (default `http://127.0.0.1:8890`).
3. **Python 3.11+** on the same machine as `dsh`, with `netx_mcp` importable:
@ -11,48 +11,73 @@ pip install "git+https://github.com/hansjone/netx.git#subdirectory=packages/netx
python -c "import netx_mcp; print('ok')"
```
4. Environment (optional if defaults match):
You do **not** need to export `NETX_API_URL` / `NETX_API_TOKEN` in the OS environment for normal use.
| Variable | Default | Purpose |
|----------|---------|---------|
| `NETX_API_URL` | `http://127.0.0.1:8890` | netx REST root |
| `NETX_API_TOKEN` | (empty / auto file) | Bearer token |
| `NETX_LANG` | `zh` | API locale |
## Install the agent preset (recommended)
Clone this repo, then link or copy the preset directory into the DSH user preset root:
```powershell
git clone https://github.com/hansjone/netxops.git
# Windows (developer junction — editable in place):
powershell -File .\scripts\link-preset.ps1
# Or copy:
# Copy-Item -Recurse .\presets\netxops $env:USERPROFILE\.dsh\.agent-presets\netxops
```
Unix:
```bash
git clone https://github.com/hansjone/netxops.git
./scripts/link-preset.sh
# Or: cp -R presets/netxops ~/.dsh/.agent-presets/netxops
```
Restart / open `dsh web`, create a session, choose preset **Netx Ops** (`netxops`).
## Optional: `dsh plugin add`
## 1) Install host bridge (URL + token + MCP tools)
```bash
dsh plugin --profile <name> add github:hansjone/netxops
# or from a checkout:
dsh plugin --profile <name> add /path/to/netxops
```
v1’s host `cordis.patch.yml` is empty (MCP stays inside the preset). You still need the preset link/copy above.
This applies `cordis.patch.yml`, which mounts package `dsh-netxops`. That plugin:
- Registers settings namespace **`netxops`** (`apiUrl`, `lang`, `pythonCommand`, …)
- Reads bearer token from credentials reference **`NETX_API_TOKEN`** (same store as model keys: `~/.dsh/.credentials.yaml`)
- Spawns `python -m netx_mcp` and registers `mcp__netx__*` on the **host** tool registry
### Fill API URL / language
**Target UX:** Settings → **Plugins** → **Netx Ops** card (settings `apiUrl` / `lang`).
The Host settings namespace is already registered; a dedicated Plugins settings card (browser half) follows the [DSH settings-card cookbook](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/cookbook/adding-a-settings-card.md) and will land in a follow-up.
**Until the card ships**, change composition defaults in the profile patch / plugin config:
```yaml
# ~/.dsh/profiles/<name>/… or override the dsh-netxops row
config:
apiUrl: http://10.0.0.5:8890
lang: zh
pythonCommand: python
```
Or edit the installed bundle row after `dsh plugin add`.
### Fill netx API token (secret)
Same credential store as DeepSeek API keys — **not** a process env var:
```powershell
powershell -File .\scripts\set-netx-token.ps1 -Token "nxt_…"
```
```bash
./scripts/set-netx-token.sh 'nxt_…'
```
This writes / updates `refs.NETX_API_TOKEN` under `%USERPROFILE%\.dsh\.credentials.yaml` (or `$DSH_HOME`). Restart is not required if DSH is watching credentials; otherwise restart `dsh web`.
## 2) Install the agent preset (persona + skills)
```powershell
git clone https://github.com/hansjone/netxops.git
cd netxops
powershell -File .\scripts\link-preset.ps1
```
Unix: `./scripts/link-preset.sh`
Open `dsh web`, new session → preset **Netx Ops**.
## Verify
1. Session tools include `mcp__netx__queryUmeAlarms` (and siblings).
2. Ask: “Critical Top 10 by host” → expect `aggregateUmeAlarms` + Result/Evidence shell.
3. Ask a single `host_name` alarm query → host-scoped tools only.
1. Tools include `mcp__netx__queryUmeAlarms` (and siblings).
2. “Critical Top by host” → aggregate + Result/Evidence shell.
3. Single `host_name` alarm query → host-scoped tools only.
See [TOOL_MAP.md](TOOL_MAP.md).
## Local debug (DeepSeekHarness checkout)
See [examples/local-debug/README.md](../examples/local-debug/README.md).