troxy-cli 1.4.4 → 1.4.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.
package/bin/troxy.js CHANGED
@@ -309,6 +309,7 @@ switch (command) {
309
309
  troxy policies list
310
310
  troxy policies describe --name "Block Amazon"
311
311
  troxy policies create --name "X" --action BLOCK --field amount --operator gte --value 500
312
+ troxy policies create --name "X" --action BLOCK --mcp "My Laptop" (scoped to one MCP)
312
313
  troxy policies enable --name "X"
313
314
  troxy policies disable --name "X"
314
315
  troxy policies delete --name "X"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "troxy-cli",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "AI payment control — protect your agent's payments with policies",
5
5
  "type": "module",
6
6
  "bin": {
package/src/policies.js CHANGED
@@ -82,8 +82,30 @@ export async function runPolicies([sub, ...args], flags) {
82
82
  if (flags.value2) cond.value2 = flags.value2;
83
83
  conditions.push(cond);
84
84
  }
85
- const policy = await api.createPolicy(jwt, { name, action, conditions, enabled: true });
86
- console.log(`\n Policy "${policy.name}" created ✓ (priority: ${policy.priority})\n`);
85
+
86
+ // --mcp <name>: scope policy to a specific MCP instead of all
87
+ let isGlobal = true;
88
+ let mcpIds = [];
89
+ if (flags.mcp) {
90
+ const { tokens = [] } = await api.listTokens(jwt);
91
+ const needle = flags.mcp.toLowerCase();
92
+ const match = tokens.find(t =>
93
+ (t.name && t.name.toLowerCase() === needle) ||
94
+ (t.agent_name && t.agent_name.toLowerCase() === needle) ||
95
+ (t.prefix && t.prefix.toLowerCase().startsWith(needle))
96
+ );
97
+ if (!match) {
98
+ console.error(`\n MCP "${flags.mcp}" not found. Run: troxy mcps list\n`);
99
+ process.exit(1);
100
+ }
101
+ isGlobal = false;
102
+ mcpIds = [match.id];
103
+ console.log(`\n Scoping to MCP: ${match.name || match.agent_name || match.prefix}`);
104
+ }
105
+
106
+ const policy = await api.createPolicy(jwt, { name, action, conditions, enabled: true, global: isGlobal, mcp_ids: mcpIds });
107
+ const scope = isGlobal ? 'all MCPs' : (policy.mcps?.[0]?.name || flags.mcp);
108
+ console.log(`\n Policy "${policy.name}" created ✓ (priority: ${policy.priority}, scope: ${scope})\n`);
87
109
  break;
88
110
  }
89
111