Agent-Hellboy / Agent-Hellboy/mcp-runtime

Tool catalog + copy-config + informational risk badges (minimal, internal-team scope)

Abierto
#273 0 comentarios 0 reacciones 0 asignados Ver en GitHub
cli crd enhancement service-api service-ui
Lenguaje dominante
Go
Estrellas
6
Forks
1
Merge medio
11 h 33 min
PR fusionados (30 d)
13

Descripción

## Summary

Add a **tool-level catalog with copy-config and informational risk badges** so internal teams can answer "what MCP tools do we have, who can use them, and how do I connect?" from one place.

This is deliberately **minimal**. The platform targets small internal teams that trust their own agents and do not want a heavyweight gateway/policy product. We build **visibility and onboarding only** — no enforcement, no approval queues, no virtual endpoints, no new identity system.

It extends primitives that already exist (`MCPServer` inventory, live-inventory cache, the existing UI connect-config renderer, existing authz scoping) rather than introducing parallel concepts.

## Goals

- Search every tool across every server a user can access, in one view.
- See owning team/server, trust, side effect, drift, and a computed risk badge.
- Copy a ready-to-use client config (Claude / Cursor / VS Code / raw JSON) from the same flow.

## Non-goals (explicitly out of scope)

- **Enforcement** — no `block`/`approve` policy decisions, no policy-mode rename. Existing `observe`/`allow-list` modes and `allow`/`deny` decisions stay as-is. No CRD enum migration.
- **Human approval workflow** for destructive tools.
- **Virtual governed endpoints** (multi-server composition / alias routing).
- **Automatic IdP/LDAP group→team mapping.** Identity comes from the company LDAP via the existing OIDC login fronting the corporate IdP; team membership stays **manual** for the MVP. Revisit auto-mapping only when manual membership actually hurts.

---

## Scope of work

### 1. Catalog API — `GET /api/runtime/tools`

- Build the response from the **existing** server-list path and the live-inventory cache. **Do not re-probe** servers.
- Scope results with the same authz rules used by `handleRuntimeServerList` (`services/api/internal/runtimeapi/servers.go`).
- Return one row per tool:
- `tool_name`, `description`, `server_name`, `namespace`, `team_id`, `endpoint_url`
- `declared`, `live`, `drift_status` (`declared` | `ungoverned` | `missing`)
- `required_trust`, `side_effect`, `risk_level`, `labels`, `connect_config`
- Filters: query text, namespace, team, server, trust, side effect, risk, drift.
- Consider pagination / a documented cap; `connect_config` may be heavy per row (lazy on detail view if needed).

### 2. Risk badge (informational only)

- Add an **optional, additive** `riskLevel` field to `ToolConfig` in `api/v1alpha1/mcpserver_types.go`. **No enum changes.**
- Compute a default when unset:
- `read` + low trust → `low`
- `write` or medium trust → `medium`
- `destructive` or high trust → `high`
- Drift (`ungoverned` / `missing`) stays a **separate badge**, not folded into risk — risk must stay an intrinsic tool property that doesn't flip with probe state.
- Leave `pkg/policy.Authorize` and its `Decision` struct **unchanged**. Risk does not gate calls.
- Regenerate CRDs + deepcopy; update webhook defaulting and `pkg/metadata/schema.go` (+ loader tests) for the new field.
- `services/mcp-gateway` emits `risk_level` in audit events alongside existing fields (mode, decision, reason, tool, subject) so audit can be filtered by risk. **No new decisions.**

### 3. Copy-config (promote existing renderer)

- `renderServerConnectConfig(server)` already exists in `services/ui/static/app.js` with Claude Desktop / Cursor / VS Code / raw JSON tabs. **Promote it**, don't rebuild.
- Add a visible **Copy config** action beside Copy URL / Copy JSON; open a focused drawer/modal with client tabs.
- Include server URL, auth header placeholder, adapter command where needed; add copy success/failure states.

### 4. Catalog UI

- Add a first-class **Tools** view (or catalog mode in the Servers screen): dense table, search, filters, sortable columns.
- Keep server cards; make the catalog the fastest path to "what tools do we have and who can use them?"
- Reuse `serverDisplayInventory`, `mergeToolInventory`, and related inventory helpers.
- Badges: trust, side effect, risk, drift (compact and stable). Add a risk filter.

### 5. CLI

- `mcp-runtime catalog tools` with `--query`, `--team`, `--namespace`, `--server`, `--side-effect`, `--trust`, `--risk`, `--drift`, `--output table|json|yaml`.
- `mcp-runtime catalog tool --server ` for a single detail view.
- `mcp-runtime server connect-config ` with `--client claude|cursor|vscode|json`, `--namespace`, `--domain`, `--output json|text` — generate the same shape as the UI from shared helper code where practical.
- Add `--tool-risk low|medium|high` to server init/apply flows that touch tool metadata.
- Update golden/help files when help output changes.

---

## Identity note

Users come from the company's internal **LDAP** directory via the existing OIDC login (`services/api/auth/oidc.go`) fronting the corporate IdP. The MVP needs **no new identity code** — point OIDC at the company provider and use manual team membership.

⚠️ `oidc.go` currently keys users on the `email` claim only. Confirm the corporate IdP issues a usable `email` (or adjust the claim mapping) before relying on this.

---

## Acceptance criteria

- [ ] `GET /api/runtime/tools` returns scoped, filterable tool rows built from cache (no re-probe), with the same authz as server list.
- [ ] `riskLevel` is an additive `ToolConfig` field; CRDs/deepcopy/webhook/metadata regenerated; no policy enum or decision changes.
- [ ] Computed risk default works; drift is a separate badge.
- [ ] Catalog UI: searchable/filterable/sortable table with trust/side-effect/risk/drift badges + risk filter.
- [ ] Visible **Copy config** in UI reusing the existing renderer.
- [ ] CLI: `catalog tools`, `catalog tool`, `server connect-config`, `--tool-risk` flag; golden files updated.
- [ ] Gateway audit events include `risk_level`.
- [ ] Tests: API (scoping, filters, drift states, live-inventory fallback), CLI golden/help, UI (`services/ui/main_test.go` — catalog rendering, filters, empty states, drift badges).

## Validation

```bash
gofmt -s -l .
go build -o bin/mcp-runtime ./cmd/mcp-runtime
go test ./api/... ./internal/operator/... ./internal/cli/... -count=1
go test ./services/api/... -count=1
go test ./services/ui/... -count=1
go test ./services/mcp-gateway/... -count=1
# before merge:
go test ./... -count=1 -race
go vet ./...
E2E_CACHE_MODE=1 E2E_SCENARIOS=smoke-auth bash test/e2e/kind.sh
```

## Suggested milestones

- **M1 — Catalog & Config:** `GET /api/runtime/tools`, catalog UI, `mcp-runtime catalog tools`, promote Copy config, `mcp-runtime server connect-config`.
- **M2 — Risk badges:** computed `riskLevel`, badge + filter, `risk_level` in audit events.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.