saktum 0.2.0 → 0.3.0

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.
Files changed (3) hide show
  1. package/README.md +29 -1
  2. package/package.json +1 -1
  3. package/saktum.mjs +380 -64
package/README.md CHANGED
@@ -51,13 +51,41 @@ grade. Every report ends with **OWASP MCP Top 10 coverage**: which categories th
51
51
  `npx saktum checks` lists every check with the standard behind it ([docs/CHECKS.md](docs/CHECKS.md)).
52
52
  - **Control:** `--ignore check.id="reason"` (shown in the report, not scored) and `--badge badge.svg` for your README.
53
53
 
54
+ ## The provider toolkit
55
+
56
+ | Command | What it does |
57
+ | --- | --- |
58
+ | `saktum fix -- <server>` | Suggests danger annotations for every tool, as code to paste (`--format ts` or `py`), and flags annotations that contradict a tool's name |
59
+ | `saktum snapshot -- <server>` | Writes `saktum.lock.json`, a lock file of your tools |
60
+ | `saktum diff saktum.lock.json -- <server>` | Breaking changes (removed tools, new required fields, changed types), changes to review (descriptions, annotations: silent tool changes), additions, and the version bump they need; fails CI on breaking or risky changes |
61
+ | `saktum docs -- <server>` | A Markdown tools table and ready-to-paste configuration for Claude Desktop, Cursor and VS Code |
62
+ | `saktum packet saktum-report.json` | A printable **security packet** for customers' security reviews, built from a verified signed result, with a section for your own statements (clearly marked as not verified) |
63
+
64
+ ## In CI (GitHub Action)
65
+
66
+ ```yaml
67
+ - uses: actions/checkout@v4
68
+ - uses: soodhere/saktum-check@v0.3.0
69
+ with:
70
+ target: "-- node build/index.js" # or an https URL
71
+ args: "--active --tests saktum.tests.yaml" # optional; --active only for your own server
72
+ fail-on: high
73
+ ```
74
+
75
+ The report appears in the job summary; the signed result, HTML report and badge are saved as an artifact.
76
+
77
+ ## Test vectors for the MCP community
78
+
79
+ [`test-vectors/`](test-vectors/) holds known-good and known-bad servers with the expected verdict for every check, so any
80
+ MCP testing tool can validate itself against the same cases. Contributions welcome.
81
+
54
82
  ## What it checks
55
83
 
56
84
  | Area | Checks |
57
85
  | --- | --- |
58
86
  | Conformance | Handshake, tool list, valid input schemas (draft-07, 2019-09, 2020-12), tool names, unknown-tool handling |
59
87
  | Sign-in (remote servers) | HTTPS; 401 with a Bearer challenge pointing to resource metadata (RFC 9728); protected resource metadata; authorization server metadata with PKCE S256 (RFC 8414, RFC 7636); invalid tokens rejected (RFC 6750) |
60
- | Security | Hidden instructions to the agent, invisible and bidirectional characters, terminal escape sequences, secrets in tools or errors (always redacted), stack traces and source paths in errors |
88
+ | Security | Hidden instructions to the agent, invisible and bidirectional characters, terminal escape sequences, secrets in tools or errors (always redacted), stack traces and source paths in errors, Origin validation for local HTTP servers (DNS rebinding) |
61
89
  | Agent experience | Danger annotations, description quality, context cost in tokens and dollars |
62
90
  | Functional (`--active` or test cases) | Tools respond to valid arguments; results well-formed and matching their `outputSchema`; invalid arguments rejected gracefully; the server survives |
63
91
  | Performance (never scored) | Start-up, latency percentiles, behaviour at 1, 5 and 20 concurrent callers, memory of the whole process tree |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saktum",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Test MCP servers in one command: conformance, sign-in, security (OWASP MCP Top 10), agent experience, context cost and performance.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/saktum.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // Saktum Check 0.2.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
2
+ // Saktum Check 0.3.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
3
3
  import { createRequire as __saktumCreateRequire } from "node:module";
4
4
  const require = __saktumCreateRequire(import.meta.url);
5
5
  var __create = Object.create;
@@ -19093,7 +19093,7 @@ var init_embedded = __esm({
19093
19093
  }
19094
19094
  }
