@plune-ai/cairn 0.9.0 → 0.11.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.
- package/README.md +84 -8
- package/dist/agent/check-docs.d.ts +25 -0
- package/dist/agent/check-docs.d.ts.map +1 -0
- package/dist/agent/check-docs.js +57 -0
- package/dist/agent/check-docs.js.map +1 -0
- package/dist/agent/collect-docs.d.ts +94 -0
- package/dist/agent/collect-docs.d.ts.map +1 -0
- package/dist/agent/collect-docs.js +326 -0
- package/dist/agent/collect-docs.js.map +1 -0
- package/dist/agent/graph.d.ts +39 -2
- package/dist/agent/graph.d.ts.map +1 -1
- package/dist/agent/graph.js +113 -4
- package/dist/agent/graph.js.map +1 -1
- package/dist/agent/index.d.ts +14 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +114 -10
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/overlays.d.ts +88 -0
- package/dist/agent/overlays.d.ts.map +1 -0
- package/dist/agent/overlays.js +447 -0
- package/dist/agent/overlays.js.map +1 -0
- package/dist/agent/repair-loop.d.ts +8 -1
- package/dist/agent/repair-loop.d.ts.map +1 -1
- package/dist/agent/repair-loop.js +18 -3
- package/dist/agent/repair-loop.js.map +1 -1
- package/dist/analyze/index.d.ts +1 -1
- package/dist/analyze/index.d.ts.map +1 -1
- package/dist/analyze/index.js +3 -2
- package/dist/analyze/index.js.map +1 -1
- package/dist/api/adversarial.d.ts +1 -1
- package/dist/api/adversarial.js +1 -1
- package/dist/api/collection.d.ts +20 -0
- package/dist/api/collection.d.ts.map +1 -0
- package/dist/api/collection.js +357 -0
- package/dist/api/collection.js.map +1 -0
- package/dist/api/derived.d.ts +179 -0
- package/dist/api/derived.d.ts.map +1 -0
- package/dist/api/derived.js +852 -0
- package/dist/api/derived.js.map +1 -0
- package/dist/api/discover.d.ts +66 -0
- package/dist/api/discover.d.ts.map +1 -0
- package/dist/api/discover.js +125 -0
- package/dist/api/discover.js.map +1 -0
- package/dist/api/flows.d.ts +194 -0
- package/dist/api/flows.d.ts.map +1 -0
- package/dist/api/flows.js +663 -0
- package/dist/api/flows.js.map +1 -0
- package/dist/api/guard.d.ts +19 -0
- package/dist/api/guard.d.ts.map +1 -1
- package/dist/api/guard.js +18 -4
- package/dist/api/guard.js.map +1 -1
- package/dist/api/openapi.d.ts +17 -1
- package/dist/api/openapi.d.ts.map +1 -1
- package/dist/api/openapi.js +64 -3
- package/dist/api/openapi.js.map +1 -1
- package/dist/api/runner.d.ts.map +1 -1
- package/dist/api/runner.js +18 -14
- package/dist/api/runner.js.map +1 -1
- package/dist/api/two-actor.d.ts +165 -0
- package/dist/api/two-actor.d.ts.map +1 -0
- package/dist/api/two-actor.js +627 -0
- package/dist/api/two-actor.js.map +1 -0
- package/dist/artifacts/contract.d.ts +1 -1
- package/dist/artifacts/contract.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +5 -0
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +14 -10
- package/dist/artifacts/index.js.map +1 -1
- package/dist/artifacts/report.d.ts +29 -2
- package/dist/artifacts/report.d.ts.map +1 -1
- package/dist/artifacts/report.js +65 -1
- package/dist/artifacts/report.js.map +1 -1
- package/dist/artifacts/testcase-md.d.ts +18 -0
- package/dist/artifacts/testcase-md.d.ts.map +1 -1
- package/dist/artifacts/testcase-md.js +15 -1
- package/dist/artifacts/testcase-md.js.map +1 -1
- package/dist/browser/api-traffic.d.ts +85 -0
- package/dist/browser/api-traffic.d.ts.map +1 -0
- package/dist/browser/api-traffic.js +283 -0
- package/dist/browser/api-traffic.js.map +1 -0
- package/dist/browser/backends/playwright-cli.d.ts.map +1 -1
- package/dist/browser/backends/playwright-cli.js +3 -0
- package/dist/browser/backends/playwright-cli.js.map +1 -1
- package/dist/browser/backends/playwright-lib.d.ts +84 -1
- package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
- package/dist/browser/backends/playwright-lib.js +677 -32
- package/dist/browser/backends/playwright-lib.js.map +1 -1
- package/dist/browser/click-effect.d.ts +84 -0
- package/dist/browser/click-effect.d.ts.map +1 -0
- package/dist/browser/click-effect.js +235 -0
- package/dist/browser/click-effect.js.map +1 -0
- package/dist/browser/gateway.d.ts +9 -1
- package/dist/browser/gateway.d.ts.map +1 -1
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +5 -0
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +196 -1
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +123 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/index.d.ts +10 -1
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +28 -7
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/lint.d.ts +32 -1
- package/dist/codegen/lint.d.ts.map +1 -1
- package/dist/codegen/lint.js +286 -1
- package/dist/codegen/lint.js.map +1 -1
- package/dist/codegen/mailbox.d.ts +19 -0
- package/dist/codegen/mailbox.d.ts.map +1 -0
- package/dist/codegen/mailbox.js +78 -0
- package/dist/codegen/mailbox.js.map +1 -0
- package/dist/codegen/schema.d.ts.map +1 -1
- package/dist/codegen/schema.js +3 -2
- package/dist/codegen/schema.js.map +1 -1
- package/dist/config/profiles.d.ts +2 -0
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +2 -0
- package/dist/config/profiles.js.map +1 -1
- package/dist/core/modalities/api.d.ts.map +1 -1
- package/dist/core/modalities/api.js +265 -29
- package/dist/core/modalities/api.js.map +1 -1
- package/dist/core/modalities/check-docs.d.ts +3 -0
- package/dist/core/modalities/check-docs.d.ts.map +1 -0
- package/dist/core/modalities/check-docs.js +64 -0
- package/dist/core/modalities/check-docs.js.map +1 -0
- package/dist/core/modalities/collect-docs.d.ts +3 -0
- package/dist/core/modalities/collect-docs.d.ts.map +1 -0
- package/dist/core/modalities/collect-docs.js +48 -0
- package/dist/core/modalities/collect-docs.js.map +1 -0
- package/dist/core/modalities/explore.d.ts.map +1 -1
- package/dist/core/modalities/explore.js +2 -0
- package/dist/core/modalities/explore.js.map +1 -1
- package/dist/core/modalities/mcp-test.d.ts +3 -0
- package/dist/core/modalities/mcp-test.d.ts.map +1 -0
- package/dist/core/modalities/mcp-test.js +26 -0
- package/dist/core/modalities/mcp-test.js.map +1 -0
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +11 -3
- package/dist/core/registry.js.map +1 -1
- package/dist/decider/uses/repair-triage.d.ts +9 -0
- package/dist/decider/uses/repair-triage.d.ts.map +1 -1
- package/dist/decider/uses/repair-triage.js +20 -3
- package/dist/decider/uses/repair-triage.js.map +1 -1
- package/dist/design/critique.d.ts +1 -1
- package/dist/design/index.d.ts +7 -1
- package/dist/design/index.d.ts.map +1 -1
- package/dist/design/index.js +20 -2
- package/dist/design/index.js.map +1 -1
- package/dist/design/schema.d.ts +9 -3
- package/dist/design/schema.d.ts.map +1 -1
- package/dist/design/schema.js +4 -1
- package/dist/design/schema.js.map +1 -1
- package/dist/documentarian/check.d.ts +91 -0
- package/dist/documentarian/check.d.ts.map +1 -0
- package/dist/documentarian/check.js +230 -0
- package/dist/documentarian/check.js.map +1 -0
- package/dist/documentarian/docs.d.ts +103 -0
- package/dist/documentarian/docs.d.ts.map +1 -0
- package/dist/documentarian/docs.js +243 -0
- package/dist/documentarian/docs.js.map +1 -0
- package/dist/documentarian/index.d.ts +2 -0
- package/dist/documentarian/index.d.ts.map +1 -1
- package/dist/documentarian/index.js +5 -4
- package/dist/documentarian/index.js.map +1 -1
- package/dist/environment/apply.js +1 -1
- package/dist/environment/apply.js.map +1 -1
- package/dist/flow/crawl.d.ts +4 -0
- package/dist/flow/crawl.d.ts.map +1 -1
- package/dist/flow/crawl.js +9 -2
- package/dist/flow/crawl.js.map +1 -1
- package/dist/fs/inside-dir.d.ts +8 -0
- package/dist/fs/inside-dir.d.ts.map +1 -0
- package/dist/fs/inside-dir.js +15 -0
- package/dist/fs/inside-dir.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +1 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/structured.d.ts +19 -0
- package/dist/llm/structured.d.ts.map +1 -1
- package/dist/llm/structured.js +61 -0
- package/dist/llm/structured.js.map +1 -1
- package/dist/mailbox/doctor.d.ts +10 -0
- package/dist/mailbox/doctor.d.ts.map +1 -0
- package/dist/mailbox/doctor.js +33 -0
- package/dist/mailbox/doctor.js.map +1 -0
- package/dist/mailbox/rule.d.ts +34 -0
- package/dist/mailbox/rule.d.ts.map +1 -0
- package/dist/mailbox/rule.js +47 -0
- package/dist/mailbox/rule.js.map +1 -0
- package/dist/mailbox/session.d.ts +5 -0
- package/dist/mailbox/session.d.ts.map +1 -1
- package/dist/mailbox/session.js +8 -0
- package/dist/mailbox/session.js.map +1 -1
- package/dist/mcp/server.d.ts +15 -5
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +75 -27
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +194 -82
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +82 -8
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp-test/adversarial.d.ts +80 -0
- package/dist/mcp-test/adversarial.d.ts.map +1 -0
- package/dist/mcp-test/adversarial.js +99 -0
- package/dist/mcp-test/adversarial.js.map +1 -0
- package/dist/mcp-test/advice.d.ts +20 -0
- package/dist/mcp-test/advice.d.ts.map +1 -0
- package/dist/mcp-test/advice.js +22 -0
- package/dist/mcp-test/advice.js.map +1 -0
- package/dist/mcp-test/call.d.ts +76 -0
- package/dist/mcp-test/call.d.ts.map +1 -0
- package/dist/mcp-test/call.js +105 -0
- package/dist/mcp-test/call.js.map +1 -0
- package/dist/mcp-test/cases.d.ts +154 -0
- package/dist/mcp-test/cases.d.ts.map +1 -0
- package/dist/mcp-test/cases.js +643 -0
- package/dist/mcp-test/cases.js.map +1 -0
- package/dist/mcp-test/connect.d.ts +70 -0
- package/dist/mcp-test/connect.d.ts.map +1 -0
- package/dist/mcp-test/connect.js +426 -0
- package/dist/mcp-test/connect.js.map +1 -0
- package/dist/mcp-test/coverage.d.ts +61 -0
- package/dist/mcp-test/coverage.d.ts.map +1 -0
- package/dist/mcp-test/coverage.js +76 -0
- package/dist/mcp-test/coverage.js.map +1 -0
- package/dist/mcp-test/discover.d.ts +40 -0
- package/dist/mcp-test/discover.d.ts.map +1 -0
- package/dist/mcp-test/discover.js +149 -0
- package/dist/mcp-test/discover.js.map +1 -0
- package/dist/mcp-test/guard.d.ts +161 -0
- package/dist/mcp-test/guard.d.ts.map +1 -0
- package/dist/mcp-test/guard.js +363 -0
- package/dist/mcp-test/guard.js.map +1 -0
- package/dist/mcp-test/model.d.ts +89 -0
- package/dist/mcp-test/model.d.ts.map +1 -0
- package/dist/mcp-test/model.js +88 -0
- package/dist/mcp-test/model.js.map +1 -0
- package/dist/mcp-test/payloads.d.ts +20 -0
- package/dist/mcp-test/payloads.d.ts.map +1 -0
- package/dist/mcp-test/payloads.js +20 -0
- package/dist/mcp-test/payloads.js.map +1 -0
- package/dist/mcp-test/report.d.ts +55 -0
- package/dist/mcp-test/report.d.ts.map +1 -0
- package/dist/mcp-test/report.js +157 -0
- package/dist/mcp-test/report.js.map +1 -0
- package/dist/mcp-test/run.d.ts +68 -0
- package/dist/mcp-test/run.d.ts.map +1 -0
- package/dist/mcp-test/run.js +467 -0
- package/dist/mcp-test/run.js.map +1 -0
- package/dist/mcp-test/runner.d.ts +133 -0
- package/dist/mcp-test/runner.d.ts.map +1 -0
- package/dist/mcp-test/runner.js +412 -0
- package/dist/mcp-test/runner.js.map +1 -0
- package/dist/mcp-test/schema.d.ts +103 -0
- package/dist/mcp-test/schema.d.ts.map +1 -0
- package/dist/mcp-test/schema.js +513 -0
- package/dist/mcp-test/schema.js.map +1 -0
- package/dist/mcp-test/secrets.d.ts +25 -0
- package/dist/mcp-test/secrets.d.ts.map +1 -0
- package/dist/mcp-test/secrets.js +67 -0
- package/dist/mcp-test/secrets.js.map +1 -0
- package/dist/observe/index.d.ts +3 -1
- package/dist/observe/index.d.ts.map +1 -1
- package/dist/observe/index.js +1 -0
- package/dist/observe/index.js.map +1 -1
- package/dist/observe/locator-hints.d.ts +18 -0
- package/dist/observe/locator-hints.d.ts.map +1 -0
- package/dist/observe/locator-hints.js +36 -0
- package/dist/observe/locator-hints.js.map +1 -0
- package/dist/observe/overlays.d.ts +135 -0
- package/dist/observe/overlays.d.ts.map +1 -0
- package/dist/observe/overlays.js +242 -0
- package/dist/observe/overlays.js.map +1 -0
- package/dist/observe/parse-aria.d.ts +7 -1
- package/dist/observe/parse-aria.d.ts.map +1 -1
- package/dist/observe/parse-aria.js +79 -4
- package/dist/observe/parse-aria.js.map +1 -1
- package/dist/probe/index.d.ts +3 -1
- package/dist/probe/index.d.ts.map +1 -1
- package/dist/probe/index.js +3 -2
- package/dist/probe/index.js.map +1 -1
- package/dist/project/index.d.ts +2 -0
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +10 -2
- package/dist/project/index.js.map +1 -1
- package/dist/prompts/local/describe-screen.d.ts +7 -0
- package/dist/prompts/local/describe-screen.d.ts.map +1 -0
- package/dist/prompts/local/describe-screen.js +29 -0
- package/dist/prompts/local/describe-screen.js.map +1 -0
- package/dist/prompts/local/index.d.ts.map +1 -1
- package/dist/prompts/local/index.js +7 -0
- package/dist/prompts/local/index.js.map +1 -1
- package/dist/prompts/local/name-overlays.d.ts +6 -0
- package/dist/prompts/local/name-overlays.d.ts.map +1 -0
- package/dist/prompts/local/name-overlays.js +16 -0
- package/dist/prompts/local/name-overlays.js.map +1 -0
- package/dist/prompts/local/qa-api-flows.d.ts +8 -0
- package/dist/prompts/local/qa-api-flows.d.ts.map +1 -0
- package/dist/prompts/local/qa-api-flows.js +19 -0
- package/dist/prompts/local/qa-api-flows.js.map +1 -0
- package/dist/prompts/local/qa-playwright-ts-writer.d.ts +1 -1
- package/dist/prompts/local/qa-playwright-ts-writer.d.ts.map +1 -1
- package/dist/prompts/local/qa-playwright-ts-writer.js +5 -1
- package/dist/prompts/local/qa-playwright-ts-writer.js.map +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
- package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +24 -2
- package/dist/session/index.js.map +1 -1
- package/dist/validate/index.d.ts +11 -0
- package/dist/validate/index.d.ts.map +1 -1
- package/dist/validate/index.js +21 -0
- package/dist/validate/index.js.map +1 -1
- package/dist/validate/runner.d.ts +15 -1
- package/dist/validate/runner.d.ts.map +1 -1
- package/dist/validate/runner.js +158 -25
- package/dist/validate/runner.js.map +1 -1
- package/dist/validate/write-guard.d.ts +24 -0
- package/dist/validate/write-guard.d.ts.map +1 -0
- package/dist/validate/write-guard.js +210 -0
- package/dist/validate/write-guard.js.map +1 -0
- package/dist/view/index.d.ts +9 -0
- package/dist/view/index.d.ts.map +1 -0
- package/dist/view/index.js +126 -0
- package/dist/view/index.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-E4 — the guard that decides, before every tool call, whether it may be sent. (Not `src/api/guard.ts`, which masks
|
|
3
|
+
* secrets and limits HTTP requests for `cairn api`; this one is its own class on its own types.)
|
|
4
|
+
*
|
|
5
|
+
* Nothing is sent by default. A tool is called only when the user named it (`--allow-tools`, exact names) or, with
|
|
6
|
+
* `--allow-read-only-hints`, when the server claims it is read-only and nothing about its name says otherwise. What a
|
|
7
|
+
* server says about itself is not a proof: a `readOnlyHint` alone never allows a call, a tool the server marks
|
|
8
|
+
* destructive is never let through on a hint, and anything that is not proven safe is a mutation, which needs
|
|
9
|
+
* `--allow-mutations` AND the tool's name in `--allow-tools`. `--allow-mutations` alone allows nothing.
|
|
10
|
+
*
|
|
11
|
+
* The decision is taken against the snapshot of the tool list the user saw. If the server later changes a tool (a
|
|
12
|
+
* `list_changed`, a second list), the tool is refused from then on: the permission was given for what was shown.
|
|
13
|
+
*
|
|
14
|
+
* Tool names and titles come from the server and are untrusted text: they are compared byte for byte with the user's
|
|
15
|
+
* names, never by similarity, and printed only through `safeText`.
|
|
16
|
+
*/
|
|
17
|
+
import { DESTRUCTIVE } from "../flow/crawl.js";
|
|
18
|
+
import { isDeletionIntent } from "../safety/guardrails.js";
|
|
19
|
+
import { MUTATING_STYLES } from "../api/guard.js";
|
|
20
|
+
import { safeText, sortKeys } from "./model.js";
|
|
21
|
+
export const DEFAULT_MAX_CALLS = 100;
|
|
22
|
+
export const DEFAULT_CALL_RPS = 2;
|
|
23
|
+
/** Exit code when the call budget or the time budget is spent (the same as `cairn api`). */
|
|
24
|
+
export const CALL_BUDGET_EXIT_CODE = 4;
|
|
25
|
+
/** Exit code when no call was sent: nothing was tested. */
|
|
26
|
+
export const NOTHING_SENT_EXIT_CODE = 5;
|
|
27
|
+
export const MUTATION_BANNER = "Calls may change data: run this on a test account or a stand.";
|
|
28
|
+
export const CLAIM_NOTE = "This is the server's claim, not a check.";
|
|
29
|
+
/** An error in how the flags were given (not a decision about a call). */
|
|
30
|
+
export class GuardUsageError extends Error {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "GuardUsageError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Characters that make an entry of `--allow-tools` look like a pattern: refused, never read as one. */
|
|
37
|
+
const PATTERN_CHARS = /[*?[\]{}()|^$\\+]/;
|
|
38
|
+
/**
|
|
39
|
+
* `--allow-tools a,b,c` → the names, exactly as written (no trimming, no case folding). An empty list, an empty entry,
|
|
40
|
+
* `all`, or anything that looks like a pattern is a usage error, not a permission.
|
|
41
|
+
*/
|
|
42
|
+
export function parseAllowTools(raw) {
|
|
43
|
+
if (raw === undefined)
|
|
44
|
+
return [];
|
|
45
|
+
const names = raw.split(",");
|
|
46
|
+
for (const n of names) {
|
|
47
|
+
if (n === "")
|
|
48
|
+
throw new GuardUsageError('--allow-tools takes tool names separated by commas; an empty name is not accepted (there is no "all").');
|
|
49
|
+
if (n.toLowerCase() === "all" || PATTERN_CHARS.test(n)) {
|
|
50
|
+
throw new GuardUsageError(`--allow-tools takes exact tool names; "${safeText(n, 40)}" is not accepted (no "all", no patterns).`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [...new Set(names)];
|
|
54
|
+
}
|
|
55
|
+
/** The names of `allowed` that the server does not have, compared exactly. */
|
|
56
|
+
export function unknownToolNames(allowed, tools) {
|
|
57
|
+
const have = new Set(tools.map((t) => t.name));
|
|
58
|
+
return allowed.filter((n) => !have.has(n));
|
|
59
|
+
}
|
|
60
|
+
/** A tool name or title split into lowercase words: `deleteFile`, `delete_file`, `remove-item` → separate words. */
|
|
61
|
+
export function nameWords(text) {
|
|
62
|
+
return text
|
|
63
|
+
.normalize("NFKC")
|
|
64
|
+
.replace(/(\p{Ll}|\p{N})(\p{Lu})/gu, "$1 $2") // camelCase
|
|
65
|
+
.replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu, "$1 $2") // HTTPServer → HTTP Server
|
|
66
|
+
.replace(/[_\-.:/\\]+/g, " ")
|
|
67
|
+
.replace(/\s+/g, " ")
|
|
68
|
+
.trim()
|
|
69
|
+
.toLowerCase();
|
|
70
|
+
}
|
|
71
|
+
/** Whether a name or title reads as a deletion, with the crawler's rules (English, Ukrainian, Russian) after splitting. */
|
|
72
|
+
export function readsDestructive(text) {
|
|
73
|
+
if (!text)
|
|
74
|
+
return false;
|
|
75
|
+
const words = nameWords(text);
|
|
76
|
+
return DESTRUCTIVE.test(words) || isDeletionIntent(words);
|
|
77
|
+
}
|
|
78
|
+
/** Control, invisible and bidi characters, or a name that is not in normalized form. */
|
|
79
|
+
const UNSAFE_NAME = /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u180e\u200b-\u200f\u2028-\u202e\u2060-\u206f\ufeff\ufff9-\ufffb]/u;
|
|
80
|
+
export const hasUnsafeName = (name) => UNSAFE_NAME.test(name) || name !== name.normalize("NFC");
|
|
81
|
+
/**
|
|
82
|
+
* The first word of a tool name that lets the trust flag (`--allow-read-only-hints`) rely on the server's claim. A list of
|
|
83
|
+
* words that are harmful cannot be completed (`destroy`, `send_email`, `deploy`, ... all slip past one), so the flag goes
|
|
84
|
+
* the other way: only a tool that claims read-only AND starts with one of these verbs is allowed on the claim.
|
|
85
|
+
* Known ceiling: `get` or `query` can still hide a write (a tool that runs SQL, for one). The flag is trust in the
|
|
86
|
+
* server's claim; the description is free text and takes no part in the decision.
|
|
87
|
+
*/
|
|
88
|
+
export const READ_VERBS = ["get", "list", "read", "search", "find", "describe", "show", "view", "fetch", "query", "count", "check", "lookup", "status"];
|
|
89
|
+
/** Plain ASCII only: a look-alike letter from another alphabet is not accepted on the claim. */
|
|
90
|
+
const PLAIN_NAME = /^[A-Za-z0-9_.-]+$/;
|
|
91
|
+
/** Why a tool that claims read-only is still not trusted on the claim, if it is not. */
|
|
92
|
+
export function claimProblem(name) {
|
|
93
|
+
if (!PLAIN_NAME.test(name))
|
|
94
|
+
return "name has characters outside ASCII letters, digits, _ - .";
|
|
95
|
+
const first = nameWords(name).split(" ")[0] ?? "";
|
|
96
|
+
return READ_VERBS.includes(first) ? undefined : "name does not start with a read verb";
|
|
97
|
+
}
|
|
98
|
+
const bool = (v) => (typeof v === "boolean" ? v : undefined);
|
|
99
|
+
const foldName = (n) => n.normalize("NFKC").toLowerCase();
|
|
100
|
+
/** Classify every tool of a model. `read-claimed` is the server's word, and only when nothing else contradicts it. */
|
|
101
|
+
export function assessTools(tools) {
|
|
102
|
+
const count = new Map();
|
|
103
|
+
for (const t of tools)
|
|
104
|
+
count.set(foldName(t.name ?? ""), (count.get(foldName(t.name ?? "")) ?? 0) + 1);
|
|
105
|
+
return tools.map((t) => {
|
|
106
|
+
const name = t.name ?? "";
|
|
107
|
+
const a = t.annotations ?? {};
|
|
108
|
+
const readOnlyHint = bool(a["readOnlyHint"]);
|
|
109
|
+
const destructiveHint = bool(a["destructiveHint"]);
|
|
110
|
+
const idempotentHint = bool(a["idempotentHint"]);
|
|
111
|
+
const destructiveName = readsDestructive(name) || readsDestructive(t.title);
|
|
112
|
+
const unsafeName = hasUnsafeName(name);
|
|
113
|
+
const ambiguous = (count.get(foldName(name)) ?? 0) > 1;
|
|
114
|
+
let cls;
|
|
115
|
+
if (destructiveName || readOnlyHint === false || destructiveHint === true)
|
|
116
|
+
cls = "mutating";
|
|
117
|
+
else
|
|
118
|
+
cls = "unknown";
|
|
119
|
+
const claimClean = readOnlyHint === true && !destructiveName && destructiveHint !== true && !unsafeName && !ambiguous;
|
|
120
|
+
const problem = claimClean ? claimProblem(name) : undefined;
|
|
121
|
+
if (claimClean && !problem)
|
|
122
|
+
cls = "read-claimed";
|
|
123
|
+
const mismatch = readOnlyHint === true && destructiveName
|
|
124
|
+
? "the server says read-only, the name or title reads as a deletion"
|
|
125
|
+
: readOnlyHint === true && destructiveHint === true
|
|
126
|
+
? "the server says both read-only and destructive"
|
|
127
|
+
: undefined;
|
|
128
|
+
return {
|
|
129
|
+
name,
|
|
130
|
+
class: cls,
|
|
131
|
+
...(readOnlyHint !== undefined ? { readOnlyHint } : {}),
|
|
132
|
+
...(destructiveHint !== undefined ? { destructiveHint } : {}),
|
|
133
|
+
...(idempotentHint !== undefined ? { idempotentHint } : {}),
|
|
134
|
+
destructiveName,
|
|
135
|
+
unsafeName,
|
|
136
|
+
ambiguous,
|
|
137
|
+
claimClean,
|
|
138
|
+
proposed: cls === "read-claimed",
|
|
139
|
+
...(problem ? { claimNote: `claims read-only; ${problem}` } : {}),
|
|
140
|
+
...(mismatch ? { mismatch } : {}),
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/** The table of tools and what is proposed for permission. */
|
|
145
|
+
export function renderProposal(assessments) {
|
|
146
|
+
const lines = ["Tools the server offers (nothing is called without your permission):", " tool | class | proposed for permission"];
|
|
147
|
+
for (const a of assessments) {
|
|
148
|
+
lines.push(` ${safeText(a.name, 60)} | ${a.class} | ${a.proposed ? "yes" : "no"}${a.claimNote ? ` (${a.claimNote})` : ""}`);
|
|
149
|
+
}
|
|
150
|
+
const proposed = assessments.filter((a) => a.proposed);
|
|
151
|
+
if (proposed.length) {
|
|
152
|
+
lines.push(` Proposed with --allow-read-only-hints or by name in --allow-tools: ${proposed.map((a) => safeText(a.name, 60)).join(", ")}.`);
|
|
153
|
+
lines.push(` Class read-claimed: ${CLAIM_NOTE}`);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
lines.push(" Nothing is proposed: no tool is claimed read-only with a clean name.");
|
|
157
|
+
}
|
|
158
|
+
return lines;
|
|
159
|
+
}
|
|
160
|
+
const fingerprint = (t) => JSON.stringify(sortKeys({ title: t.title, description: t.description, annotations: t.annotations, inputSchema: t.inputSchema, outputSchema: t.outputSchema }));
|
|
161
|
+
export class McpCallGuard {
|
|
162
|
+
allow;
|
|
163
|
+
allowList;
|
|
164
|
+
trustHints;
|
|
165
|
+
mutations;
|
|
166
|
+
maxCalls;
|
|
167
|
+
rps;
|
|
168
|
+
timeBudgetMs;
|
|
169
|
+
now;
|
|
170
|
+
sleepFn;
|
|
171
|
+
startedAt;
|
|
172
|
+
assessments;
|
|
173
|
+
byName = new Map();
|
|
174
|
+
snapshot = new Map();
|
|
175
|
+
changedSet = new Set();
|
|
176
|
+
decisions = [];
|
|
177
|
+
used = 0;
|
|
178
|
+
nextSlot = 0;
|
|
179
|
+
exhausted = false;
|
|
180
|
+
constructor(opts) {
|
|
181
|
+
// A limit that is NaN, zero, negative or infinite would make the budget or the rate vanish: refused.
|
|
182
|
+
const positive = (v, label) => {
|
|
183
|
+
if (v !== undefined && !(Number.isFinite(v) && v > 0))
|
|
184
|
+
throw new GuardUsageError(`${label} must be a finite number greater than 0.`);
|
|
185
|
+
};
|
|
186
|
+
positive(opts.maxCalls, "--max-calls");
|
|
187
|
+
positive(opts.rps, "--rps");
|
|
188
|
+
positive(opts.timeBudgetMs, "--time-budget (time budget)");
|
|
189
|
+
this.allowList = [...(opts.allowTools ?? [])];
|
|
190
|
+
this.allow = new Set(this.allowList);
|
|
191
|
+
this.trustHints = opts.allowReadOnlyHints ?? false;
|
|
192
|
+
this.mutations = opts.allowMutations ?? false;
|
|
193
|
+
this.maxCalls = opts.maxCalls ?? DEFAULT_MAX_CALLS;
|
|
194
|
+
this.rps = opts.rps ?? DEFAULT_CALL_RPS;
|
|
195
|
+
this.timeBudgetMs = opts.timeBudgetMs;
|
|
196
|
+
// Monotonic: a wall-clock step must not open the rate limiter.
|
|
197
|
+
this.now = opts.now ?? (() => performance.now());
|
|
198
|
+
this.sleepFn = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
199
|
+
this.startedAt = this.now();
|
|
200
|
+
this.assessments = assessTools(opts.tools);
|
|
201
|
+
for (const a of this.assessments)
|
|
202
|
+
this.byName.set(a.name, a);
|
|
203
|
+
for (const t of opts.tools)
|
|
204
|
+
this.snapshot.set(t.name ?? "", fingerprint(t));
|
|
205
|
+
}
|
|
206
|
+
/** The server announced a changed list (or it was read again): a tool that is not as it was shown stays refused. */
|
|
207
|
+
observe(tools) {
|
|
208
|
+
const seen = new Set();
|
|
209
|
+
for (const t of tools) {
|
|
210
|
+
const name = t.name ?? "";
|
|
211
|
+
seen.add(name);
|
|
212
|
+
const before = this.snapshot.get(name);
|
|
213
|
+
if (before !== undefined && before !== fingerprint(t))
|
|
214
|
+
this.changedSet.add(name);
|
|
215
|
+
}
|
|
216
|
+
for (const name of this.snapshot.keys())
|
|
217
|
+
if (!seen.has(name))
|
|
218
|
+
this.changedSet.add(name);
|
|
219
|
+
}
|
|
220
|
+
/** Whether a call could still be admitted: the time budget and the call budget are not spent. */
|
|
221
|
+
budgetLeft() {
|
|
222
|
+
if (this.timeBudgetMs !== undefined && this.now() - this.startedAt >= this.timeBudgetMs)
|
|
223
|
+
return false;
|
|
224
|
+
return this.used < this.maxCalls;
|
|
225
|
+
}
|
|
226
|
+
/** Takes one rate slot without taking a call of the budget: a read of the tool list before a call counts toward --rps only. */
|
|
227
|
+
async waitSlot() {
|
|
228
|
+
const now = this.now();
|
|
229
|
+
const slot = Math.max(now, this.nextSlot);
|
|
230
|
+
this.nextSlot = slot + 1000 / this.rps;
|
|
231
|
+
if (slot > now)
|
|
232
|
+
await this.sleepFn(slot - now);
|
|
233
|
+
}
|
|
234
|
+
/** The decision for one call, by policy alone (budget and rate are applied in {@link admit}). Not recorded. */
|
|
235
|
+
decide(call) {
|
|
236
|
+
const base = { tool: call.tool, ...(call.style ? { style: call.style } : {}) };
|
|
237
|
+
const deny = (reason) => ({ ...base, allowed: false, reason });
|
|
238
|
+
const a = this.byName.get(call.tool);
|
|
239
|
+
if (!a)
|
|
240
|
+
return deny("not in the model");
|
|
241
|
+
if (a.ambiguous)
|
|
242
|
+
return deny("ambiguous name");
|
|
243
|
+
if (a.unsafeName)
|
|
244
|
+
return deny("unsafe name");
|
|
245
|
+
if (this.changedSet.has(call.tool))
|
|
246
|
+
return deny("changed since permission");
|
|
247
|
+
const named = this.allow.has(call.tool);
|
|
248
|
+
const mutatingStyle = MUTATING_STYLES.has(call.style ?? "");
|
|
249
|
+
const clean = a.claimClean && !mutatingStyle;
|
|
250
|
+
if (a.destructiveName && !(named && this.mutations))
|
|
251
|
+
return deny("destructive name");
|
|
252
|
+
if (clean) {
|
|
253
|
+
if (named)
|
|
254
|
+
return { ...base, allowed: true, reason: "named in --allow-tools", basis: "named" };
|
|
255
|
+
if (this.trustHints) {
|
|
256
|
+
if (a.class === "read-claimed")
|
|
257
|
+
return { ...base, allowed: true, reason: "server claims read-only, trusted by --allow-read-only-hints", basis: "server-claim" };
|
|
258
|
+
return deny("claim not trusted");
|
|
259
|
+
}
|
|
260
|
+
return deny("not allowed");
|
|
261
|
+
}
|
|
262
|
+
// Not proven safe: a mutation. It needs the name AND --allow-mutations; a hint never lifts it.
|
|
263
|
+
if (!named)
|
|
264
|
+
return deny(this.mutations ? "not allowed" : "mutations not allowed");
|
|
265
|
+
if (!this.mutations)
|
|
266
|
+
return deny("mutations not allowed");
|
|
267
|
+
return { ...base, allowed: true, reason: "named in --allow-tools with --allow-mutations", basis: "named" };
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The only question a runner asks before sending: the decision, with the budget and the rate applied. An allowed
|
|
271
|
+
* decision has taken one call of the budget (a retry takes another) and waited for its rate slot, which is reserved
|
|
272
|
+
* synchronously, so concurrent callers queue 1/rps apart. Recorded for the report.
|
|
273
|
+
*/
|
|
274
|
+
async admit(call) {
|
|
275
|
+
let d = this.decide(call);
|
|
276
|
+
if (d.allowed) {
|
|
277
|
+
if (this.timeBudgetMs !== undefined && this.now() - this.startedAt >= this.timeBudgetMs) {
|
|
278
|
+
this.exhausted = true;
|
|
279
|
+
d = { ...d, allowed: false, reason: "time budget exhausted" };
|
|
280
|
+
}
|
|
281
|
+
else if (this.used >= this.maxCalls) {
|
|
282
|
+
this.exhausted = true;
|
|
283
|
+
d = { ...d, allowed: false, reason: "budget exhausted" };
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (d.allowed) {
|
|
287
|
+
this.used += 1;
|
|
288
|
+
const now = this.now();
|
|
289
|
+
const slot = Math.max(now, this.nextSlot);
|
|
290
|
+
this.nextSlot = slot + 1000 / this.rps;
|
|
291
|
+
this.decisions.push(d);
|
|
292
|
+
if (slot > now)
|
|
293
|
+
await this.sleepFn(slot - now);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
this.decisions.push(d);
|
|
297
|
+
}
|
|
298
|
+
return d;
|
|
299
|
+
}
|
|
300
|
+
report() {
|
|
301
|
+
const sent = this.decisions.filter((d) => d.allowed).length;
|
|
302
|
+
const notes = [];
|
|
303
|
+
if (this.mutations && this.allowList.length === 0)
|
|
304
|
+
notes.push("--allow-mutations without --allow-tools allows nothing.");
|
|
305
|
+
if (this.changedSet.size)
|
|
306
|
+
notes.push("The server changed some tools after they were shown; calls to them are refused.");
|
|
307
|
+
return {
|
|
308
|
+
policy: {
|
|
309
|
+
allowTools: [...this.allowList],
|
|
310
|
+
allowReadOnlyHints: this.trustHints,
|
|
311
|
+
allowMutations: this.mutations,
|
|
312
|
+
maxCalls: this.maxCalls,
|
|
313
|
+
rps: this.rps,
|
|
314
|
+
...(this.timeBudgetMs !== undefined ? { timeBudgetMs: this.timeBudgetMs } : {}),
|
|
315
|
+
},
|
|
316
|
+
...(this.mutations ? { banner: MUTATION_BANNER } : {}),
|
|
317
|
+
restsOnServerClaims: this.decisions.some((d) => d.allowed && d.basis === "server-claim"),
|
|
318
|
+
tools: this.assessments,
|
|
319
|
+
proposed: this.assessments.filter((a) => a.proposed).map((a) => a.name),
|
|
320
|
+
mismatches: this.assessments.filter((a) => a.mismatch).map((a) => ({ tool: a.name, detail: a.mismatch })),
|
|
321
|
+
changed: [...this.changedSet],
|
|
322
|
+
decisions: [...this.decisions],
|
|
323
|
+
sent,
|
|
324
|
+
denied: this.decisions.length - sent,
|
|
325
|
+
budgetExhausted: this.exhausted,
|
|
326
|
+
notes,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/** 4 when a budget ran out, 5 when nothing was sent, 0 otherwise (a failed case is the runner's 1). */
|
|
330
|
+
exitCode() {
|
|
331
|
+
if (this.exhausted)
|
|
332
|
+
return CALL_BUDGET_EXIT_CODE;
|
|
333
|
+
return this.decisions.some((d) => d.allowed) ? 0 : NOTHING_SENT_EXIT_CODE;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** The tools whose hint and name disagree. */
|
|
337
|
+
export function renderMismatches(mismatches) {
|
|
338
|
+
if (!mismatches.length)
|
|
339
|
+
return [];
|
|
340
|
+
return [" Hint and name disagree:", ...mismatches.map((m) => ` ${safeText(m.tool, 60)}: ${m.detail}`)];
|
|
341
|
+
}
|
|
342
|
+
/** Console lines of the guard's report: the banner first (when mutations are allowed), then what was decided and why. */
|
|
343
|
+
export function renderGuardReport(r) {
|
|
344
|
+
const lines = [];
|
|
345
|
+
if (r.banner)
|
|
346
|
+
lines.push(`⚠ ${r.banner}`);
|
|
347
|
+
lines.push("=== Call guard ===");
|
|
348
|
+
lines.push(` Policy: ${r.policy.allowTools.length} tool(s) named, read-only hints ${r.policy.allowReadOnlyHints ? "TRUSTED" : "not trusted"}, mutations ${r.policy.allowMutations ? "allowed" : "not allowed"}; at most ${r.policy.maxCalls} call(s), ${r.policy.rps}/s.`);
|
|
349
|
+
lines.push(` Sent: ${r.sent}, refused: ${r.denied}.`);
|
|
350
|
+
if (r.restsOnServerClaims)
|
|
351
|
+
lines.push(` Some permission rests on the server's own claim of read-only. ${CLAIM_NOTE}`);
|
|
352
|
+
for (const d of r.decisions.filter((x) => !x.allowed))
|
|
353
|
+
lines.push(` refused ${safeText(d.tool, 60)}: ${d.reason}`);
|
|
354
|
+
for (const d of r.decisions.filter((x) => x.allowed))
|
|
355
|
+
lines.push(` allowed ${safeText(d.tool, 60)}: ${d.reason}`);
|
|
356
|
+
lines.push(...renderMismatches(r.mismatches));
|
|
357
|
+
for (const n of r.notes)
|
|
358
|
+
lines.push(` Note: ${n}`);
|
|
359
|
+
if (r.budgetExhausted)
|
|
360
|
+
lines.push(" ✗ The call budget ran out: the rest were not sent and are not counted as passed.");
|
|
361
|
+
return lines;
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/mcp-test/guard.ts"],"names":[],"mappings":"A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;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACpH,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnH,KAAK,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9C,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACpD,IAAI,CAAC,CAAC,eAAe;QAAE,KAAK,CAAC,IAAI,CAAC,oFAAoF,CAAC,CAAC;IACxH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-E1 — the model of a foreign MCP server: what it declared and what it lists.
|
|
3
|
+
*
|
|
4
|
+
* Everything in here is read from the server, so it is untrusted text: nothing is executed or handed to a model as an
|
|
5
|
+
* instruction, and every line printed to the console goes through {@link safeText}.
|
|
6
|
+
*
|
|
7
|
+
* The file written from this model must be the same bytes for the same server, so {@link serializeModel} sorts every
|
|
8
|
+
* object key and every list by name, and the model carries no time, run id or anything that depends on the network.
|
|
9
|
+
*/
|
|
10
|
+
export declare const MCP_MODEL_VERSION = 1;
|
|
11
|
+
export interface McpToolEntry {
|
|
12
|
+
name: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
inputSchema: Record<string, unknown>;
|
|
16
|
+
outputSchema?: Record<string, unknown>;
|
|
17
|
+
annotations?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface McpResourceEntry {
|
|
20
|
+
uri: string;
|
|
21
|
+
name: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
mimeType?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface McpResourceTemplateEntry {
|
|
27
|
+
uriTemplate: string;
|
|
28
|
+
name: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
mimeType?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface McpPromptEntry {
|
|
34
|
+
name: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
arguments?: Array<Record<string, unknown>>;
|
|
38
|
+
}
|
|
39
|
+
export type McpListKind = "tools" | "resources" | "resourceTemplates" | "prompts";
|
|
40
|
+
/** A list that stopped before the server's last page. */
|
|
41
|
+
export interface McpTruncation {
|
|
42
|
+
/** A list, or `capabilities` when its nesting was cut. */
|
|
43
|
+
list: McpListKind | "capabilities";
|
|
44
|
+
reason: string;
|
|
45
|
+
/** How many entries were kept. */
|
|
46
|
+
kept: number;
|
|
47
|
+
}
|
|
48
|
+
export interface McpModel {
|
|
49
|
+
schemaVersion: typeof MCP_MODEL_VERSION;
|
|
50
|
+
serverInfo: {
|
|
51
|
+
name: string;
|
|
52
|
+
version: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
};
|
|
55
|
+
/** The protocol revision the server agreed to in `initialize`. */
|
|
56
|
+
protocolVersion: string;
|
|
57
|
+
capabilities: Record<string, unknown>;
|
|
58
|
+
/** false when any list was cut short; `truncated` says which and why. */
|
|
59
|
+
complete: boolean;
|
|
60
|
+
truncated: McpTruncation[];
|
|
61
|
+
/** Plain statements about what could not be read (a list the server did not declare, for one). */
|
|
62
|
+
notes: string[];
|
|
63
|
+
/** Names only: the values of headers and environment variables are never stored. */
|
|
64
|
+
connection: {
|
|
65
|
+
transport: "stdio" | "streamable-http";
|
|
66
|
+
headerNames: string[];
|
|
67
|
+
envNames: string[];
|
|
68
|
+
};
|
|
69
|
+
tools: McpToolEntry[];
|
|
70
|
+
resources: McpResourceEntry[];
|
|
71
|
+
resourceTemplates: McpResourceTemplateEntry[];
|
|
72
|
+
prompts: McpPromptEntry[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The same value with every object key sorted by UTF-16 code unit (JavaScript's default string order; arrays keep
|
|
76
|
+
* their order). Nesting beyond {@link SORT_DEPTH_LIMIT} becomes a mark instead of a stack overflow.
|
|
77
|
+
*/
|
|
78
|
+
export declare function sortKeys(value: unknown, depth?: number): unknown;
|
|
79
|
+
/** The model with its lists in name order, ready to be written. */
|
|
80
|
+
export declare function canonicalModel(m: McpModel): McpModel;
|
|
81
|
+
/** The text of `mcp-model.json` for a model whose lists are already in order (keys are sorted here). */
|
|
82
|
+
export declare function serializeCanonical(m: McpModel): string;
|
|
83
|
+
/** The exact text of `mcp-model.json`: lists in order, keys sorted. */
|
|
84
|
+
export declare function serializeModel(m: McpModel): string;
|
|
85
|
+
/** Text from a server made printable: control characters (escape sequences included) become a space, length is capped. */
|
|
86
|
+
export declare function safeText(text: unknown, max?: number): string;
|
|
87
|
+
/** The short summary printed after a read: counts, which tools take arguments, which declared `readOnlyHint`. */
|
|
88
|
+
export declare function renderModelSummary(m: McpModel): string[];
|
|
89
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/mcp-test/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE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AAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,yEAAyE;IACzE,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,kGAAkG;IAClG,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,oFAAoF;IACpF,UAAU,EAAE;QAAE,SAAS,EAAE,OAAO,GAAG,iBAAiB,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAClG,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,iBAAiB,EAAE,wBAAwB,EAAE,CAAC;IAC9C,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAKD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAQ3D;AASD,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAUpD;AAED,wGAAwG;AACxG,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,CAEtD;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,CAElD;AAED,0HAA0H;AAC1H,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,MAAM,CAMxD;AAOD,iHAAiH;AACjH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,EAAE,CAkBxD"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-E1 — the model of a foreign MCP server: what it declared and what it lists.
|
|
3
|
+
*
|
|
4
|
+
* Everything in here is read from the server, so it is untrusted text: nothing is executed or handed to a model as an
|
|
5
|
+
* instruction, and every line printed to the console goes through {@link safeText}.
|
|
6
|
+
*
|
|
7
|
+
* The file written from this model must be the same bytes for the same server, so {@link serializeModel} sorts every
|
|
8
|
+
* object key and every list by name, and the model carries no time, run id or anything that depends on the network.
|
|
9
|
+
*/
|
|
10
|
+
export const MCP_MODEL_VERSION = 1;
|
|
11
|
+
/** Past this depth {@link sortKeys} stops descending (discovery already cuts at 64; this is the backstop). */
|
|
12
|
+
const SORT_DEPTH_LIMIT = 128;
|
|
13
|
+
/**
|
|
14
|
+
* The same value with every object key sorted by UTF-16 code unit (JavaScript's default string order; arrays keep
|
|
15
|
+
* their order). Nesting beyond {@link SORT_DEPTH_LIMIT} becomes a mark instead of a stack overflow.
|
|
16
|
+
*/
|
|
17
|
+
export function sortKeys(value, depth = 0) {
|
|
18
|
+
if (value && typeof value === "object") {
|
|
19
|
+
if (depth >= SORT_DEPTH_LIMIT)
|
|
20
|
+
return "[nesting too deep]";
|
|
21
|
+
if (Array.isArray(value))
|
|
22
|
+
return value.map((x) => sortKeys(x, depth + 1));
|
|
23
|
+
const o = value;
|
|
24
|
+
return Object.fromEntries(Object.keys(o).sort().map((k) => [k, sortKeys(o[k], depth + 1)]));
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
const cmp = (x, y) => (x < y ? -1 : x > y ? 1 : 0);
|
|
29
|
+
const text = (v) => (typeof v === "string" ? v : "");
|
|
30
|
+
const canon = (v) => JSON.stringify(sortKeys(v));
|
|
31
|
+
/** Order by the key (a missing or non-string key counts as ""); equal keys are told apart by the entry's canonical JSON. */
|
|
32
|
+
const byKey = (key) => (a, b) => cmp(text(key(a)), text(key(b))) || cmp(canon(a), canon(b));
|
|
33
|
+
/** The model with its lists in name order, ready to be written. */
|
|
34
|
+
export function canonicalModel(m) {
|
|
35
|
+
return {
|
|
36
|
+
...m,
|
|
37
|
+
connection: { ...m.connection, headerNames: [...m.connection.headerNames].sort(), envNames: [...m.connection.envNames].sort() },
|
|
38
|
+
truncated: [...m.truncated].sort(byKey((t) => t.list)),
|
|
39
|
+
tools: [...m.tools].sort(byKey((t) => t.name)),
|
|
40
|
+
resources: [...m.resources].sort(byKey((r) => r.uri)),
|
|
41
|
+
resourceTemplates: [...m.resourceTemplates].sort(byKey((r) => r.uriTemplate)),
|
|
42
|
+
prompts: [...m.prompts].sort(byKey((p) => p.name)),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** The text of `mcp-model.json` for a model whose lists are already in order (keys are sorted here). */
|
|
46
|
+
export function serializeCanonical(m) {
|
|
47
|
+
return `${JSON.stringify(sortKeys(m), null, 2)}\n`;
|
|
48
|
+
}
|
|
49
|
+
/** The exact text of `mcp-model.json`: lists in order, keys sorted. */
|
|
50
|
+
export function serializeModel(m) {
|
|
51
|
+
return serializeCanonical(canonicalModel(m));
|
|
52
|
+
}
|
|
53
|
+
/** Text from a server made printable: control characters (escape sequences included) become a space, length is capped. */
|
|
54
|
+
export function safeText(text, max = 80) {
|
|
55
|
+
const s = String(text ?? "")
|
|
56
|
+
.replace(/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/g, " ")
|
|
57
|
+
.replace(/\s+/g, " ")
|
|
58
|
+
.trim();
|
|
59
|
+
return s.length > max ? `${s.slice(0, max - 1)}…` : s;
|
|
60
|
+
}
|
|
61
|
+
function hasProperties(schema) {
|
|
62
|
+
const p = schema["properties"];
|
|
63
|
+
return !!p && typeof p === "object" && Object.keys(p).length > 0;
|
|
64
|
+
}
|
|
65
|
+
/** The short summary printed after a read: counts, which tools take arguments, which declared `readOnlyHint`. */
|
|
66
|
+
export function renderModelSummary(m) {
|
|
67
|
+
const withProps = m.tools.filter((t) => hasProperties(t.inputSchema));
|
|
68
|
+
const without = m.tools.filter((t) => !hasProperties(t.inputSchema));
|
|
69
|
+
const readOnly = m.tools.filter((t) => t.annotations?.["readOnlyHint"] === true);
|
|
70
|
+
const names = (xs) => (xs.length ? xs.map((t) => safeText(t.name, 60)).join(", ") : "none");
|
|
71
|
+
const lines = [
|
|
72
|
+
`MCP server: ${safeText(m.serverInfo.name)} ${safeText(m.serverInfo.version)} (protocol ${safeText(m.protocolVersion)})`,
|
|
73
|
+
` ${m.tools.length} tool(s), ${m.resources.length} resource(s), ${m.resourceTemplates.length} resource template(s), ${m.prompts.length} prompt(s)`,
|
|
74
|
+
` Tools with an inputSchema that has properties: ${withProps.length} (${names(withProps)})`,
|
|
75
|
+
` Tools without properties: ${without.length} (${names(without)})`,
|
|
76
|
+
` Tools that declared readOnlyHint: ${readOnly.length} (${names(readOnly)})`,
|
|
77
|
+
];
|
|
78
|
+
for (const t of m.truncated) {
|
|
79
|
+
if (t.list === "capabilities")
|
|
80
|
+
lines.push(` ⚠ The capabilities were cut: ${safeText(t.reason, 300)}. The model has complete: false.`);
|
|
81
|
+
else
|
|
82
|
+
lines.push(` ⚠ The ${t.list} list is INCOMPLETE: ${safeText(t.reason, 300)} (${t.kept} kept). The model has complete: false.`);
|
|
83
|
+
}
|
|
84
|
+
for (const n of m.notes)
|
|
85
|
+
lines.push(` Note: ${n}`);
|
|
86
|
+
return lines;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/mcp-test/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAgEnC,8GAA8G;AAC9G,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,IAAI,KAAK,IAAI,gBAAgB;YAAE,OAAO,oBAAoB,CAAC;QAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC,GAA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C,CAAC,CAAC;IACvI,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-E3 — the strings the adversarial styles put into tool arguments. They are generic, written for this project, and
|
|
3
|
+
* known to be harmless: they test that a server refuses or sanitises, never that an attack works. Characters that cannot
|
|
4
|
+
* be seen are written as escapes, so this file holds none of them raw. Nothing here is shaped like a real credential, and
|
|
5
|
+
* no path points at a real file.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SQL_INJECTION = "' OR '1'='1";
|
|
8
|
+
export declare const SCRIPT_INJECTION = "<script>alert(1)</script>";
|
|
9
|
+
/** A command substitution that names a command that does not exist: if it were run, nothing useful would happen. */
|
|
10
|
+
export declare const COMMAND_SUBSTITUTION = "$(cairn-sentinel-no-such-command)";
|
|
11
|
+
/** A path that goes up one level to a name that does not exist. */
|
|
12
|
+
export declare const PATH_TRAVERSAL = "../cairn-sentinel-not-a-real-file";
|
|
13
|
+
/** A byte of zero in the middle of a string. */
|
|
14
|
+
export declare const NULL_BYTE_STRING = "a\0b";
|
|
15
|
+
/** A high surrogate with no low surrogate after it: not valid Unicode text. */
|
|
16
|
+
export declare const LONE_SURROGATE_STRING = "a\uD800b";
|
|
17
|
+
export declare const MAX_SAFE_NUMBER: number;
|
|
18
|
+
export declare const SENTINEL_EXTRA_PROPERTY = "cairn_extra_property";
|
|
19
|
+
export declare const SENTINEL_PROTO_VALUE = "cairn-sentinel";
|
|
20
|
+
//# sourceMappingURL=payloads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.d.ts","sourceRoot":"","sources":["../../src/mcp-test/payloads.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAC3C,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,oHAAoH;AACpH,eAAO,MAAM,oBAAoB,sCAAsC,CAAC;AACxE,mEAAmE;AACnE,eAAO,MAAM,cAAc,sCAAsC,CAAC;AAClE,gDAAgD;AAChD,eAAO,MAAM,gBAAgB,SAAa,CAAC;AAC3C,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,aAAa,CAAC;AAChD,eAAO,MAAM,eAAe,QAA0B,CAAC;AACvD,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D,eAAO,MAAM,oBAAoB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-E3 — the strings the adversarial styles put into tool arguments. They are generic, written for this project, and
|
|
3
|
+
* known to be harmless: they test that a server refuses or sanitises, never that an attack works. Characters that cannot
|
|
4
|
+
* be seen are written as escapes, so this file holds none of them raw. Nothing here is shaped like a real credential, and
|
|
5
|
+
* no path points at a real file.
|
|
6
|
+
*/
|
|
7
|
+
export const SQL_INJECTION = "' OR '1'='1";
|
|
8
|
+
export const SCRIPT_INJECTION = "<script>alert(1)</script>";
|
|
9
|
+
/** A command substitution that names a command that does not exist: if it were run, nothing useful would happen. */
|
|
10
|
+
export const COMMAND_SUBSTITUTION = "$(cairn-sentinel-no-such-command)";
|
|
11
|
+
/** A path that goes up one level to a name that does not exist. */
|
|
12
|
+
export const PATH_TRAVERSAL = "../cairn-sentinel-not-a-real-file";
|
|
13
|
+
/** A byte of zero in the middle of a string. */
|
|
14
|
+
export const NULL_BYTE_STRING = "a\u0000b";
|
|
15
|
+
/** A high surrogate with no low surrogate after it: not valid Unicode text. */
|
|
16
|
+
export const LONE_SURROGATE_STRING = "a\uD800b";
|
|
17
|
+
export const MAX_SAFE_NUMBER = Number.MAX_SAFE_INTEGER;
|
|
18
|
+
export const SENTINEL_EXTRA_PROPERTY = "cairn_extra_property";
|
|
19
|
+
export const SENTINEL_PROTO_VALUE = "cairn-sentinel";
|
|
20
|
+
//# sourceMappingURL=payloads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payloads.js","sourceRoot":"","sources":["../../src/mcp-test/payloads.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAC5D,oHAAoH;AACpH,MAAM,CAAC,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AACxE,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAClE,gDAAgD;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAC3C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC"}
|