@auctra/mcp-gateway 0.1.4 → 0.1.5

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 +18 -0
  2. package/package.json +1 -1
  3. package/src/index.ts +59 -0
package/README.md CHANGED
@@ -30,6 +30,24 @@ const sendEmail = withAuctraGate({
30
30
 
31
31
  Blocked or approval-required tool calls throw `McpToolBlockedError` with the decision evidence hash when present.
32
32
 
33
+ ## NL→SQL data scope (`gateMcpSqlQuery`)
34
+
35
+ Declare requested vs authorized query scope so the production gate can emit `SQL_SCOPE_EXCEEDED`:
36
+
37
+ ```ts
38
+ import { gateMcpSqlQuery } from "@auctra/mcp-gateway";
39
+
40
+ await gateMcpSqlQuery({
41
+ client,
42
+ agentId: "agent-uuid",
43
+ toolName: "customer_query",
44
+ requestedScope: "customers.*",
45
+ authorizedScope: "customers.aggregate_metrics",
46
+ claimedIntentId: intent.id,
47
+ intentAnchorToken: intent.anchor_token,
48
+ });
49
+ ```
50
+
33
51
  ## Engine 15 — MCP / skill install attestation
34
52
 
35
53
  High-impact installs require `mcp_install` + HMAC `supply_chain_attestation` on the gate.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auctra/mcp-gateway",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "MCP gateway — gate tool calls and MCP/skill installs through Auctra action.execute",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.ts CHANGED
@@ -349,3 +349,62 @@ export function withAuctraGate<TArgs extends Record<string, unknown>, TResult>(
349
349
  };
350
350
  };
351
351
  }
352
+
353
+ /**
354
+ * Gate an NL→SQL / database tool call with declared data scope metadata.
355
+ * Production path: same action.execute gate companies use — requested ⊆ authorized.
356
+ */
357
+ export async function gateMcpSqlQuery(input: {
358
+ client: ExecuteActionClient;
359
+ agentId: string;
360
+ toolName: string;
361
+ requestedScope: string | string[];
362
+ authorizedScope?: string | string[];
363
+ args?: Record<string, unknown>;
364
+ actionType?: string;
365
+ claimedIntentId?: string;
366
+ intentAnchorToken?: string;
367
+ }) {
368
+ const result = await input.client.action.execute({
369
+ agentId: input.agentId,
370
+ actionType: input.actionType ?? "execute_sql",
371
+ claimedIntentId: input.claimedIntentId,
372
+ intentAnchorToken: input.intentAnchorToken,
373
+ payload: {
374
+ tool: input.toolName,
375
+ arguments: input.args ?? {},
376
+ resource: Array.isArray(input.requestedScope)
377
+ ? input.requestedScope[0]
378
+ : input.requestedScope,
379
+ },
380
+ action: {
381
+ target: `mcp-sql:${input.toolName}`,
382
+ description: `SQL/query tool ${input.toolName}`,
383
+ metadata: {
384
+ sql: {
385
+ requested_scope: input.requestedScope,
386
+ ...(input.authorizedScope != null
387
+ ? { authorized_scope: input.authorizedScope }
388
+ : {}),
389
+ },
390
+ inputs: [
391
+ {
392
+ source: `mcp:${input.toolName}:sql`,
393
+ source_type: "mcp_tool_response",
394
+ trust_level: "untrusted",
395
+ authority: "none",
396
+ claimed_influence: "privilege_escalation",
397
+ },
398
+ ],
399
+ },
400
+ },
401
+ });
402
+
403
+ if (result.decision !== "allowed") {
404
+ const evidenceId = evidenceIdFromResult(result);
405
+ const message = evidenceId ? `${result.reason} (evidence: ${evidenceId})` : result.reason;
406
+ throw new McpToolBlockedError(message, result.decision, result.evidence);
407
+ }
408
+
409
+ return result;
410
+ }