19095
19095
  `, "result.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/result/0.1.json",\n "title": "Saktum Trust Check result",\n "description": "The canonical result of one run. Every report format is rendered from this model. Evidence is a hash plus a short, sanitised excerpt; raw payloads never appear.",\n "type": "object",\n "required": [\n "resultFormat",\n "tool",\n "target",\n "packs",\n "findings",\n "scores",\n "metrics",\n "run"\n ],\n "additionalProperties": false,\n "properties": {\n "resultFormat": {\n "const": "0.1"\n },\n "tool": {\n "type": "object",\n "required": [\n "name",\n "version"\n ],\n "additionalProperties": false,\n "properties": {\n "name": {\n "const": "saktum-trust-check"\n },\n "version": {\n "type": "string"\n }\n }\n },\n "target": {\n "type": "object",\n "required": [\n "transport",\n "description"\n ],\n "additionalProperties": false,\n "properties": {\n "transport": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n },\n "description": {\n "type": "string"\n },\n "protocolVersion": {\n "type": "string"\n },\n "serverInfo": {\n "type": "object"\n },\n "toolsFingerprint": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "packs": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "id",\n "version",\n "hash"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string"\n },\n "version": {\n "type": "string"\n },\n "hash": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n }\n }\n }\n },\n "findings": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/finding"\n }\n },\n "scores": {\n "type": "object",\n "required": [\n "overall",\n "capped",\n "categories"\n ],\n "additionalProperties": false,\n "properties": {\n "overall": {\n "type": [\n "integer",\n "null"\n ],\n "minimum": 0,\n "maximum": 100\n },\n "capped": {\n "type": "boolean"\n },\n "categories": {\n "type": "object",\n "additionalProperties": {\n "type": [\n "integer",\n "null"\n ]\n }\n }\n }\n },\n "metrics": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "contextCostTokens": {\n "type": "integer",\n "minimum": 0\n },\n "largestTools": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "tool",\n "tokens"\n ],\n "properties": {\n "tool": {\n "type": "string"\n },\n "tokens": {\n "type": "integer"\n }\n }\n }\n },\n "contextCostPer1kTurnsUsd": {\n "type": "number",\n "minimum": 0,\n "description": "Estimated cost of loading the tool definitions on 1,000 agent turns at pricePerMTokUsd. Reported only."\n },\n "pricePerMTokUsd": {\n "type": "number",\n "minimum": 0\n },\n "performance": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "initMs": {\n "type": "integer",\n "minimum": 0\n },\n "listMs": {\n "type": "integer",\n "minimum": 0\n },\n "listBytes": {\n "type": "integer",\n "minimum": 0\n },\n "rssMb": {\n "type": "number",\n "minimum": 0\n },\n "cpuPct": {\n "type": "number",\n "minimum": 0\n },\n "burst": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "requests": {\n "type": "integer"\n },\n "ok": {\n "type": "integer"\n },\n "rateLimited": {\n "type": "integer"\n },\n "errors": {\n "type": "integer"\n },\n "p95Ms": {\n "type": "integer"\n }\n }\n }\n }\n }\n }\n },\n "run": {\n "type": "object",\n "required": [\n "startedAt",\n "durationMs",\n "mode",\n "runner",\n "sandbox"\n ],\n "additionalProperties": false,\n "properties": {\n "startedAt": {\n "type": "string",\n "format": "date-time"\n },\n "durationMs": {\n "type": "integer",\n "minimum": 0\n },\n "mode": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "runner": {\n "enum": [\n "self",\n "hosted"\n ],\n "description": "self: run and signed by the user, proves integrity not independence. hosted: run and signed by Saktum (later)."\n },\n "sandbox": {\n "enum": [\n "none",\n "docker"\n ],\n "description": "Whether local servers ran inside a container sandbox."\n }\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n }\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ],\n "description": "Letter grade from the trust score: A 90-100, B 80-89, C 70-79, D 50-69, F below 50 or any failed critical check."\n },\n "summary": {\n "type": "array",\n "maxItems": 5,\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "description": "Plain-language summary sentences shown first in every report."\n },\n "assuranceLevel": {\n "enum": [\n "L1",\n "L2",\n "L3",\n "L4"\n ],\n "description": "L1 self-tested (Saktum Check); L2 independently tested; L3 certified; L4 continuously certified."\n },\n "readiness": {\n "description": "Agent readiness: a second grade beside trust (annotations, descriptions, context cost), never mixed into the trust score.",\n "oneOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "score",\n "grade",\n "toolsAnnotated",\n "toolsDescribed",\n "toolCount",\n "contextTokens"\n ],\n "properties": {\n "score": {\n "type": "integer",\n "minimum": 0,\n "maximum": 100\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ]\n },\n "toolsAnnotated": {\n "type": "integer",\n "minimum": 0\n },\n "toolsDescribed": {\n "type": "integer",\n "minimum": 0\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n },\n "contextTokens": {\n "type": "integer",\n "minimum": 0\n },\n "topImprovement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n ]\n },\n "coverage": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "trustChecksRun": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "capabilities": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capabilities",\n "lethalTrifecta",\n "note"\n ],\n "properties": {\n "capabilities": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capability",\n "label",\n "tools",\n "basis"\n ],\n "properties": {\n "capability": {\n "type": "string"\n },\n "label": {\n "type": "string",\n "maxLength": 400\n },\n "tools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "maxItems": 20\n },\n "basis": {\n "enum": [\n "declared",\n "inferred"\n ]\n }\n }\n }\n },\n "lethalTrifecta": {\n "type": "boolean"\n },\n "note": {\n "type": "string",\n "maxLength": 400\n }\n }\n },\n "functional": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "ran",\n "calledTools",\n "notCalled",\n "calls"\n ],\n "properties": {\n "ran": {\n "type": "boolean"\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n },\n "calledTools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "survived": {\n "type": "boolean"\n },\n "notCalled": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "why"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "why": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "calls": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "purpose",\n "outcome",\n "latencyMs",\n "problems"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "purpose": {\n "type": "string",\n "maxLength": 400\n },\n "outcome": {\n "type": "string",\n "maxLength": 400\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n },\n "load": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "operation",\n "latency",\n "levels",\n "verdicts"\n ],\n "properties": {\n "operation": {\n "type": "string",\n "maxLength": 400\n },\n "latency": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "p50": {\n "type": "number"\n },\n "p95": {\n "type": "number"\n },\n "samples": {\n "type": "integer"\n }\n }\n },\n "levels": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "concurrency",\n "requests",\n "ok",\n "rateLimited",\n "errors",\n "p95",\n "throughput"\n ],\n "properties": {\n "concurrency": {\n "type": "number",\n "minimum": 0\n },\n "requests": {\n "type": "number",\n "minimum": 0\n },\n "ok": {\n "type": "number",\n "minimum": 0\n },\n "rateLimited": {\n "type": "number",\n "minimum": 0\n },\n "errors": {\n "type": "number",\n "minimum": 0\n },\n "p95": {\n "type": "number",\n "minimum": 0\n },\n "throughput": {\n "type": "number",\n "minimum": 0\n }\n }\n }\n },\n "memoryGrowthMb": {\n "type": "number"\n },\n "verdicts": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "id",\n "tool",\n "status",\n "problems"\n ],\n "properties": {\n "id": {\n "type": "string",\n "maxLength": 400\n },\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped"\n ]\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n }\n }\n }\n },\n "suppressions": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "check",\n "reason"\n ],\n "properties": {\n "check": {\n "type": "string",\n "maxLength": 400\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n },\n "$defs": {\n "finding": {\n "type": "object",\n "required": [\n "check",\n "pack",\n "status",\n "severity",\n "title"\n ],\n "additionalProperties": false,\n "properties": {\n "check": {\n "type": "string"\n },\n "pack": {\n "type": "string"\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped",\n "inconclusive",\n "info"\n ]\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "scored": {\n "type": "boolean"\n },\n "title": {\n "type": "string"\n },\n "subject": {\n "type": "string"\n },\n "message": {\n "type": "string"\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "evidence": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "hash": {\n "type": "string"\n },\n "excerpt": {\n "type": "string",\n "maxLength": 240\n }\n }\n },\n "suppressed": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "reason"\n ],\n "properties": {\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n}\n', "test-cases.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/test-cases/0.1.json",\n "title": "Saktum Trust Check functional test cases (saktum.tests.yaml)",\n "type": "object",\n "required": ["testsFormat", "tests"],\n "additionalProperties": false,\n "properties": {\n "testsFormat": { "const": "0.1" },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "required": ["id", "tool", "input", "expect"],\n "additionalProperties": false,\n "properties": {\n "id": { "type": "string" },\n "tool": { "type": "string" },\n "input": { "type": "object" },\n "sideEffects": { "type": "boolean", "default": false, "description": "Tests with side effects run only against owned targets." },\n "expect": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "isError": { "type": "boolean" },\n "textContains": { "type": "string" },\n "structured": { "type": "object" },\n "outputSchema": { "type": "boolean" },\n "latencyMs": { "type": "object", "properties": { "lt": { "type": "integer" } }, "additionalProperties": false }\n }\n }\n }\n }\n }\n }\n}\n' };
19096
- EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n', "auth.yaml": `packFormat: "0.1"
19096
+ EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n - id: ax.client-compat\n title: Fits common client and model-provider constraints\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: client-compat }]\n fix: Use tool names of 1 to 64 letters, digits, underscores and hyphens, keep them short enough for a server prefix, and keep the tool count manageable.\n', "auth.yaml": `packFormat: "0.1"
19097
19097
  id: auth
19098
19098
  version: 0.1.0
19099
19099
  category: auth
@@ -19280,7 +19280,7 @@ checks:
19280
19280
  steps: [{ action: analyse, analyser: perf-concurrency }]
19281
19281
  fix: Keep p95 latency low, answer overload with HTTP 429 and Retry-After instead of errors, and set limits per client.
19282
19282
  references: ["OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (resource abuse)", "CWE-770"]
19283
- `, "security.yaml": 'packFormat: "0.1"\nid: security\nversion: 0.1.0\ncategory: security\ndescription: Passive security checks on what the server tells agents and users.\nchecks:\n - id: sec.description.hidden-instructions\n title: No instructions to the agent in tool descriptions or schemas\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: hidden-instructions }]\n fix: Describe what each tool does; never instruct the agent (for example to read other data, send data elsewhere or hide actions from the user).\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP03 Tool Poisoning", level: best-practice }]\n references: ["MCP security best practices", "CWE-1427", "OWASP MCP Top 10: MCP03 Tool Poisoning", "OWASP MCP Top 10: MCP06 Intent Flow Subversion"]\n - id: sec.description.invisible-text\n title: No invisible or bidirectional control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: invisible-text }]\n fix: Remove zero-width and bidirectional control characters from names, descriptions and schemas.\n references: ["CWE-1007", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.description.control-characters\n title: No escape sequences or control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: control-characters }]\n fix: Remove terminal escape sequences and control characters; clients may print tool text to a terminal.\n references: ["CWE-150", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.secrets.exposed\n title: No secrets in tool definitions or responses\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: secrets }]\n fix: Remove keys, tokens and passwords from descriptions, schemas, defaults, examples and error messages; load them from a secret store at runtime.\n references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "CWE-798", "CWE-200"]\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP01 Token Mismanagement and Secret Exposure", level: best-practice }]\n - id: sec.errors.leakage\n title: Errors do not expose internals\n severity: medium\n safety: passive\n steps: [{ action: analyse, analyser: error-leakage }]\n fix: Return short, actionable error messages; log stack traces, file paths and database errors on the server only.\n references: ["OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (errors leak internals)", "CWE-209"]\n normative: [{ source: "OWASP MCP Top 10", clause: "Information exposure through errors", level: best-practice }]\n\n' };
19283
+ `, "security.yaml": 'packFormat: "0.1"\nid: security\nversion: 0.1.0\ncategory: security\ndescription: Passive security checks on what the server tells agents and users.\nchecks:\n - id: sec.description.hidden-instructions\n title: No instructions to the agent in tool descriptions or schemas\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: hidden-instructions }]\n fix: Describe what each tool does; never instruct the agent (for example to read other data, send data elsewhere or hide actions from the user).\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP03 Tool Poisoning", level: best-practice }]\n references: ["MCP security best practices", "CWE-1427", "OWASP MCP Top 10: MCP03 Tool Poisoning", "OWASP MCP Top 10: MCP06 Intent Flow Subversion"]\n - id: sec.description.invisible-text\n title: No invisible or bidirectional control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: invisible-text }]\n fix: Remove zero-width and bidirectional control characters from names, descriptions and schemas.\n references: ["CWE-1007", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.description.control-characters\n title: No escape sequences or control characters\n severity: high\n safety: passive\n steps: [{ action: analyse, analyser: control-characters }]\n fix: Remove terminal escape sequences and control characters; clients may print tool text to a terminal.\n references: ["CWE-150", "OWASP MCP Top 10: MCP03 Tool Poisoning"]\n - id: sec.secrets.exposed\n title: No secrets in tool definitions or responses\n severity: critical\n safety: passive\n steps: [{ action: analyse, analyser: secrets }]\n fix: Remove keys, tokens and passwords from descriptions, schemas, defaults, examples and error messages; load them from a secret store at runtime.\n references: ["OWASP MCP Top 10: MCP01 Token Mismanagement and Secret Exposure", "CWE-798", "CWE-200"]\n normative: [{ source: "OWASP MCP Top 10", clause: "MCP01 Token Mismanagement and Secret Exposure", level: best-practice }]\n - id: sec.errors.leakage\n title: Errors do not expose internals\n severity: medium\n safety: passive\n steps: [{ action: analyse, analyser: error-leakage }]\n fix: Return short, actionable error messages; log stack traces, file paths and database errors on the server only.\n references: ["OWASP MCP Top 10: MCP08 Lack of Audit and Telemetry (errors leak internals)", "CWE-209"]\n normative: [{ source: "OWASP MCP Top 10", clause: "Information exposure through errors", level: best-practice }]\n - id: sec.http.origin\n title: Local HTTP servers refuse requests from foreign web origins\n severity: high\n safety: passive\n appliesTo: { transports: [streamable-http] }\n steps: [{ action: analyse, analyser: origin-validation }]\n fix: Validate the Origin header on every request and refuse origins you do not expect (HTTP 403); bind local servers to 127.0.0.1, not all interfaces.\n references: ["MCP specification: transports, security warning (DNS rebinding)", "CWE-346", "OWASP MCP Top 10: MCP07 Insufficient Authentication and Authorization"]\n normative: [{ source: "MCP specification", version: "verify-latest", clause: "Transports: Streamable HTTP security warning, validate the Origin header", level: MUST }]\n' };
19284
19284
  }
