hmcp-gateway 0.0.2 → 0.1.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 (102) hide show
  1. package/LICENSE +77 -0
  2. package/README.md +41 -9
  3. package/bin/hmcp-gateway.js +20 -0
  4. package/catalog/atlassian.yaml +41 -0
  5. package/catalog/brave-search.yaml +57 -0
  6. package/catalog/context7.yaml +42 -0
  7. package/catalog/fetch.yaml +37 -0
  8. package/catalog/figma.yaml +48 -0
  9. package/catalog/filesystem.yaml +48 -0
  10. package/catalog/git.yaml +48 -0
  11. package/catalog/github.yaml +103 -0
  12. package/catalog/huggingface.yaml +59 -0
  13. package/catalog/linear.yaml +47 -0
  14. package/catalog/memory.yaml +47 -0
  15. package/catalog/notion.yaml +41 -0
  16. package/catalog/playwright.yaml +38 -0
  17. package/catalog/postgres.yaml +66 -0
  18. package/catalog/sentry.yaml +39 -0
  19. package/catalog/sequential-thinking.yaml +29 -0
  20. package/catalog/stripe.yaml +41 -0
  21. package/catalog/supabase.yaml +45 -0
  22. package/catalog/time.yaml +49 -0
  23. package/dist/adopt-cli.d.ts +351 -0
  24. package/dist/adopt-cli.js +1857 -0
  25. package/dist/adopt-emit.d.ts +64 -0
  26. package/dist/adopt-emit.js +248 -0
  27. package/dist/adopt-plan.d.ts +108 -0
  28. package/dist/adopt-plan.js +386 -0
  29. package/dist/catalog.d.ts +140 -0
  30. package/dist/catalog.js +250 -0
  31. package/dist/classify.d.ts +23 -0
  32. package/dist/classify.js +47 -0
  33. package/dist/cli.d.ts +2 -0
  34. package/dist/cli.js +535 -0
  35. package/dist/client-allow.d.ts +42 -0
  36. package/dist/client-allow.js +95 -0
  37. package/dist/client-config.d.ts +200 -0
  38. package/dist/client-config.js +784 -0
  39. package/dist/config-source.d.ts +106 -0
  40. package/dist/config-source.js +156 -0
  41. package/dist/config.d.ts +159 -0
  42. package/dist/config.js +330 -0
  43. package/dist/connect-client.d.ts +49 -0
  44. package/dist/connect-client.js +249 -0
  45. package/dist/contracts.d.ts +251 -0
  46. package/dist/contracts.js +9 -0
  47. package/dist/credential.d.ts +63 -0
  48. package/dist/credential.js +136 -0
  49. package/dist/draft.d.ts +71 -0
  50. package/dist/draft.js +596 -0
  51. package/dist/exposure-cli.d.ts +28 -0
  52. package/dist/exposure-cli.js +119 -0
  53. package/dist/gateway.d.ts +756 -0
  54. package/dist/gateway.js +2106 -0
  55. package/dist/index.d.ts +26 -0
  56. package/dist/index.js +26 -0
  57. package/dist/notify.d.ts +44 -0
  58. package/dist/notify.js +93 -0
  59. package/dist/oauth.d.ts +139 -0
  60. package/dist/oauth.js +641 -0
  61. package/dist/observe.d.ts +10 -0
  62. package/dist/observe.js +26 -0
  63. package/dist/open.d.ts +24 -0
  64. package/dist/open.js +31 -0
  65. package/dist/packs.d.ts +119 -0
  66. package/dist/packs.js +131 -0
  67. package/dist/pin-cli.d.ts +28 -0
  68. package/dist/pin-cli.js +103 -0
  69. package/dist/probe-upstream.d.ts +31 -0
  70. package/dist/probe-upstream.js +377 -0
  71. package/dist/registry-map.d.ts +39 -0
  72. package/dist/registry-map.js +390 -0
  73. package/dist/rule-cli.d.ts +51 -0
  74. package/dist/rule-cli.js +412 -0
  75. package/dist/serve-http.d.ts +67 -0
  76. package/dist/serve-http.js +478 -0
  77. package/dist/snippet.d.ts +20 -0
  78. package/dist/snippet.js +826 -0
  79. package/dist/status-cli.d.ts +61 -0
  80. package/dist/status-cli.js +195 -0
  81. package/dist/suggest-cli.d.ts +43 -0
  82. package/dist/suggest-cli.js +279 -0
  83. package/dist/toolname.d.ts +47 -0
  84. package/dist/toolname.js +149 -0
  85. package/dist/upstream-errors.d.ts +54 -0
  86. package/dist/upstream-errors.js +330 -0
  87. package/dist/upstream.d.ts +128 -0
  88. package/dist/upstream.js +413 -0
  89. package/dist/version.d.ts +10 -0
  90. package/dist/version.js +11 -0
  91. package/package.json +50 -6
  92. package/packs/brave-search.yaml +20 -0
  93. package/packs/context7.yaml +13 -0
  94. package/packs/fetch.yaml +14 -0
  95. package/packs/filesystem.yaml +79 -0
  96. package/packs/git.yaml +29 -0
  97. package/packs/github.yaml +47 -0
  98. package/packs/huggingface.yaml +16 -0
  99. package/packs/memory.yaml +23 -0
  100. package/packs/playwright.yaml +41 -0
  101. package/packs/sequential-thinking.yaml +13 -0
  102. package/packs/time.yaml +14 -0
