@fidacy/mcp 0.6.2 → 0.6.3

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/core.js CHANGED
@@ -488,7 +488,7 @@ function resolveMandateRules(cfg) {
488
488
  }
489
489
 
490
490
  // src/telemetry.ts
491
- var CLIENT_VERSION = true ? "0.6.2" : "dev";
491
+ var CLIENT_VERSION = true ? "0.6.3" : "dev";
492
492
  function bandOf(amount) {
493
493
  if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
494
494
  if (amount < 10) return "lt10";
package/dist/index.js CHANGED
@@ -15,6 +15,17 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/config.ts
18
+ var config_exports = {};
19
+ __export(config_exports, {
20
+ auditLogPath: () => auditLogPath,
21
+ configDir: () => configDir,
22
+ configPath: () => configPath,
23
+ ensureState: () => ensureState,
24
+ hasEngineKey: () => hasEngineKey,
25
+ readConfig: () => readConfig,
26
+ resolveMandateRules: () => resolveMandateRules,
27
+ writeConfig: () => writeConfig
28
+ });
18
29
  import { randomUUID as randomUUID2 } from "node:crypto";
19
30
  import { homedir } from "node:os";
20
31
  import { join } from "node:path";
@@ -214,7 +225,7 @@ var init_telemetry = __esm({
214
225
  "src/telemetry.ts"() {
215
226
  "use strict";
216
227
  init_config();
217
- CLIENT_VERSION = true ? "0.6.2" : "dev";
228
+ CLIENT_VERSION = true ? "0.6.3" : "dev";
218
229
  currentShell = "mcp";
219
230
  anonIdCache = null;
220
231
  buffer = [];
@@ -291,7 +302,7 @@ var init_register = __esm({
291
302
  "src/register.ts"() {
292
303
  "use strict";
293
304
  init_config();
294
- CLIENT_VERSION3 = true ? "0.6.2" : "dev";
305
+ CLIENT_VERSION3 = true ? "0.6.3" : "dev";
295
306
  }
296
307
  });
297
308
 
@@ -583,6 +594,7 @@ var init_setup = __esm({
583
594
  // src/index.ts
584
595
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
585
596
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
597
+ import { createHash as createHash2 } from "node:crypto";
586
598
  import { z } from "zod";
587
599
 
588
600
  // src/core.ts
@@ -1267,7 +1279,7 @@ init_telemetry();
1267
1279
 
1268
1280
  // src/provision.ts
1269
1281
  init_config();
1270
- var CLIENT_VERSION2 = true ? "0.6.2" : "dev";
1282
+ var CLIENT_VERSION2 = true ? "0.6.3" : "dev";
1271
1283
  function provisionEnabled() {
1272
1284
  const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
1273
1285
  return !(v === "1" || v === "true" || v === "yes");
@@ -1644,8 +1656,12 @@ function renderAlertLine(alerts) {
1644
1656
  var state = ensureState();
1645
1657
  var core = makeCore();
1646
1658
  var subject = process.env.FIDACY_SUBJECT ?? "agent:demo";
1647
- var SERVER_VERSION = true ? "0.6.2" : "dev";
1659
+ var SERVER_VERSION = true ? "0.6.3" : "dev";
1648
1660
  var bootClaim = claimUrl();
1661
+ function derivedIdempotencyKey(req) {
1662
+ const material = [req.payee, req.amount, req.currency, req.invoiceRef ?? "", req.category ?? ""].join("|");
1663
+ return "auto-" + createHash2("sha256").update(material).digest("hex").slice(0, 24);
1664
+ }
1649
1665
  var server = new McpServer(
1650
1666
  // The commercial identity. `name` is the stable slug hosts key on; `title` is
1651
1667
  // what a human reads in the client's server list. The npm package stays
@@ -1679,7 +1695,9 @@ server.registerTool(
1679
1695
  "Your stated reason for this payment, in your own words. It is persisted readably on the tamper-evident audit record (ALLOW and DENY alike) and becomes part of the after-the-fact proof, so write the real reason."
1680
1696
  ),
1681
1697
  category: z.string().describe("Purpose category (must be allowed by the mandate)"),
1682
- idempotencyKey: z.string().describe("Caller-supplied idempotency key"),
1698
+ idempotencyKey: z.string().describe(
1699
+ "Optional. Your own key for this payment, if you have one (an order id, a job id). Leave it out and Fidacy derives one from the payment itself, which is the safer default: a retry of the SAME payment produces the SAME key, where an invented one would not."
1700
+ ).optional(),
1683
1701
  invoiceRef: z.string().describe(
1684
1702
  "Optional invoice identity. When set, Fidacy enforces one payment per invoice: a second request for the same invoiceRef is DENIED, at any amount."
1685
1703
  ).optional()
@@ -1714,7 +1732,10 @@ server.registerTool(
1714
1732
  };
1715
1733
  return { content: [{ type: "text", text: halted }], structuredContent: out2 };
1716
1734
  }
1717
- const req = args;
1735
+ const req = {
1736
+ ...args,
1737
+ idempotencyKey: args.idempotencyKey || derivedIdempotencyKey(args)
1738
+ };
1718
1739
  let sentinelAlerts = [];
1719
1740
  try {
1720
1741
  const [before, mandate] = await Promise.all([core.history(5e3), core.getMandate(subject)]);
@@ -2074,6 +2095,32 @@ async function main() {
2074
2095
  await runSetup2({ force: true });
2075
2096
  return;
2076
2097
  }
2098
+ const allowAt = process.argv.indexOf("allow");
2099
+ if (allowAt !== -1) {
2100
+ const { readConfig: readConfig2, writeConfig: writeConfig2, configPath: configPath2 } = await Promise.resolve().then(() => (init_config(), config_exports));
2101
+ const payees = process.argv.slice(allowAt + 1).filter((a) => !a.startsWith("-"));
2102
+ if (!payees.length) {
2103
+ console.error("Usage: npx @fidacy/mcp allow <payee> [more payees\u2026]\nApproves counterparties this agent may pay. Everything else stays denied.");
2104
+ process.exitCode = 1;
2105
+ return;
2106
+ }
2107
+ const cfg = readConfig2();
2108
+ if (!cfg) {
2109
+ console.error("No Fidacy config yet. Run the agent once (or `npx @fidacy/mcp setup`) so the install exists, then approve a payee.");
2110
+ process.exitCode = 1;
2111
+ return;
2112
+ }
2113
+ const mandate = { ...cfg.mandate ?? {} };
2114
+ const current = Array.isArray(mandate.payees) ? mandate.payees : [];
2115
+ const added = payees.filter((p) => !current.includes(p));
2116
+ mandate.payees = [...current, ...added];
2117
+ writeConfig2({ ...cfg, mandate });
2118
+ console.error(
2119
+ added.length ? `Approved ${added.map((p) => `"${p}"`).join(", ")}. This agent may now pay ${added.length === 1 ? "that counterparty" : "those counterparties"} within the mandate's caps; everything else is still denied.
2120
+ Written to ${configPath2()}. The firewall picks it up on the next call, no restart needed.` : `Already approved: ${payees.map((p) => `"${p}"`).join(", ")}. Nothing changed.`
2121
+ );
2122
+ return;
2123
+ }
2077
2124
  const transport = new StdioServerTransport();
2078
2125
  await server.connect(transport);
2079
2126
  if (state.firstRun) recordInstall();
package/dist/lib.js CHANGED
@@ -643,7 +643,7 @@ function resolveMandateRules(cfg) {
643
643
  }
644
644
 
645
645
  // src/telemetry.ts
646
- var CLIENT_VERSION = true ? "0.6.2" : "dev";
646
+ var CLIENT_VERSION = true ? "0.6.3" : "dev";
647
647
  function bandOf(amount) {
648
648
  if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
649
649
  if (amount < 10) return "lt10";
@@ -831,7 +831,7 @@ function requestUpgrade() {
831
831
  }
832
832
 
833
833
  // src/provision.ts
834
- var CLIENT_VERSION2 = true ? "0.6.2" : "dev";
834
+ var CLIENT_VERSION2 = true ? "0.6.3" : "dev";
835
835
  function provisionEnabled() {
836
836
  const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
837
837
  return !(v === "1" || v === "true" || v === "yes");
@@ -994,7 +994,7 @@ function activationBootLine() {
994
994
  }
995
995
 
996
996
  // src/register.ts
997
- var CLIENT_VERSION3 = true ? "0.6.2" : "dev";
997
+ var CLIENT_VERSION3 = true ? "0.6.3" : "dev";
998
998
  function endpoint3() {
999
999
  const base = (process.env.FIDACY_ENGINE_URL ?? "https://api.fidacy.com").replace(/\/$/, "");
1000
1000
  return `${base}/v1/register`;
@@ -134,7 +134,7 @@ var init_register = __esm({
134
134
  "src/register.ts"() {
135
135
  "use strict";
136
136
  init_config();
137
- CLIENT_VERSION = true ? "0.6.2" : "dev";
137
+ CLIENT_VERSION = true ? "0.6.3" : "dev";
138
138
  }
139
139
  });
140
140
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fidacy/mcp",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Fidacy action firewall for AI agents. Mandate-gated payment authorization as an MCP server.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fidacy (ZeepCode Group Technology LLC) <hello@fidacy.com> (https://fidacy.com)",