19285
19285
  });
19286
19286
 
@@ -20202,6 +20202,267 @@ init_contracts();
20202
20202
  // packages/testkit-core/dist/analysers.js
20203
20203
  init_contracts();
20204
20204
 
20205
+ // packages/testkit-core/dist/capabilities.js
20206
+ var CAPABILITY_LABELS = {
20207
+ "reads-private-data": "reads private or account data",
20208
+ "untrusted-content": "brings in untrusted content (web pages, emails, documents)",
20209
+ network: "reaches the network",
20210
+ "code-execution": "runs code or commands",
20211
+ filesystem: "reads or writes files",
20212
+ "writes-or-deletes": "changes or deletes data",
20213
+ "sends-messages": "sends messages or posts content",
20214
+ money: "moves money or makes purchases"
20215
+ };
20216
+ var RULES = [
20217
+ { cap: "code-execution", name: /(^|[_-])(exec|execute|eval|shell|bash|terminal|psql|run_command|run_code|run_script)([_-]|$)|exec_in_/i, text: /\b(execute|run)s? (a |an |the )?(shell|terminal|bash|command|script|code|program|sql|query)\b/i, strong: /\b(arbitrary (code|commands?)|shell commands?|(executes?|runs?) (shell|terminal|bash) commands?|runs? (javascript|python) code|starts? (a |an )?(new )?(terminal|shell) (process|session))\b/i, arg: /^(command|cmd|script|code|shell)$/i },
20218
+ { cap: "filesystem", name: /(^|[_-])(read_file|write_file|edit_file|move_file|list_directory|create_directory|directory_tree|filesystem|fs)([_-]|$)/i, text: /\b(local )?file ?system\b|\bon (the )?(local )?(disk|machine)\b|\b(files?|director(y|ies)) (on|in) the (user'?s )?(computer|machine|disk)\b/i, arg: /^(path|filepath|file_path|directory|dir)$/i },
20219
+ { cap: "network", name: /(^|[_-])(fetch|http|download|webhook|crawl|scrape|browse|navigate)([_-]|$)/i, text: /\b(fetch(es)? (a |the )?(url|web ?page|website)|http requests?|crawls?|scrapes?|web ?hooks?|downloads? .{0,20} from)\b/i, strong: /\b(http requests?|fetch(es)? (a |the |any )?(url|web ?page|website))\b/i, arg: /^(url|uri|endpoint|webhook|href)$/i },
20220
+ { cap: "untrusted-content", name: /(^|[_-])(fetch|crawl|scrape|browse|web_search|read_email|get_email|read_emails|read_message|read_messages)([_-]|$)/i, text: /\b(web ?pages?|websites?|internet|emails?|inbox|scrap(e|es|ing)|crawl(s|ing)?)\b/i, strong: /\b(search(es)? the (web|internet)|web search|scrap(e|es|ing) (web|pages|sites)|crawl(s|ing)? (a |the )?(web|site|website)|web ?pages?)\b/i },
20221
+ { cap: "reads-private-data", arg: /^(sql)$/i, name: /(^|[_-])(query|sql|customers?|contacts?|inbox|calendar|crm|database|db)([_-]|$)/i, text: /\b(reads?|retrieves?|gets?|lists?|search(es)?|quer(y|ies)|looks? up|fetch(es)?|returns?)\b.{0,40}\b(database|customers?|contacts?|account (data|details)|personal|private|inbox|calendar|crm)\b/i },
20222
+ { cap: "writes-or-deletes", name: /(^|[_-])(create|update|delete|remove|write|insert|upsert|drop|patch|edit|modify|move|rename|overwrite|reset|commit|push|purge)([_-]|$)/i, text: /\b(deletes?|removes?|overwrites?|modif(y|ies)|updates?|creates?|writes?) (a |an |the |one or more )?(new )?\w+/i },
20223
+ { cap: "sends-messages", name: /(^|[_-])(send|notify|reply|tweet|sms|send_message|send_email|post_message)([_-]|$)/i, text: /\bsends? (an? )?(new )?(email|message|sms|notification)|\bposts? (a |an )?(new )?(message|comment|tweet|reply)\b|\brepl(y|ies) to (a |the )?(specific )?(message|thread|email)/i, strong: /\bsends? (an? )?(email|sms|text message|slack message)s?\b|\bposts? (a |an )?(new )?message to (a |the )?(slack )?channel\b/i },
20224
+ { cap: "money", name: /(^|[_-])(pay|payment|payments|charge|refund|refunds|invoice|invoices|payout|purchase|billing)([_-]|$)/i, text: /\b(payments?|charges? (a |the )?(card|customer)|refunds?|invoices?|transfers? (funds|money)|purchases?)\b/i, strong: /\b(refunds? (a |the )?(payment|charge)|charges? (a |the )?(card|customer)|creates? (a |an )?(invoice|payment|payout))\b/i }
20225
+ ];
20226
+ function capabilityProfile(tools) {
20227
+ const found = /* @__PURE__ */ new Map();
20228
+ const add = (c, tool, declared = false) => {
20229
+ const e = found.get(c) ?? { tools: /* @__PURE__ */ new Set(), declared: false };
20230
+ e.tools.add(sanitizeText(tool, 60));
20231
+ e.declared ||= declared;
20232
+ found.set(c, e);
20233
+ };
20234
+ for (const t of tools) {
20235
+ const a = t.annotations ?? {};
20236
+ if (a.openWorldHint === true)
20237
+ add("network", t.name, true);
20238
+ if (a.destructiveHint === true || a.readOnlyHint === false)
20239
+ add("writes-or-deletes", t.name, true);
20240
+ const args = Object.keys((t.inputSchema ?? {}).properties ?? {});
20241
+ const desc = (t.description ?? "").trim().split(/(?<=[.!?])\s/)[0].slice(0, 280);
20242
+ for (const r of RULES) {
20243
+ if (r.cap === "writes-or-deletes" && a.readOnlyHint === true)
20244
+ continue;
20245
+ const signals = Number(r.name.test(t.name)) + Number(r.text.test(desc)) + Number(Boolean(r.arg && args.some((x) => r.arg.test(x))));
20246
+ if (signals >= 2 || r.strong && r.strong.test(desc))
20247
+ add(r.cap, t.name);
20248
+ }
20249
+ }
20250
+ const has2 = (c) => found.has(c);
20251
+ const lethalTrifecta = has2("reads-private-data") && has2("untrusted-content") && (has2("network") || has2("sends-messages"));
20252
+ const order = Object.keys(CAPABILITY_LABELS);
20253
+ return {
20254
+ capabilities: order.filter(has2).map((c) => ({ capability: c, label: CAPABILITY_LABELS[c], tools: [...found.get(c).tools].slice(0, 8), basis: found.get(c).declared ? "declared" : "inferred" })),
20255
+ lethalTrifecta,
20256
+ note: "Inferred from annotations, tool names, descriptions and argument names; it describes what the tools appear able to do, not a finding."
20257
+ };
20258
+ }
20259
+
20260
+ // packages/testkit-core/dist/provider.js
20261
+ var words = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
20262
+ var READ = /* @__PURE__ */ new Set(["get", "list", "read", "search", "find", "fetch", "query", "describe", "show", "view", "lookup", "count", "check", "status", "retrieve", "browse", "inspect", "resolve", "validate", "analyze", "analyse", "summarize", "summarise", "explain", "compare", "preview", "info", "stats", "download", "export", "diff", "log", "history", "whoami", "ping", "health", "extract", "crawl", "scrape", "research", "map", "summary", "lookup", "tail", "watch"]);
20263
+ var DESTROY = /* @__PURE__ */ new Set(["delete", "remove", "drop", "purge", "destroy", "reset", "revoke", "cancel", "terminate", "kill", "wipe", "truncate", "overwrite", "uninstall", "unpublish", "archive"]);
20264
+ var WRITE = /* @__PURE__ */ new Set(["create", "add", "insert", "update", "set", "put", "patch", "edit", "write", "save", "upload", "send", "post", "publish", "deploy", "run", "execute", "exec", "start", "stop", "restart", "move", "rename", "merge", "commit", "push", "install", "enable", "disable", "assign", "invite", "approve", "pay", "charge", "refund", "transfer", "book", "order", "replace", "import", "sync", "trigger", "schedule", "close", "open", "submit", "apply", "generate", "upsert"]);
20265
+ var IDEMPOTENT_WRITE = /* @__PURE__ */ new Set(["set", "put", "update", "upsert", "enable", "disable", "replace"]);
20266
+ function suggestAnnotations(tools) {
20267
+ const caps = capabilityProfile(tools).capabilities;
20268
+ const hasCap = (tool, c) => caps.some((x) => x.capability === c && x.tools.includes(sanitizeText(tool, 60)));
20269
+ return tools.map((t) => {
20270
+ const w = words(t.name);
20271
+ const verb = w.find((x) => READ.has(x) || DESTROY.has(x) || WRITE.has(x));
20272
+ const current = t.annotations && Object.keys(t.annotations).length ? t.annotations : void 0;
20273
+ const openWorld = hasCap(t.name, "network") || hasCap(t.name, "untrusted-content") || hasCap(t.name, "sends-messages") ? true : void 0;
20274
+ let suggested;
20275
+ let reason;
20276
+ if (verb && DESTROY.has(verb)) {
20277
+ suggested = { readOnlyHint: false, destructiveHint: true, idempotentHint: verb === "delete" || verb === "remove" ? true : void 0, openWorldHint: openWorld };
20278
+ reason = `"${verb}" usually deletes or overwrites data`;
20279
+ } else if (verb && WRITE.has(verb)) {
20280
+ suggested = { readOnlyHint: false, destructiveHint: false, idempotentHint: IDEMPOTENT_WRITE.has(verb) ? true : void 0, openWorldHint: openWorld };
20281
+ reason = `"${verb}" usually changes data without destroying it`;
20282
+ } else if (verb && READ.has(verb)) {
20283
+ suggested = { readOnlyHint: true, openWorldHint: openWorld };
20284
+ reason = `"${verb}" usually only reads`;
20285
+ } else {
20286
+ reason = "the name does not say whether it reads or changes data: decide and annotate it";
20287
+ }
20288
+ const clean = suggested ? Object.fromEntries(Object.entries(suggested).filter(([, v]) => v !== void 0)) : void 0;
20289
+ let conflict;
20290
+ if (current?.readOnlyHint === true && verb && (DESTROY.has(verb) || WRITE.has(verb)))
20291
+ conflict = `declared read-only, but "${verb}" suggests it changes data`;
20292
+ if (current?.destructiveHint === false && verb && DESTROY.has(verb))
20293
+ conflict = `declared non-destructive, but "${verb}" suggests it deletes or overwrites`;
20294
+ return { tool: t.name, current, suggested: clean, reason, confidence: verb ? "likely" : "review", conflict };
20295
+ });
20296
+ }
20297
+ var tsValue = (o) => `{ ${Object.entries(o).map(([k, v]) => `${k}: ${v}`).join(", ")} }`;
20298
+ var pyValue = (o) => `ToolAnnotations(${Object.entries(o).map(([k, v]) => `${k}=${v === true ? "True" : v === false ? "False" : v}`).join(", ")})`;
20299
+ function renderFix(tools, format = "ts") {
20300
+ const s = suggestAnnotations(tools);
20301
+ if (format === "json")
20302
+ return JSON.stringify(s, null, 2) + "\n";
20303
+ const todo = s.filter((x) => !x.current && x.suggested);
20304
+ const review = s.filter((x) => !x.current && !x.suggested);
20305
+ const conflicts = s.filter((x) => x.conflict);
20306
+ const lines = [];
20307
+ lines.push(`Saktum fix: annotation suggestions for ${tools.length} tools (review each before applying; Saktum suggests, you decide).`);
20308
+ lines.push(`${todo.length} to add, ${review.length} need your judgement, ${conflicts.length} possible conflicts, ${s.filter((x) => x.current && !x.conflict).length} already annotated.`);
20309
+ lines.push("");
20310
+ if (format === "py")
20311
+ lines.push("from mcp.types import ToolAnnotations", "");
20312
+ for (const x of todo) {
20313
+ lines.push(format === "py" ? `# ${sanitizeText(x.tool, 60)}: ${x.reason}
20314
+ @mcp.tool(annotations=${pyValue(x.suggested)})` : `// ${sanitizeText(x.tool, 60)}: ${x.reason}
20315
+ annotations: ${tsValue(x.suggested)},`);
20316
+ lines.push("");
20317
+ }
20318
+ if (review.length) {
20319
+ lines.push(format === "py" ? "# Decide for these tools:" : "// Decide for these tools:");
20320
+ for (const x of review)
20321
+ lines.push(`${format === "py" ? "#" : "//"} ${sanitizeText(x.tool, 60)}: ${x.reason}`);
20322
+ lines.push("");
20323
+ }
20324
+ if (conflicts.length) {
20325
+ lines.push(format === "py" ? "# Possible conflicts with your current annotations:" : "// Possible conflicts with your current annotations:");
20326
+ for (const x of conflicts)
20327
+ lines.push(`${format === "py" ? "#" : "//"} ${sanitizeText(x.tool, 60)}: ${x.conflict}`);
20328
+ lines.push("");
20329
+ }
20330
+ const short = tools.filter((t) => (t.description ?? "").trim().length < 20);
20331
+ if (short.length)
20332
+ lines.push(`${format === "py" ? "#" : "//"} Also write a one-sentence description (what it does, when to use it) for: ${short.map((t) => sanitizeText(t.name, 40)).join(", ")}`);
20333
+ const cost = contextCost(tools);
20334
+ if (cost.contextCostTokens > 1e4)
20335
+ lines.push(`${format === "py" ? "#" : "//"} Context cost is ${cost.contextCostTokens.toLocaleString("en-US")} tokens per turn; the largest tools are ${cost.largestTools.slice(0, 3).map((x) => `${x.tool} (${x.tokens})`).join(", ")}: shorten their descriptions and schemas first.`);
20336
+ return lines.join("\n").trimEnd() + "\n";
20337
+ }
20338
+ function toolsLock(tools, server) {
20339
+ const sorted = [...tools].sort((a, b) => a.name.localeCompare(b.name));
20340
+ return { lockFormat: "0.1", server, createdAt: (/* @__PURE__ */ new Date()).toISOString(), tools: sorted.map((t) => ({ ...t, hash: sha256Tag(canonicalize(t)) })) };
20341
+ }
20342
+ var typeOf = (s) => JSON.stringify(s?.type ?? null);
20343
+ function schemaChanges(tool, label, a, b, out, forInput) {
20344
+ if (!a && !b)
20345
+ return;
20346
+ if (a && !b) {
20347
+ out.push({ tool, kind: forInput ? "change" : "breaking", detail: `${label} schema removed` });
20348
+ return;
20349
+ }
20350
+ if (!a && b) {
20351
+ out.push({ tool, kind: "addition", detail: `${label} schema added` });
20352
+ return;
20353
+ }
20354
+ const pa = a.properties ?? {}, pb = b.properties ?? {};
20355
+ const ra = new Set(a.required ?? []), rb = new Set(b.required ?? []);
20356
+ for (const k of Object.keys(pa)) {
20357
+ if (!(k in pb)) {
20358
+ out.push({ tool, kind: "breaking", detail: `${label} field "${k}" removed` });
20359
+ continue;
20360
+ }
20361
+ if (typeOf(pa[k]) !== typeOf(pb[k]))
20362
+ out.push({ tool, kind: "breaking", detail: `${label} field "${k}" changed type from ${typeOf(pa[k])} to ${typeOf(pb[k])}` });
20363
+ const ea = pa[k].enum, eb = pb[k].enum;
20364
+ if (Array.isArray(ea) && Array.isArray(eb)) {
20365
+ const removed = ea.filter((v) => !eb.some((w) => JSON.stringify(w) === JSON.stringify(v)));
20366
+ const added = eb.filter((v) => !ea.some((w) => JSON.stringify(w) === JSON.stringify(v)));
20367
+ if (removed.length)
20368
+ out.push({ tool, kind: forInput ? "breaking" : "change", detail: `${label} field "${k}" no longer allows ${removed.map((v) => JSON.stringify(v)).join(", ")}` });
20369
+ if (added.length)
20370
+ out.push({ tool, kind: forInput ? "addition" : "breaking", detail: `${label} field "${k}" now allows ${added.map((v) => JSON.stringify(v)).join(", ")}` });
20371
+ }
20372
+ }
20373
+ for (const k of Object.keys(pb))
20374
+ if (!(k in pa))
20375
+ out.push({ tool, kind: forInput && rb.has(k) ? "breaking" : "addition", detail: `${label} field "${k}" added${forInput && rb.has(k) ? " as required" : ""}` });
20376
+ if (forInput) {
20377
+ for (const k of rb)
20378
+ if (!ra.has(k) && k in pa)
20379
+ out.push({ tool, kind: "breaking", detail: `input field "${k}" is now required` });
20380
+ }
20381
+ if (!forInput) {
20382
+ for (const k of ra)
20383
+ if (!rb.has(k) && k in pb)
20384
+ out.push({ tool, kind: "breaking", detail: `output field "${k}" is no longer guaranteed` });
20385
+ }
20386
+ if (forInput && a.additionalProperties !== false && b.additionalProperties === false)
20387
+ out.push({ tool, kind: "breaking", detail: "input no longer accepts extra fields" });
20388
+ }
20389
+ function diffLocks(a, b) {
20390
+ const out = [];
20391
+ const ma = new Map(a.tools.map((t) => [t.name, t])), mb = new Map(b.tools.map((t) => [t.name, t]));
20392
+ for (const [n2] of ma)
20393
+ if (!mb.has(n2))
20394
+ out.push({ tool: n2, kind: "breaking", detail: "tool removed" });
20395
+ for (const [n2] of mb)
20396
+ if (!ma.has(n2))
20397
+ out.push({ tool: n2, kind: "addition", detail: "tool added" });
20398
+ for (const [n2, ta] of ma) {
20399
+ const tb = mb.get(n2);
20400
+ if (!tb)
20401
+ continue;
20402
+ schemaChanges(n2, "input", ta.inputSchema, tb.inputSchema, out, true);
20403
+ schemaChanges(n2, "output", ta.outputSchema, tb.outputSchema, out, false);
20404
+ const aa = ta.annotations ?? {}, ab = tb.annotations ?? {};
20405
+ if (aa.readOnlyHint === true && ab.readOnlyHint !== true)
20406
+ out.push({ tool: n2, kind: "risky", detail: "no longer declared read-only: re-review before agents use it" });
20407
+ if (aa.destructiveHint !== true && ab.destructiveHint === true)
20408
+ out.push({ tool: n2, kind: "risky", detail: "now declared destructive" });
20409
+ if (aa.openWorldHint !== true && ab.openWorldHint === true)
20410
+ out.push({ tool: n2, kind: "risky", detail: "now reaches outside systems (openWorldHint)" });
20411
+ if ((ta.description ?? "") !== (tb.description ?? ""))
20412
+ out.push({ tool: n2, kind: "risky", detail: "description changed: review it for new instructions to agents (silent tool changes, OWASP MCP03)" });
20413
+ }
20414
+ const has2 = (k) => out.some((c) => c.kind === k);
20415
+ const semver = has2("breaking") ? "major" : has2("addition") ? "minor" : out.length ? "patch" : "none";
20416
+ const n = (k) => out.filter((c) => c.kind === k).length;
20417
+ return { changes: out, semver, summary: out.length ? `${n("breaking")} breaking, ${n("risky")} to review, ${n("addition")} additions, ${n("change")} other changes; suggested version bump: ${semver}.` : "No changes to tools." };
20418
+ }
20419
+ function docsFor(tools, name, launch) {
20420
+ const kind = (t) => {
20421
+ const a = t.annotations ?? {};
20422
+ return a.readOnlyHint === true ? "reads only" : a.destructiveHint === true ? "can delete or overwrite" : a.readOnlyHint === false ? "changes data" : "not declared";
20423
+ };
20424
+ const firstSentence = (d) => sanitizeText((d ?? "").trim().split(/(?<=[.!?])\s/)[0] ?? "", 160).replace(/\|/g, "/");
20425
+ const req = (t) => ((t.inputSchema ?? {}).required ?? []).join(", ") || "none";
20426
+ const id = name.replace(/[^a-zA-Z0-9_-]/g, "-").replace(/^-+|-+$/g, "") || "server";
20427
+ const local = launch.url ? void 0 : { command: launch.command, args: launch.args ?? [] };
20428
+ const lines = [
20429
+ `## Tools`,
20430
+ "",
20431
+ "| Tool | What it does | Effect | Required arguments |",
20432
+ "| --- | --- | --- | --- |",
20433
+ ...tools.map((t) => `| \`${sanitizeText(t.name, 60)}\` | ${firstSentence(t.description)} | ${kind(t)} | ${req(t)} |`),
20434
+ "",
20435
+ `## Use it`,
20436
+ "",
20437
+ "**Claude Desktop** (`claude_desktop_config.json`) and **Cursor** (`.cursor/mcp.json`):",
20438
+ "",
20439
+ "```json",
20440
+ JSON.stringify({ mcpServers: { [id]: local ?? { url: launch.url } } }, null, 2),
20441
+ "```",
20442
+ "",
20443
+ "**VS Code** (`.vscode/mcp.json`):",
20444
+ "",
20445
+ "```json",
20446
+ JSON.stringify({ servers: { [id]: local ? { type: "stdio", ...local } : { type: "http", url: launch.url } } }, null, 2),
20447
+ "```",
20448
+ "",
20449
+ `_Generated by Saktum Check. Check the exact configuration format in each client's documentation._`
20450
+ ];
20451
+ return lines.join("\n") + "\n";
20452
+ }
20453
+ function clientCompatibility(tools) {
20454
+ const issues = [];
20455
+ const bad = tools.filter((t) => !/^[a-zA-Z0-9_-]{1,64}$/.test(t.name));
20456
+ if (bad.length)
20457
+ issues.push(`${bad.length} tool name(s) use characters or a length that many model providers reject in function names (allowed: 1 to 64 letters, digits, underscores and hyphens): ${bad.slice(0, 5).map((t) => sanitizeText(t.name, 60)).join(", ")}`);
20458
+ const long = tools.filter((t) => t.name.length > 40 && t.name.length <= 64);
20459
+ if (long.length)
20460
+ issues.push(`${long.length} tool name(s) are over 40 characters; clients that prefix the server name may exceed the 64-character limit: ${long.slice(0, 3).map((t) => sanitizeText(t.name, 60)).join(", ")}`);
20461
+ if (tools.length > 40)
20462
+ issues.push(`${tools.length} tools: some clients limit how many tools they load or show; check your target clients and consider grouping or splitting the server`);
20463
+ return issues;
20464
+ }
20465
+
20205
20466
  // node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
20206
20467
  var util_exports = {};
20207
20468
  __export(util_exports, {
@@ -32014,7 +32275,7 @@ var StreamableHTTPClientTransport = class {
32014
32275
  };
32015
32276
 
32016
32277
  // packages/transports/dist/index.js
32017
- var USER_AGENT = "saktum-check/0.2.0 (+https://saktum.dev/check)";
32278
+ var USER_AGENT = "saktum-check/0.3.0 (+https://saktum.dev/check)";
32018
32279
  var LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
32019
32280
  var LimitError = class extends Error {
32020
32281
  };
@@ -32088,6 +32349,11 @@ function guardSize(value, what) {
32088
32349
  async function connect(target) {
32089
32350
  const client = new Client({ name: "saktum-trust-check", version: "0.0.1" }, { capabilities: {} });
32090
32351
  const transport = target.kind === "streamable-http" ? new StreamableHTTPClientTransport(new URL(target.url), { requestInit: { headers: { "User-Agent": USER_AGENT, ...target.headers ?? {} } } }) : new StdioClientTransport({ command: target.command, args: target.args, env: minimalEnv(target.env), cwd: target.cwd, stderr: "ignore" });
32352
+ const tAny = transport;
32353
+ if (!tAny.setProtocolVersion)
32354
+ tAny.setProtocolVersion = (v) => {
32355
+ tAny.protocolVersion = v;
32356
+ };
32091
32357
  const t0 = Date.now();
32092
32358
  await withTimeout(client.connect(transport), LIMITS.connectTimeoutMs, "connect");
32093
32359
  const initMs = Date.now() - t0;
@@ -32144,7 +32410,7 @@ var INIT_BODY = JSON.stringify({
32144
32410
  jsonrpc: "2.0",
32145
32411
  id: 1,
32146
32412
  method: "initialize",
32147
- params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.2.0" } }
32413
+ params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.3.0" } }
32148
32414
  });
32149
32415
  async function httpRequest(url2, init = {}) {
32150
32416
  const t0 = Date.now();
@@ -32428,6 +32694,23 @@ var authAnalysers = {
32428
32694
  return { status: "fail", message: `Answered an invalid token with HTTP ${p.status} instead of 401 (RFC 6750); server errors on bad tokens can hide validation bugs.` };
32429
32695
  }
32430
32696
  };
32697
+ authAnalysers["origin-validation"] = (ctx) => {
32698
+ const u = serverUrl(ctx);
32699
+ if (!u)
32700
+ return skippedNotHttp;
32701
+ if (!isLocal(u))
32702
+ return { status: "skipped", message: "Applies to local HTTP servers, where DNS rebinding can expose them to web pages." };
32703
+ const p = ctx.http?.foreignOrigin;
32704
+ if (!p || p.status === null)
32705
+ return { status: "inconclusive", message: "No answer to a request from a foreign web origin." };
32706
+ if (p.status === 403 || p.status === 400)
32707
+ return { status: "pass", message: `Refuses requests from foreign web origins (HTTP ${p.status}).` };
32708
+ if (p.status === 401)
32709
+ return { status: "pass", message: "Requires sign-in, which also blocks requests from foreign web origins that carry no token." };
32710
+ if (p.status >= 200 && p.status < 300)
32711
+ return { status: "fail", message: "Accepted a request claiming to come from an unrelated web page (Origin: https://attacker.example). Through DNS rebinding, any website the user visits could call this local server." };
32712
+ return { status: "inconclusive", message: `Answered a foreign-origin request with HTTP ${p.status}.` };
32713
+ };
32431
32714
  var AUTH_NEEDS = Object.fromEntries(Object.keys(authAnalysers).map((k) => [k, "none"]));
32432
32715
 
32433
32716
  // packages/testkit-core/dist/leakage.js
@@ -32600,13 +32883,23 @@ var evidenceFor = (tool, text) => tool ? { hash: sha256Tag(JSON.stringify(tool))
32600
32883
  var CONTROL = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/;
32601
32884
  var HIDDEN_INSTRUCTION = [
32602
32885
  /ignore (all |any )?(previous|prior|above) (instructions|messages)/i,
32603
- /do not (tell|mention|inform|reveal to) the user/i,
32886
+ // Concealment, not guidance: honest advice such as "do not tell the user it is in their account" must not match.
32887
+ /\b(do not|don['’]t|never) tell the user\s*[.!]/i,
32888
+ /\bwithout (telling|informing|alerting|notifying) the user\b/i,
32889
+ /\b(do not|don['’]t|never) (mention|reveal|disclose) (this|these) (instructions?|steps?|tool|call)\b/i,
32890
+ /\bhide (this|it|the (action|request|call|upload)) from the user\b/i,
32604
32891
  /<\s*important\s*>/i,
32605
- /\b(system prompt|developer message)\b/i,
32892
+ // Manipulating the agent's instructions, not merely mentioning a system prompt (for example a parameter that appends to one).
32893
+ /\b(ignore|disregard|override|forget|replace) (the |your |all )?(system prompt|developer message|previous instructions)\b/i,
32894
+ /\b(reveal|print|output|leak|show) (the |your )?(system prompt|developer message)\b/i,
32606
32895
  /before using this tool,? (you must |first )?(read|send|call|fetch|upload)/i,
32607
32896
  /(send|upload|post|forward) (the |all |any )?(conversation|chat history|credentials|api keys?|secrets?|tokens?) to/i
32608
32897
  ];
32609
32898
  var coreAnalysers = {
32899
+ "client-compat": ({ tools }) => {
32900
+ const issues = clientCompatibility(tools);
32901
+ return issues.length ? { status: "info", message: issues.join(" ") } : { status: "pass", message: "Tool names and count fit the constraints common to model providers and clients." };
32902
+ },
32610
32903
  "unknown-tool-code": ({ probes }) => {
32611
32904
  const o = probes?.unknownTool;
32612
32905
  if (!o)
@@ -32908,61 +33201,6 @@ function readinessFor(tools) {
32908
33201
  };
32909
33202
  }
32910
33203
 
32911
- // packages/testkit-core/dist/capabilities.js
32912
- var CAPABILITY_LABELS = {
32913
- "reads-private-data": "reads private or account data",
32914
- "untrusted-content": "brings in untrusted content (web pages, emails, documents)",
32915
- network: "reaches the network",
32916
- "code-execution": "runs code or commands",
32917
- filesystem: "reads or writes files",
32918
- "writes-or-deletes": "changes or deletes data",
32919
- "sends-messages": "sends messages or posts content",
32920
- money: "moves money or makes purchases"
32921
- };
32922
- var RULES = [
32923
- { cap: "code-execution", name: /(^|[_-])(exec|execute|eval|shell|bash|terminal|psql|run_command|run_code|run_script)([_-]|$)|exec_in_/i, text: /\b(execute|run)s? (a |an |the )?(shell|terminal|bash|command|script|code|program|sql|query)\b/i, strong: /\b(arbitrary (code|commands?)|shell commands?|(executes?|runs?) (shell|terminal|bash) commands?|runs? (javascript|python) code|starts? (a |an )?(new )?(terminal|shell) (process|session))\b/i, arg: /^(command|cmd|script|code|shell)$/i },
32924
- { cap: "filesystem", name: /(^|[_-])(read_file|write_file|edit_file|move_file|list_directory|create_directory|directory_tree|filesystem|fs)([_-]|$)/i, text: /\b(local )?file ?system\b|\bon (the )?(local )?(disk|machine)\b|\b(files?|director(y|ies)) (on|in) the (user'?s )?(computer|machine|disk)\b/i, arg: /^(path|filepath|file_path|directory|dir)$/i },
32925
- { cap: "network", name: /(^|[_-])(fetch|http|download|webhook|crawl|scrape|browse|navigate)([_-]|$)/i, text: /\b(fetch(es)? (a |the )?(url|web ?page|website)|http requests?|crawls?|scrapes?|web ?hooks?|downloads? .{0,20} from)\b/i, strong: /\b(http requests?|fetch(es)? (a |the |any )?(url|web ?page|website))\b/i, arg: /^(url|uri|endpoint|webhook|href)$/i },
32926
- { cap: "untrusted-content", name: /(^|[_-])(fetch|crawl|scrape|browse|web_search|read_email|get_email|read_emails|read_message|read_messages)([_-]|$)/i, text: /\b(web ?pages?|websites?|internet|emails?|inbox|scrap(e|es|ing)|crawl(s|ing)?)\b/i, strong: /\b(search(es)? the (web|internet)|web search|scrap(e|es|ing) (web|pages|sites)|crawl(s|ing)? (a |the )?(web|site|website)|web ?pages?)\b/i },
32927
- { cap: "reads-private-data", arg: /^(sql)$/i, name: /(^|[_-])(query|sql|customers?|contacts?|inbox|calendar|crm|database|db)([_-]|$)/i, text: /\b(reads?|retrieves?|gets?|lists?|search(es)?|quer(y|ies)|looks? up|fetch(es)?|returns?)\b.{0,40}\b(database|customers?|contacts?|account (data|details)|personal|private|inbox|calendar|crm)\b/i },
32928
- { cap: "writes-or-deletes", name: /(^|[_-])(create|update|delete|remove|write|insert|upsert|drop|patch|edit|modify|move|rename|overwrite|reset|commit|push|purge)([_-]|$)/i, text: /\b(deletes?|removes?|overwrites?|modif(y|ies)|updates?|creates?|writes?) (a |an |the |one or more )?(new )?\w+/i },
32929
- { cap: "sends-messages", name: /(^|[_-])(send|notify|reply|tweet|sms|send_message|send_email|post_message)([_-]|$)/i, text: /\bsends? (an? )?(new )?(email|message|sms|notification)|\bposts? (a |an )?(new )?(message|comment|tweet|reply)\b|\brepl(y|ies) to (a |the )?(specific )?(message|thread|email)/i, strong: /\bsends? (an? )?(email|sms|text message|slack message)s?\b|\bposts? (a |an )?(new )?message to (a |the )?(slack )?channel\b/i },
32930
- { cap: "money", name: /(^|[_-])(pay|payment|payments|charge|refund|refunds|invoice|invoices|payout|purchase|billing)([_-]|$)/i, text: /\b(payments?|charges? (a |the )?(card|customer)|refunds?|invoices?|transfers? (funds|money)|purchases?)\b/i, strong: /\b(refunds? (a |the )?(payment|charge)|charges? (a |the )?(card|customer)|creates? (a |an )?(invoice|payment|payout))\b/i }
32931
- ];
32932
- function capabilityProfile(tools) {
32933
- const found = /* @__PURE__ */ new Map();
32934
- const add = (c, tool, declared = false) => {
32935
- const e = found.get(c) ?? { tools: /* @__PURE__ */ new Set(), declared: false };
32936
- e.tools.add(sanitizeText(tool, 60));
32937
- e.declared ||= declared;
32938
- found.set(c, e);
32939
- };
32940
- for (const t of tools) {
32941
- const a = t.annotations ?? {};
32942
- if (a.openWorldHint === true)
32943
- add("network", t.name, true);
32944
- if (a.destructiveHint === true || a.readOnlyHint === false)
32945
- add("writes-or-deletes", t.name, true);
32946
- const args = Object.keys((t.inputSchema ?? {}).properties ?? {});
32947
- const desc = (t.description ?? "").trim().split(/(?<=[.!?])\s/)[0].slice(0, 280);
32948
- for (const r of RULES) {
32949
- if (r.cap === "writes-or-deletes" && a.readOnlyHint === true)
32950
- continue;
32951
- const signals = Number(r.name.test(t.name)) + Number(r.text.test(desc)) + Number(Boolean(r.arg && args.some((x) => r.arg.test(x))));
32952
- if (signals >= 2 || r.strong && r.strong.test(desc))
32953
- add(r.cap, t.name);
32954
- }
32955
- }
32956
- const has2 = (c) => found.has(c);
32957
- const lethalTrifecta = has2("reads-private-data") && has2("untrusted-content") && (has2("network") || has2("sends-messages"));
32958
- const order = Object.keys(CAPABILITY_LABELS);
32959
- return {
32960
- capabilities: order.filter(has2).map((c) => ({ capability: c, label: CAPABILITY_LABELS[c], tools: [...found.get(c).tools].slice(0, 8), basis: found.get(c).declared ? "declared" : "inferred" })),
32961
- lethalTrifecta,
32962
- note: "Inferred from annotations, tool names, descriptions and argument names; it describes what the tools appear able to do, not a finding."
32963
- };
32964
- }
32965
-
32966
33204
  // packages/testkit-core/dist/functional.js
32967
33205
  init_contracts();
32968
33206
  var FUNCTIONAL_LIMITS = { maxSmokeTools: 8, perCallTimeoutMs: 15e3, survivalWaitMs: 500 };
@@ -33239,7 +33477,7 @@ async function measureLoad(session, op) {
33239
33477
  }
33240
33478
 
33241
33479
  // packages/testkit-core/dist/engine.js
33242
- var ENGINE_VERSION = "0.2.0";
33480
+ var ENGINE_VERSION = "0.3.0";
33243
33481
  var UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
33244
33482
  var INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
33245
33483
  function isProtocolFailure(e) {
@@ -33318,7 +33556,8 @@ async function runTrustCheck(target, opts) {
33318
33556
  const userSuppliedAuth = Object.keys(target.headers ?? {}).some((k) => k.toLowerCase() === "authorization");
33319
33557
  const unauthenticated = await probeInitialize(target.url);
33320
33558
  const invalidToken = await probeInitialize(target.url, { Authorization: `Bearer ${INVALID_TOKEN}` });
33321
- ctx.http = { unauthenticated, invalidToken, userSuppliedAuth };
33559
+ const foreignOrigin = await probeInitialize(target.url, { Origin: "https://attacker.example" });
33560
+ ctx.http = { unauthenticated, invalidToken, foreignOrigin, userSuppliedAuth };
33322
33561
  if (unauthenticated.status === null && !userSuppliedAuth)
33323
33562
  throw new Error(`Could not reach ${target.url}: ${unauthenticated.error}`);
33324
33563
  }
@@ -33690,6 +33929,33 @@ function checksTable(packs, markdown = false) {
33690
33929
  ].join("\n") + "\n";
33691
33930
  return rows.map((x) => `${x.id.padEnd(34)} ${x.area.padEnd(16)} ${x.severity.padEnd(9)} ${x.when.padEnd(32)} ${x.title}`).join("\n") + "\n";
33692
33931
  }
33932
+ function renderPacket(r, signedBy) {
33933
+ const e = (x) => escapeHtml(sanitizeText(x, 2e3));
33934
+ const name = `${r.target.serverInfo?.["name"] ?? r.target.description} ${r.target.serverInfo?.["version"] ?? ""}`.trim();
33935
+ const card = trustCard(r).map((x) => `<tr><td><b>${e(x.dimension)}</b></td><td class="m">${e(x.mark)}</td><td>${e(x.text)}</td></tr>`).join("");
33936
+ const problems = r.findings.filter((f) => f.status === "fail" && !f.suppressed).map((f) => `<tr><td>${e(f.severity)}</td><td>${e(f.title)}</td><td>${e(f.message ?? "")}</td></tr>`).join("") || `<tr><td colspan="3">No failed checks in this run.</td></tr>`;
33937
+ const caps = (r.capabilities?.capabilities ?? []).map((c) => `<li>${e(c.label)} <small>(${e(c.basis)}: ${e(c.tools.join(", "))})</small></li>`).join("") || "<li>No notable capabilities inferred.</li>";
33938
+ const tests = (r.tests ?? []).map((t) => `<li>${t.status === "pass" ? "\u2713" : t.status === "fail" ? "\u2717" : "-"} ${e(t.id)} (${e(t.tool)})</li>`).join("");
33939
+ const declare = ["Data the server processes, and whether it includes personal data", "Where it is hosted, and data residency", "Logging and retention of requests and results", "Credentials it needs and how they are stored", "How to report a security issue, and response time", "Incident notification commitment"].map((q) => `<tr><td>${e(q)}</td><td class="blank">&nbsp;</td></tr>`).join("");
33940
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
33941
+ <title>Security packet: ${e(name)}</title>
33942
+ <style>body{font:14px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#16161d;max-width:860px;margin:32px auto;padding:0 20px}h1{font-size:26px;margin:0 0 4px}h2{font-size:18px;margin:28px 0 8px;border-bottom:2px solid #16161d;padding-bottom:4px}
33943
+ table{border-collapse:collapse;width:100%}td,th{border-top:1px solid #ddd;padding:7px 6px;vertical-align:top;text-align:left}.m{width:28px;text-align:center}.blank{width:55%;border-bottom:1px solid #999}.muted{color:#555}.grades{font-size:20px;font-weight:700}
33944
+ @media print{body{margin:0}h2{break-after:avoid}}</style></head><body>
33945
+ <h1>Security packet: ${e(name)}</h1>
33946
+ <p class="muted">Prepared with Saktum Check ${e(r.tool.version)} on ${e(r.run.startedAt.slice(0, 10))} (${e(r.run.mode)} run). Assurance level ${e(r.assuranceLevel ?? "L1")}: self-tested by the provider; the result is signed so it cannot be changed without detection.</p>
33947
+ <p class="grades">Trust ${e(r.grade ?? "-")} &middot; Agent readiness ${e(r.readiness?.grade ?? "-")}</p>
33948
+ ${(r.summary ?? []).map((l) => `<p>${e(l)}</p>`).join("")}
33949
+ <h2>1. Trust card</h2><table>${card}</table>
33950
+ <h2>2. Open findings</h2><table><tr><th>Severity</th><th>Check</th><th>Detail</th></tr>${problems}</table>
33951
+ <h2>3. What the tools can do</h2><ul>${caps}</ul>${r.capabilities?.lethalTrifecta ? "<p><b>Note:</b> the tools combine private data, untrusted content and an outbound channel; customers should limit what an agent can combine.</p>" : ""}
33952
+ ${tests ? `<h2>4. Provider test cases</h2><ul>${tests}</ul>` : ""}
33953
+ <h2>${tests ? 5 : 4}. Scope and limits</h2>${scopeOfRun(r).map((l) => `<p>${e(l)}</p>`).join("")}<p class="muted">${e(COVERAGE_NOTE)} ${e(DISCLAIMER)}</p>
33954
+ <h2>${tests ? 6 : 5}. Verify this evidence</h2><p>The full signed result accompanies this packet${signedBy ? ` (signed by <code>${e(signedBy)}</code>)` : ""}. Anyone can check it was not altered: <code>npx saktum verify saktum-report.json</code>.</p>
33955
+ <h2>${tests ? 7 : 6}. Provider statements (completed by the provider; not verified by Saktum)</h2><table>${declare}</table>
33956
+ </body></html>
33957
+ `;
33958
+ }
33693
33959
 
33694
33960
  // packages/cli/dist/doctor.js
33695
33961
  import { spawn as spawn2, spawnSync } from "node:child_process";
@@ -33903,6 +34169,56 @@ Badge: ${sanitizeText(o.badge)}` : ""}
33903
34169
  const packs = o.packs ? loadPackDir(o.packs) : existsSync3(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
33904
34170
  process.stdout.write(checksTable(packs, o.markdown));
33905
34171
  });
34172
+ const listTarget = async (targetParts, env, header) => {
34173
+ const target = parseTarget(targetParts);
34174
+ if (target.kind === "stdio" && env.length)
34175
+ target.env = parseEnv(env);
34176
+ if (target.kind === "streamable-http" && header.length)
34177
+ target.headers = parseHeaders(header);
34178
+ const s = await connect(target);
34179
+ try {
34180
+ return { target, tools: await s.listTools(), server: s.serverInfo };
34181
+ } finally {
34182
+ await s.close();
34183
+ }
34184
+ };
34185
+ program2.command("fix").description("Suggest annotations (and other quick fixes) for every tool, as code to paste").argument("<target...>", "https://host/mcp or -- node server.js").option("--format <ts|py|json>", "code style: TypeScript SDK, Python SDK, or JSON", "ts").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (targetParts, o) => {
34186
+ const { tools } = await listTarget(targetParts, o.env, o.header);
34187
+ process.stdout.write(renderFix(tools, o.format));
34188
+ });
34189
+ program2.command("snapshot").description("Write a lock file of the server's tools, to detect breaking or silent changes later with saktum diff").argument("<target...>", "https://host/mcp or -- node server.js").option("--out <file>", "lock file", "saktum.lock.json").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (targetParts, o) => {
34190
+ const { tools, server } = await listTarget(targetParts, o.env, o.header);
34191
+ writeFileSync2(o.out, JSON.stringify(toolsLock(tools, server), null, 2) + "\n");
34192
+ process.stdout.write(`Wrote ${sanitizeText(o.out)} with ${tools.length} tools. Commit it; run saktum diff in CI to catch breaking or silent changes.
34193
+ `);
34194
+ });
34195
+ program2.command("diff").description("Compare tools with a lock file: breaking changes, risky changes (silent tool changes), additions, and the version bump they need").argument("<lock>", "the lock file written by saktum snapshot").argument("[target...]", "a second lock file, or the server to compare (after --)").option("--allow-breaking", "do not fail on breaking or risky changes", false).option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (lock, rest, o) => {
34196
+ const before = JSON.parse(readFileSync4(lock, "utf8"));
34197
+ const after = rest.length === 1 && rest[0].endsWith(".json") ? JSON.parse(readFileSync4(rest[0], "utf8")) : { tools: (await listTarget(rest, o.env, o.header)).tools };
34198
+ const d = diffLocks(before, after);
34199
+ const mark2 = { breaking: "\u2717 BREAKING", risky: "! REVIEW ", addition: "+ ADDED ", change: "~ CHANGED " };
34200
+ for (const c of d.changes)
34201
+ process.stdout.write(`${mark2[c.kind]} ${sanitizeText(c.tool, 60)}: ${sanitizeText(c.detail, 200)}
34202
+ `);
34203
+ process.stdout.write(`
34204
+ ${d.summary}
34205
+ `);
34206
+ exitCode = !o.allowBreaking && d.changes.some((c) => c.kind === "breaking" || c.kind === "risky") ? 1 : 0;
34207
+ });
34208
+ program2.command("docs").description("Generate a Markdown tools table and ready-to-paste client configuration").argument("<target...>", "https://host/mcp or -- npx -y your-package").option("--name <name>", "server name in the client configuration").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (targetParts, o) => {
34209
+ const { target, tools, server } = await listTarget(targetParts, o.env, o.header);
34210
+ const name = o.name ?? String(server?.["name"] ?? "server");
34211
+ process.stdout.write(docsFor(tools, name, target.kind === "stdio" ? { command: target.command, args: target.args } : { url: target.url }));
34212
+ });
34213
+ program2.command("packet").description("Turn a signed result into a printable security packet for customers' security reviews").argument("<result>", "a signed result (saktum-report.json)").option("--out <file>", "HTML packet (print to PDF from a browser)", "saktum-security-packet.html").action((file, o) => {
34214
+ const doc = JSON.parse(readFileSync4(file, "utf8"));
34215
+ const v = verifyDocument(doc);
34216
+ if (!v.valid)
34217
+ throw new Error(`The result's signature is not valid (${v.reason}); a packet must be built from an unaltered signed result.`);
34218
+ writeFileSync2(o.out, renderPacket(doc, v.kid));
34219
+ process.stdout.write(`Wrote ${sanitizeText(o.out)}: open it in a browser and print to PDF. Send it with ${sanitizeText(file)} so customers can verify it.
34220
+ `);
34221
+ });
33906
34222
  program2.command("doctor").description("Check your environment, and why a server will not start or connect").argument("[target...]", "optional: the same target you would pass to check").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (targetParts, o) => {
33907
34223
  const r = await runDoctor(targetParts ?? [], o.env, o.header);
33908
34224
  process.stdout.write(r.text + "\n");