aegis-x402-mcp 1.0.1 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +5 -4
  2. package/dist/index.js +30 -21
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -114,13 +114,14 @@ Add to `~/.codeium/windsurf/mcp_config.json`:
114
114
  ## Publishing & Registry Registration
115
115
 
116
116
  ### Official Model Context Protocol Registry
117
- Submit PR to: [modelcontextprotocol/servers](https://github.com/modelcontextprotocol/servers)
117
+ Published on the official MCP Registry: [registry.modelcontextprotocol.io](https://registry.modelcontextprotocol.io) via `mcp-publisher`.
118
118
 
119
- ### Community Registries
120
- - **Smithery:** Run `npx -y @smithery/cli install aegis-x402-mcp`
121
- - **mcp.so:** Submit package `aegis-x402-mcp`
119
+ ### Community Registries & Discovery
120
+ - **NPM:** [https://www.npmjs.com/package/aegis-x402-mcp](https://www.npmjs.com/package/aegis-x402-mcp)
121
+ - **GitHub:** [https://github.com/Goatincrypto/aegis-x402-mcp](https://github.com/Goatincrypto/aegis-x402-mcp)
122
122
  - **Glama:** [glama.ai/mcp/servers](https://glama.ai/mcp/servers)
123
123
  - **PulseMCP:** [pulsemcp.com](https://pulsemcp.com)
124
+ - **Smithery:** `npx -y @smithery/cli install aegis-x402-mcp`
124
125
 
125
126
  ---
126
127
 
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
5
  import { privateKeyToAccount } from 'viem/accounts';
6
+ import { getAddress } from 'viem';
6
7
  import { randomBytes } from 'crypto';
7
8
  const GATEWAY_URL = process.env.AEGIS_GATEWAY_URL || 'https://aegis-audit-x402.project-easy-x.workers.dev';
8
9
  const API_KEY = process.env.AEGIS_API_KEY || process.env.AEGIS_CREDIT_TOKEN || '';
@@ -15,7 +16,7 @@ const BASE_USDC = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'.toLowerCase();
15
16
  * Keys never leave the local machine.
16
17
  * Protected by strict recipient allowlist guard: only signs toward official Aegis address.
17
18
  */
18
- async function signEip3009Payment(privateKeyHex, accepts) {
19
+ async function signEip3009Payment(privateKeyHex, accepts, resource) {
19
20
  const cleanKey = privateKeyHex.trim().startsWith('0x')
20
21
  ? privateKeyHex.trim()
21
22
  : `0x${privateKeyHex.trim()}`;
@@ -25,14 +26,18 @@ async function signEip3009Payment(privateKeyHex, accepts) {
25
26
  throw new Error(`SECURITY_RECIPIENT_GUARD: Recipient ${recipient} is not official Aegis receiver (${ALLOWED_PAYTO}). Signing refused.`);
26
27
  }
27
28
  const nonce = `0x${randomBytes(32).toString('hex')}`;
28
- const validAfter = 0n;
29
- const validBefore = BigInt(Math.floor(Date.now() / 1000) + 3600);
30
- const value = BigInt(accepts.amount || '10000');
29
+ const validAfterStr = '0';
30
+ const maxTimeout = typeof accepts.maxTimeoutSeconds === 'number' ? accepts.maxTimeoutSeconds : 300;
31
+ const validBeforeStr = String(Math.floor(Date.now() / 1000) + maxTimeout);
32
+ const valueStr = String(accepts.amount || '10000');
33
+ const fromChecksum = getAddress(account.address);
34
+ const toChecksum = getAddress(accepts.payTo || accepts.recipient);
35
+ const assetChecksum = getAddress(accepts.asset || BASE_USDC);
31
36
  const domain = {
32
37
  name: accepts.extra?.name || 'USD Coin',
33
38
  version: accepts.extra?.version || '2',
34
39
  chainId: 8453,
35
- verifyingContract: (accepts.asset || BASE_USDC),
40
+ verifyingContract: assetChecksum,
36
41
  };
37
42
  const types = {
38
43
  TransferWithAuthorization: [
@@ -49,29 +54,33 @@ async function signEip3009Payment(privateKeyHex, accepts) {
49
54
  types,
50
55
  primaryType: 'TransferWithAuthorization',
51
56
  message: {
52
- from: account.address,
53
- to: accepts.payTo,
54
- value,
55
- validAfter,
56
- validBefore,
57
+ from: fromChecksum,
58
+ to: toChecksum,
59
+ value: BigInt(valueStr),
60
+ validAfter: BigInt(validAfterStr),
61
+ validBefore: BigInt(validBeforeStr),
57
62
  nonce,
58
63
  },
59
64
  });
65
+ const authorization = {
66
+ from: fromChecksum,
67
+ to: toChecksum,
68
+ value: valueStr,
69
+ validAfter: validAfterStr,
70
+ validBefore: validBeforeStr,
71
+ nonce,
72
+ };
60
73
  const paymentPayload = {
61
74
  x402Version: 2,
62
- scheme: 'exact',
63
- network: 'eip155:8453',
64
- asset: accepts.asset || BASE_USDC,
65
75
  payload: {
66
- from: account.address,
67
- to: accepts.payTo,
68
- value: value.toString(),
69
- validAfter: Number(validAfter),
70
- validBefore: Number(validBefore),
71
- nonce,
76
+ authorization,
72
77
  signature,
73
78
  },
79
+ accepted: accepts,
74
80
  };
81
+ if (resource) {
82
+ paymentPayload.resource = resource;
83
+ }
75
84
  return Buffer.from(JSON.stringify(paymentPayload)).toString('base64');
76
85
  }
77
86
  /**
@@ -101,7 +110,7 @@ async function fetchFromAegis(endpoint, options = {}) {
101
110
  // Tier 3: If user provided a local private key, sign and retry in-flight
102
111
  if (PRIVATE_KEY && accepts) {
103
112
  try {
104
- const signedHeader = await signEip3009Payment(PRIVATE_KEY, accepts);
113
+ const signedHeader = await signEip3009Payment(PRIVATE_KEY, accepts, paymentReq?.resource);
105
114
  const retryHeaders = {
106
115
  ...headers,
107
116
  'X-PAYMENT': signedHeader,
@@ -136,7 +145,7 @@ async function fetchFromAegis(endpoint, options = {}) {
136
145
  }
137
146
  const server = new Server({
138
147
  name: 'aegis-x402-mcp',
139
- version: '1.0.0',
148
+ version: '1.0.2',
140
149
  }, {
141
150
  capabilities: {
142
151
  tools: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-x402-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Model Context Protocol (MCP) server for AegisAudit x402 Security Intelligence, PreFlight Bundles, KYA, and Grounded AI on Base",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",