package/dist/open.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { type Policy } from "hmcp-core";
2
+ import { type GatewayConfig } from "./config.js";
3
+ import { Gateway, type GatewayOptions } from "./gateway.js";
4
+ export interface OpenedGateway {
5
+ readonly gateway: Gateway;
6
+ readonly config: GatewayConfig;
7
+ readonly policy: Policy;
8
+ /** The directory every relative path in the config and policy is resolved against. */
9
+ readonly base: string;
10
+ }
11
+ /**
12
+ * Builds a gateway from a config file, the way every command should.
13
+ *
14
+ * The one thing this adds to `new Gateway(...)` is the base directory. A
15
+ * gateway is launched by an MCP client from wherever that client happens to
16
+ * be, and `policy: ./policy.yaml` or `audit.path: ./audit.jsonl` mean "beside
17
+ * this config", not "in whatever directory the process started in". The
18
+ * config loader already read the policy from beside the config; without the
19
+ * same base here the gateway then *watched* a different path for edits and
20
+ * opened its log and database somewhere else -- so it never adopted a policy
21
+ * change, and the console, which resolves against the config's directory,
22
+ * read a log the gateway was not writing.
23
+ */
24
+ export declare function openGateway(configPath: string, options?: Pick<GatewayOptions, "notify">): OpenedGateway;
package/dist/open.js ADDED
@@ -0,0 +1,31 @@
1
+ import { dirname } from "node:path";
2
+ import { expandPath } from "hmcp-core";
3
+ import { DEFAULT_CONFIG_PATH, loadGatewayConfig } from "./config.js";
4
+ import { Gateway } from "./gateway.js";
5
+ /**
6
+ * Builds a gateway from a config file, the way every command should.
7
+ *
8
+ * The one thing this adds to `new Gateway(...)` is the base directory. A
9
+ * gateway is launched by an MCP client from wherever that client happens to
10
+ * be, and `policy: ./policy.yaml` or `audit.path: ./audit.jsonl` mean "beside
11
+ * this config", not "in whatever directory the process started in". The
12
+ * config loader already read the policy from beside the config; without the
13
+ * same base here the gateway then *watched* a different path for edits and
14
+ * opened its log and database somewhere else -- so it never adopted a policy
15
+ * change, and the console, which resolves against the config's directory,
16
+ * read a log the gateway was not writing.
17
+ */
18
+ export function openGateway(configPath, options = {}) {
19
+ const full = expandPath(configPath);
20
+ const base = dirname(full);
21
+ // Judged on the path as given, before expansion flattened the difference
22
+ // between the fallback and one somebody typed.
23
+ const { config, policy } = loadGatewayConfig(full, { typed: configPath !== DEFAULT_CONFIG_PATH });
24
+ // `configPath` is what a running gateway watches for servers being added or removed.
25
+ return {
26
+ gateway: new Gateway({ config, policy, cwd: base, policyPath: full, configPath: full, ...options }),
27
+ config,
28
+ policy,
29
+ base
30
+ };
31
+ }
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Ready-made classification for the servers people put behind a gateway
4
+ * first.
5
+ *
6
+ * The problem is day one. A tool nothing has classified is either a question
7
+ * or a wall, and a new user meets several of them before they have read
8
+ * anything about policy. A pack answers them in advance for a server whose
9
+ * tools are the same for everybody.
10
+ *
11
+ * Two rules about how they are written, both of which are about not being
12
+ * quietly wrong:
13
+ *
14
+ * - **Exact tool names, never patterns.** A glob matches one naming
15
+ * convention, so it misses `readFile` where it caught `read_file`, and
16
+ * where it does match it overrides the gateway's own classification --
17
+ * including its refusal to believe a server that marks its own delete tool
18
+ * read-only.
19
+ * - **Checked against what the server actually advertised.** A rule that
20
+ * matched nothing is reported, not written. A pack written against last
21
+ * year's release of a server must fail loudly rather than classify nothing
22
+ * while looking like it did something.
23
+ */
24
+ declare const PackRuleSchema: z.ZodObject<{
25
+ effect: z.ZodEnum<{
26
+ read: "read";
27
+ write: "write";
28
+ destructive: "destructive";
29
+ }>;
30
+ decision: z.ZodEnum<{
31
+ deny: "deny";
32
+ allow: "allow";
33
+ approve: "approve";
34
+ }>;
35
+ on_violation: z.ZodOptional<z.ZodEnum<{
36
+ deny: "deny";
37
+ approve: "approve";
38
+ }>>;
39
+ unknown_args: z.ZodOptional<z.ZodEnum<{
40
+ deny: "deny";
41
+ allow: "allow";
42
+ approve: "approve";
43
+ }>>;
44
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ }, z.core.$strict>;
46
+ declare const PackSchema: z.ZodObject<{
47
+ name: z.ZodString;
48
+ label: z.ZodString;
49
+ detect: z.ZodArray<z.ZodString>;
50
+ path_bound: z.ZodOptional<z.ZodBoolean>;
51
+ tools: z.ZodRecord<z.ZodString, z.ZodObject<{
52
+ effect: z.ZodEnum<{
53
+ read: "read";
54
+ write: "write";
55
+ destructive: "destructive";
56
+ }>;
57
+ decision: z.ZodEnum<{
58
+ deny: "deny";
59
+ allow: "allow";
60
+ approve: "approve";
61
+ }>;
62
+ on_violation: z.ZodOptional<z.ZodEnum<{
63
+ deny: "deny";
64
+ approve: "approve";
65
+ }>>;
66
+ unknown_args: z.ZodOptional<z.ZodEnum<{
67
+ deny: "deny";
68
+ allow: "allow";
69
+ approve: "approve";
70
+ }>>;
71
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ }, z.core.$strict>>;
73
+ }, z.core.$strict>;
74
+ export type Pack = z.infer<typeof PackSchema>;
75
+ export type PackRule = z.infer<typeof PackRuleSchema>;
76
+ export declare function loadPacks(): Pack[];
77
+ /**
78
+ * The pack for a server, recognised from what the client runs.
79
+ *
80
+ * Matched against the command and its arguments joined together, because the
81
+ * identifying part is as likely to be a package name in `args` (`npx -y
82
+ * @modelcontextprotocol/server-filesystem`) as a container image or a binary.
83
+ */
84
+ export declare function packFor(server: {
85
+ command: string;
86
+ args?: readonly string[];
87
+ }): Pack | undefined;
88
+ export interface ApplyPackOptions {
89
+ /** The upstream's name in the generated config, for namespacing. */
90
+ readonly upstreamName: string;
91
+ readonly namespace: boolean;
92
+ /** The tool names the server actually advertised, as the gateway serves them. */
93
+ readonly advertised: readonly string[];
94
+ /**
95
+ * The directory (or directories) a filesystem call is bounded to. Undefined
96
+ * or empty means no bound can be stated, and then none is written.
97
+ */
98
+ readonly within: string | readonly string[] | undefined;
99
+ }
100
+ export interface PackRuleOut {
101
+ readonly id: string;
102
+ readonly match: string;
103
+ readonly effect: string;
104
+ readonly decision: string;
105
+ readonly on_violation?: string;
106
+ readonly unknown_args?: string;
107
+ readonly args?: Record<string, {
108
+ within: string | string[];
109
+ }>;
110
+ }
111
+ export interface AppliedPack {
112
+ readonly rules: readonly PackRuleOut[];
113
+ /** Tools this pack knows that the server did not advertise. */
114
+ readonly unmatched: readonly string[];
115
+ /** Rules written without their path bound, because no directory was given. */
116
+ readonly skippedBounds: readonly string[];
117
+ }
118
+ export declare function applyPack(pack: Pack, options: ApplyPackOptions): AppliedPack;
119
+ export {};
package/dist/packs.js ADDED
@@ -0,0 +1,131 @@
1
+ import { readFileSync, readdirSync } from "node:fs";
2
+ import { dirname, isAbsolute, join, resolve } from "node:path";
3
+ import { realPathDeepest } from "hmcp-core";
4
+ import { fileURLToPath } from "node:url";
5
+ import { parse as parseYaml } from "yaml";
6
+ import { z } from "zod";
7
+ /**
8
+ * Ready-made classification for the servers people put behind a gateway
9
+ * first.
10
+ *
11
+ * The problem is day one. A tool nothing has classified is either a question
12
+ * or a wall, and a new user meets several of them before they have read
13
+ * anything about policy. A pack answers them in advance for a server whose
14
+ * tools are the same for everybody.
15
+ *
16
+ * Two rules about how they are written, both of which are about not being
17
+ * quietly wrong:
18
+ *
19
+ * - **Exact tool names, never patterns.** A glob matches one naming
20
+ * convention, so it misses `readFile` where it caught `read_file`, and
21
+ * where it does match it overrides the gateway's own classification --
22
+ * including its refusal to believe a server that marks its own delete tool
23
+ * read-only.
24
+ * - **Checked against what the server actually advertised.** A rule that
25
+ * matched nothing is reported, not written. A pack written against last
26
+ * year's release of a server must fail loudly rather than classify nothing
27
+ * while looking like it did something.
28
+ */
29
+ const PackRuleSchema = z
30
+ .object({
31
+ effect: z.enum(["read", "write", "destructive"]),
32
+ decision: z.enum(["allow", "approve", "deny"]),
33
+ on_violation: z.enum(["deny", "approve"]).optional(),
34
+ unknown_args: z.enum(["allow", "deny", "approve"]).optional(),
35
+ /** Arguments to bound to the adopted directory, for a filesystem server. */
36
+ paths: z.array(z.string().min(1)).optional()
37
+ })
38
+ .strict();
39
+ const PackSchema = z
40
+ .object({
41
+ name: z.string().min(1),
42
+ label: z.string().min(1),
43
+ /** Substrings of the command or arguments that identify this server. */
44
+ detect: z.array(z.string().min(1)).nonempty(),
45
+ path_bound: z.boolean().optional(),
46
+ tools: z.record(z.string().min(1), PackRuleSchema)
47
+ })
48
+ .strict();
49
+ /** Where the packs live, both in this repo and in the published package. */
50
+ function packsDir() {
51
+ // `dist/packs.js` -> package root -> packs/
52
+ return resolve(dirname(fileURLToPath(import.meta.url)), "..", "packs");
53
+ }
54
+ let cached;
55
+ export function loadPacks() {
56
+ if (cached)
57
+ return cached;
58
+ const dir = packsDir();
59
+ const packs = [];
60
+ for (const file of readdirSync(dir).sort()) {
61
+ if (!file.endsWith(".yaml"))
62
+ continue;
63
+ packs.push(PackSchema.parse(parseYaml(readFileSync(join(dir, file), "utf8"))));
64
+ }
65
+ cached = packs;
66
+ return packs;
67
+ }
68
+ /**
69
+ * The pack for a server, recognised from what the client runs.
70
+ *
71
+ * Matched against the command and its arguments joined together, because the
72
+ * identifying part is as likely to be a package name in `args` (`npx -y
73
+ * @modelcontextprotocol/server-filesystem`) as a container image or a binary.
74
+ */
75
+ export function packFor(server) {
76
+ const haystack = [server.command, ...(server.args ?? [])].join(" ").toLowerCase();
77
+ return loadPacks().find((pack) => pack.detect.some((needle) => haystack.includes(needle.toLowerCase())));
78
+ }
79
+ /**
80
+ * The folders as the bound is written: each one's real path, so a folder
81
+ * chosen through a symlink (macOS `/var` is `/private/var`) reads in the
82
+ * settings file as the place it really is, the spelling a filesystem server
83
+ * reports and an AI then sends (UT4 N8). The check itself compares real paths
84
+ * too, so either spelling works; this keeps what a reviewer reads honest. One
85
+ * folder stays a plain string, as bounds were always written.
86
+ */
87
+ function boundFolders(given) {
88
+ const list = (typeof given === "string" ? [given] : (given ?? [])).filter((d) => d.length > 0);
89
+ if (list.length === 0)
90
+ return undefined;
91
+ const real = [...new Set(list.map((d) => (isAbsolute(d) ? realPathDeepest(d) : d)))];
92
+ return real.length === 1 ? real[0] : real;
93
+ }
94
+ export function applyPack(pack, options) {
95
+ const advertised = new Set(options.advertised);
96
+ const rules = [];
97
+ const unmatched = [];
98
+ const skippedBounds = [];
99
+ const within = boundFolders(options.within);
100
+ for (const [remote, rule] of Object.entries(pack.tools)) {
101
+ const local = options.namespace ? `${options.upstreamName}__${remote}` : remote;
102
+ if (!advertised.has(local)) {
103
+ unmatched.push(remote);
104
+ continue;
105
+ }
106
+ let args;
107
+ if (rule.paths && rule.paths.length > 0) {
108
+ if (within === undefined) {
109
+ /*
110
+ * A bound nobody can state is left out and said out loud. Guessing a
111
+ * directory would be worse than no bound at all: the wrong one reads
112
+ * as protection and is not.
113
+ */
114
+ skippedBounds.push(local);
115
+ }
116
+ else {
117
+ args = Object.fromEntries(rule.paths.map((p) => [p, { within }]));
118
+ }
119
+ }
120
+ rules.push({
121
+ id: `pack-${pack.name}-${remote}`,
122
+ match: local,
123
+ effect: rule.effect,
124
+ decision: rule.decision,
125
+ ...(rule.on_violation ? { on_violation: rule.on_violation } : {}),
126
+ ...(rule.unknown_args ? { unknown_args: rule.unknown_args } : {}),
127
+ ...(args ? { args } : {})
128
+ });
129
+ }
130
+ return { rules, unmatched: unmatched.sort(), skippedBounds };
131
+ }
@@ -0,0 +1,28 @@
1
+ import { describeContractChange } from "hmcp-core";
2
+ /**
3
+ * The operator's side of pinning: what changed, and saying it is fine.
4
+ *
5
+ * Without `accept`, a reported change can only be silenced by letting the
6
+ * gateway record it quietly on the next start, which would mean a reviewer
7
+ * could never say "I looked at this and it is all right" in a way that is
8
+ * written down. With `on_tool_change: deny` it is also the only way to get a
9
+ * changed tool served again.
10
+ */
11
+ export declare class PinCommandError extends Error {
12
+ }
13
+ export interface PinCommandOptions {
14
+ readonly config: string;
15
+ readonly action: "list" | "accept";
16
+ readonly tool?: string | undefined;
17
+ /** Accept every changed tool at once. */
18
+ readonly all?: boolean | undefined;
19
+ readonly by?: string | undefined;
20
+ readonly json?: boolean | undefined;
21
+ readonly write: (line: string) => void;
22
+ }
23
+ export declare function runPinCommand(options: PinCommandOptions): Promise<void>;
24
+ /** For a caller that wants the change list without the printing. */
25
+ export declare function changeSummary(changed: readonly {
26
+ localName: string;
27
+ }[]): string | undefined;
28
+ export { describeContractChange };
@@ -0,0 +1,103 @@
1
+ import { ApprovalStore, contractDigest, describeContractChange, TOOL_CHANGED_RULE } from "hmcp-core";
2
+ import { openGateway } from "./open.js";
3
+ /**
4
+ * The operator's side of pinning: what changed, and saying it is fine.
5
+ *
6
+ * Without `accept`, a reported change can only be silenced by letting the
7
+ * gateway record it quietly on the next start, which would mean a reviewer
8
+ * could never say "I looked at this and it is all right" in a way that is
9
+ * written down. With `on_tool_change: deny` it is also the only way to get a
10
+ * changed tool served again.
11
+ */
12
+ export class PinCommandError extends Error {
13
+ }
14
+ export async function runPinCommand(options) {
15
+ const { write } = options;
16
+ const opened = openGateway(options.config);
17
+ const { gateway, config, policy, base } = opened;
18
+ const component = `gateway:${config.name}`;
19
+ try {
20
+ /*
21
+ * Connecting is what makes this honest: the comparison is against what
22
+ * the servers advertise now, not against a cached list. It also means the
23
+ * pin check has just run, so `changedTools()` is this moment's answer.
24
+ */
25
+ await gateway.connectUpstreams();
26
+ const changed = gateway.changedTools();
27
+ const store = new ApprovalStore(policy.approvals.store_path, base);
28
+ try {
29
+ if (options.action === "list") {
30
+ if (options.json) {
31
+ write(JSON.stringify({ changed, pins: store.listPins(component) }, null, 2));
32
+ return;
33
+ }
34
+ if (changed.length === 0) {
35
+ write("Every tool matches what this gateway last saw it advertise.");
36
+ write(`${store.listPins(component).length} tool(s) pinned.`);
37
+ return;
38
+ }
39
+ write(`${changed.length} tool(s) advertise something different from what was pinned:`);
40
+ write("");
41
+ for (const entry of changed) {
42
+ write(` ${entry.localName}`);
43
+ write(` pinned ${new Date(entry.pinnedAt).toISOString()}`);
44
+ write(` was ${entry.was.slice(0, 16)}… now ${entry.digest.slice(0, 16)}…`);
45
+ }
46
+ write("");
47
+ write(`The audit log carries one ${TOOL_CHANGED_RULE} record per change, naming which part changed.`);
48
+ write("Review them, then accept what is right: hmcp-gateway pin accept <tool>");
49
+ return;
50
+ }
51
+ /*
52
+ * Accepting takes the digest from this process's own look at the
53
+ * upstream rather than from an argument. A reviewer who could pass a
54
+ * digest could accept a contract they had never seen.
55
+ */
56
+ const targets = options.all
57
+ ? [...gateway.inventory()]
58
+ : gateway.inventory().filter((t) => t.localName === options.tool);
59
+ if (!options.all && options.tool === undefined) {
60
+ throw new PinCommandError("say which tool to accept, or pass --all.");
61
+ }
62
+ if (targets.length === 0) {
63
+ throw new PinCommandError(`this gateway does not serve a tool called "${options.tool}". ` +
64
+ `hmcp-gateway pin list shows what changed.`);
65
+ }
66
+ let accepted = 0;
67
+ for (const entry of targets) {
68
+ const contract = {
69
+ effect: entry.effect ?? null,
70
+ description: entry.tool.description,
71
+ inputSchema: entry.tool.inputSchema,
72
+ annotations: entry.tool.annotations ?? null
73
+ };
74
+ const written = store.acceptPin(component, entry.localName, contractDigest(contract), options.by ?? "operator", Date.now(), contract);
75
+ if (written)
76
+ accepted++;
77
+ const was = changed.find((c) => c.localName === entry.localName);
78
+ write(was || written
79
+ ? `Accepted ${entry.localName}: what it advertises now is what this gateway will expect.`
80
+ : `Already pinned ${entry.localName} (it had not changed).`);
81
+ }
82
+ if (accepted > 0 && policy.on_tool_change === "deny") {
83
+ write("");
84
+ write("Restart the gateway for an accepted tool to be served again.");
85
+ }
86
+ }
87
+ finally {
88
+ store.close();
89
+ }
90
+ }
91
+ finally {
92
+ await gateway.close();
93
+ }
94
+ }
95
+ /** For a caller that wants the change list without the printing. */
96
+ export function changeSummary(changed) {
97
+ if (changed.length === 0)
98
+ return undefined;
99
+ const names = changed.map((c) => c.localName);
100
+ return (`${names.length} tool(s) advertise something different from what was pinned ` +
101
+ `(${names.slice(0, 3).join(", ")}${names.length > 3 ? ", …" : ""}); hmcp-gateway pin list`);
102
+ }
103
+ export { describeContractChange };
@@ -0,0 +1,31 @@
1
+ import { type Policy, type SecretStore } from "hmcp-core";
2
+ import { type Upstream } from "./config.js";
3
+ import type { ProbeOutcome } from "./contracts.js";
4
+ export interface ProbeUpstreamOptions {
5
+ /** The gateway's policy, with the upstream's hosts already allowed for the test. */
6
+ policy: Policy;
7
+ /** Where `{ secret }` values resolve from. */
8
+ secrets?: SecretStore;
9
+ /** Folder the server starts in when it has no cwd. */
10
+ cwd: string;
11
+ timeoutMs?: number;
12
+ /** Rule pack to preview against the tools found. */
13
+ packId?: string;
14
+ within?: string[];
15
+ /**
16
+ * Stops the test: the gateway it built is closed, which closes the server
17
+ * it started, and the probe returns once that is done. The console's hard
18
+ * stop uses it, so a test past its time does not go on in the background.
19
+ */
20
+ signal?: AbortSignal;
21
+ /**
22
+ * A harmless call to make once the tools are listed (from our own catalog
23
+ * only), so a wrong key or an unusable file shows up in the test. Its
24
+ * answer is never shown; only whether it failed, and why in plain words.
25
+ */
26
+ checkCall?: {
27
+ tool: string;
28
+ args: Record<string, unknown>;
29
+ };
30
+ }
31
+ export declare function probeUpstream(spec: Upstream, options: ProbeUpstreamOptions): Promise<ProbeOutcome>;