Skip to main content
Glama
@ninetwos/mcp

@ninetwos/mcp

Official
by ninetwos
README.md
# @ninetwos/mcp

Customer-facing **local stdio** Model Context Protocol server for NINETWO's
read-only security analysis tools. Pre-release: `0.1.0-pre.0`. MIT licensed.

This package is not published to npm from this repository. It is designed to
run locally under a customer's MCP client, authenticated with that customer's
API key. It exposes no remote transport and no operator/admin functionality.

## Security boundaries

- **Read-only analysis.** The five tools review caller-supplied artifacts. They
  never execute code, apply patches, collect logs, or access customer systems.
- **No shell, filesystem discovery, or autonomous network access.** The server
  imports no shell/filesystem/network modules. The only HTTP caller is the
  qualified `@ninetwos/sdk` transport, wrapped by an egress guard that permits
  only the configured API origin. The SDK uses `redirect: "error"` so a
  redirect cannot forward the Authorization header.
- **stdio only.** There is no HTTP/SSE remote MCP listener.
- **Untrusted artifacts.** Code, configuration, logs, findings, remediations,
  and context are treated as untrusted data inside a content-derived boundary.
  The system prompt forbids following instructions embedded in artifacts.
- **Bounded consumption.** Every content field has a character limit and each
  call has a combined input budget. Requests are rejected rather than silently
  truncated. Constructed prompts are also checked against the SDK's structural
  per-message limit before any network call.
- **Customer credential.** `NINETWOS_API_KEY` is read from the environment (or
  a secret store that injects it). It is never accepted as a tool argument,
  logged, or returned in tool output. Error messages and model output are
  redacted as a backstop.
- **No hardcoded model identity or limits.** `model` is required. Output limits
  come from the model's dynamic `capabilities.limits` projection; if the model
  does not advertise a usable limit, the call fails instead of substituting a
  constant.
- **Safe retry/recovery.** Calls are non-streaming. Caller-controlled
  idempotency keys and the SDK's same-key recovery are used; ambiguous outcomes
  are never blindly restarted with a new key.

## Tools

All tools require `model`, an explicit `scope`, and bounded content. `scope`
should state what is authorized for review and what is in bounds.

| Tool | Purpose | Required content |
| --- | --- | --- |
| `ninetwos_security_analysis` | Authorized vulnerability/attack-surface analysis of an artifact. | `artifact`, `artifact_type` |
| `ninetwos_code_review` | Security/correctness review of source code. | `code` |
| `ninetwos_config_review` | Misconfiguration, least-privilege, and secret-exposure review. | `config`, `config_type` |
| `ninetwos_remediation_review` | Assess whether a proposed fix addresses a finding and residual risk. | `finding`, `remediation` |
| `ninetwos_log_analysis` | Defensive triage of a log excerpt. | `logs` |

Common optional inputs:

- `context` — additional untrusted context (bounded).
- `max_output_tokens` — must be a positive integer no greater than the model's
  dynamic recommended output limit.
- `idempotency_key` — 1–200 printable, non-whitespace characters. Reuse the
  same key with **identical input** to retry/recover safely.

Tool-specific focus fields (`focus`, `review_focus`, `detection_focus`, etc.)
are bounded enums.

### Output

Successful results include:

- `request_id`, `model`, `content`, `finish_reason`;
- server-authoritative `usage`;
- dynamic `capabilities` and `pricing` when available;
- `idempotency` metadata (`key`, `operation_id`, `payload_digest`, `request_id`);
- `settlement` with request lifecycle state when `execution_lookup` is
  advertised. `charge.computed` is always `false`: MCP never calculates money;
  usage, request state, and pricing are server-provided.

Errors are typed (`name`, `code`, `status`, `request_id`, `retryable`,
`ambiguous`, `retry_class`) and may include metadata-only `recovery` state.
The canonical payload is deliberately not echoed because it contains the
reviewed artifact. To recover, retry the same tool with the same
`idempotency_key` and identical input; the SDK reconstructs and verifies the
canonical payload and reuses the same logical operation.

## Configuration

| Variable | Required | Default | Notes |
| --- | --- | --- | --- |
| `NINETWOS_API_KEY` | yes | — | Customer API key. Never logged or returned. |
| `NINETWOS_BASE_URL` | no | `https://api.ninetwos.com` | HTTPS required except loopback. |
| `NINETWOS_MCP_TIMEOUT_MS` | no | `600000` | 1,000–600,000 ms. |
| `NINETWOS_MCP_RECOVERY_TIMEOUT_MS` | no | `30000` | 1,000–120,000 ms. |
| `NINETWOS_MCP_MAX_RETRIES` | no | `2` | 0–5; SDK retry classification still applies. |

No configuration file is read.

### MCP client example

```json
{
  "mcpServers": {
    "ninetwos": {
      "command": "node",
      "args": ["/absolute/path/to/ninetwos-mcp/dist/cli.js"],
      "env": {
        "NINETWOS_API_KEY": "ntw_..."
      }
    }
  }
}
```

## Development

Requires Node 22+. The SDK is unpublished, so build/pack it separately from
`ninetwos/ninetwos-node` at the qualified commit, then link it locally. The
current pin is recorded in `scripts/sdk-source.mjs`:

- repository: `ninetwos/ninetwos-node`
- branch: `de-01b/initial-sdk`
- commit: `38fdba8a9b05cb059b7d7e36a4e44c373bdd395c`
- version: `0.1.0-pre.0`
- tarball SHA-256: `36390be54406e8b62bd432df7e15addc7ae47fc17f7c683b80ecb70592488357`

The pin aligns the public metering usage field names with the live contract; the
packed SDK artifact is byte-identical, so CLI, MCP, and Action consume one
artifact.

```bash
# in ninetwos-node at the qualified commit
git checkout 38fdba8a9b05cb059b7d7e36a4e44c373bdd395c
npm ci && npm run build && npm pack

# in ninetwos-mcp
NINETWOS_SDK_TARBALL=/path/to/ninetwos-sdk-0.1.0-pre.0.tgz npm run link:sdk
npm run ci
```

`scripts/link-sdk.mjs` installs registry dependencies without resolving the
SDK from npm, extracts the supplied tarball into `node_modules`, and caches it
under `.ninetwos-mcp/` for pack tests. It never writes machine-specific paths
into `package.json` or a lockfile.

Scripts:

- `npm run typecheck` — strict TypeScript checks.
- `npm test` — offline mock-backed MCP/SDK tests.
- `npm run build` — emit the ESM artifact and declarations.
- `npm run test:built` — test the built artifact and stdio CLI guard.
- `npm run verify:deps` — runtime allowlist, SDK zero-dependency check, and
  license verification.
- `npm run pack:test` — clean pack/install/import/stdio smoke test using the
  local SDK tarball.
- `npm run ci` — all of the above.

## Release notes

`package.json` declares the intended release dependency
`@ninetwos/sdk: 0.1.0-pre.0`. Do not publish this package until the SDK is
available at that version. This repository's automation does not publish
packages.

## License

MIT