hmcp-gateway 0.2.0 → 0.2.2

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/dist/cli.js CHANGED
@@ -360,7 +360,8 @@ function withRuleOptions(command) {
360
360
  .option("--reason <text>", "recorded in the rule, the log, and told to the model on a refusal")
361
361
  .option("--bound <path.key=value>", "argument bound, repeatable", collect, [])
362
362
  .option("--on-violation <kind>", "what a call outside the bounds gets: deny | approve")
363
- .option("--unknown-args <kind>", "an argument no bound claims: allow | deny | approve")
363
+ .option("--unknown-args <kind>", "an argument no bound claims: allow | deny | approve. With --bound and no --unknown-args it follows " +
364
+ "--on-violation (deny by default), so a required argument no --bound mentions refuses every call")
364
365
  .option("--keep-bounds", "carry the bounds the governing rule sets", false)
365
366
  .option("--drop-bounds", "write a rule with no bounds, even where bounds exist today", false)
366
367
  .option("--override-deny <rule-id>", "name the rule whose decision this reverses")
package/dist/rule-cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createInterface } from "node:readline/promises";
2
2
  import { dirname, resolve } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
- import { ApprovalStore, AuditLog, TOOL_RULE_CLEAR, TOOL_RULE_SET, TOOL_RULE_UPDATE, clearToolRule, parseToolRuleDraft, policyDigest, previewClearToolRule, previewToolRule, ruleToYaml, runtimeStateIsLive, writeToolRule } from "hmcp-core";
4
+ import { ApprovalStore, AuditLog, TOOL_RULE_CLEAR, TOOL_RULE_SET, TOOL_RULE_UPDATE, clearToolRule, parseToolRuleDraft, policyDigest, previewClearToolRule, previewToolRule, requiredInputsCaught, ruleToYaml, runtimeStateIsLive, writeToolRule } from "hmcp-core";
5
5
  import { loadGatewayConfig } from "./config.js";
6
6
  export class RuleCommandError extends Error {
7
7
  }
@@ -254,6 +254,27 @@ export async function runRuleCommand(options) {
254
254
  }
255
255
  if (preview.nameContradiction)
256
256
  write(` warning: ${preview.nameContradiction}`);
257
+ /*
258
+ * Bounds with no --unknown-args catch every input they don't mention
259
+ * (deny, unless --on-violation approve). A required one is in every
260
+ * call, so the rule would refuse or hold all of them while the line
261
+ * above says the tool runs.
262
+ */
263
+ for (const name of requiredInputsCaught(parseSchema(row.input_schema), preview.rule)) {
264
+ const outcome = preview.rule.unknown_args === "approve" ? "wait for a human" : "be refused";
265
+ write(` warning: ${JSON.stringify(name)} is required and no --bound mentions it, so every call would ` +
266
+ `${outcome} (unknown_args: ${preview.rule.unknown_args}). Bound it too, or pass --unknown-args allow.`);
267
+ }
268
+ /*
269
+ * No bounds, yet every argument is caught: a rule written that way is
270
+ * kept, as the console keeps it, and --drop-bounds does not change it
271
+ * (there are no bounds to drop). Said here, not left to the YAML.
272
+ */
273
+ if (Object.keys(preview.rule.args ?? {}).length === 0 && preview.rule.unknown_args !== "allow") {
274
+ const verb = preview.rule.unknown_args === "approve" ? "holds for a human" : "refuses";
275
+ write(` note: this rule has no bounds, and still ${verb} any argument it is sent ` +
276
+ `(unknown_args: ${preview.rule.unknown_args}), as the console keeps it. Pass --unknown-args allow to let them through.`);
277
+ }
257
278
  write("");
258
279
  for (const line of ruleToYaml(preview.rule).split("\n"))
259
280
  write(` ${line}`);
@@ -364,6 +385,15 @@ function describeNow(preview) {
364
385
  }
365
386
  return `${verdict(preview.current.kind)}, under "${preview.current.ruleId}"`;
366
387
  }
388
+ /** The published schema, or nothing when it does not parse: then no warning is better than a wrong one. */
389
+ function parseSchema(text) {
390
+ try {
391
+ return JSON.parse(text);
392
+ }
393
+ catch {
394
+ return undefined;
395
+ }
396
+ }
367
397
  function describeBounds(bounds) {
368
398
  if (!bounds)
369
399
  return "none";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hmcp-gateway",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A policy gateway that sits between an agent and the MCP servers it uses, enforcing what each tool may do.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Aditya Das",
@@ -44,8 +44,8 @@
44
44
  "node": ">=22.19.0"
45
45
  },
46
46
  "dependencies": {
47
- "hmcp-core": "0.2.0",
48
- "hmcp-scanner": "0.2.0",
47
+ "hmcp-core": "0.2.2",
48
+ "hmcp-scanner": "0.2.2",
49
49
  "@modelcontextprotocol/sdk": "^1.32.1",
50
50
  "commander": "^15.0.0",
51
51
  "smol-toml": "^1.9.1",