Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2f90047
Accept MPP method tempo (push mode) when MPP_TEMPO_RECIPIENT is set
claude Oct 4, 2026
6ada795
Clearer /api/explain description for agents
claude Oct 5, 2026
e2c21e4
Merge remote branch (already merged history)
claude Oct 5, 2026
57e398c
Add glama.json to claim the Glama listing
claude Oct 5, 2026
88577ee
Merge remote branch (already merged history)
claude Oct 5, 2026
2eeeeec
MCP registry: clearer description (says when an agent would use it)
claude Oct 5, 2026
ce242d7
Merge remote branch (already merged history)
claude Oct 5, 2026
71f6a3e
Homepage: a row of prices right under the intro
claude Oct 6, 2026
fd7ae48
Merge remote branch (already merged history)
claude Oct 6, 2026
193799b
Usage log: record the network a refused payment was tried on
claude Oct 6, 2026
2d888e4
Merge branch 'claude/x402-agents-solana-payments-nceg9b' of https://g…
claude Oct 6, 2026
322505c
Pay in RLUSD on the XRP Ledger (x402 exact, xrpl:0)
claude Oct 7, 2026
aa35a9d
Merge branch 'claude/x402-agents-solana-payments-nceg9b' of https://g…
claude Oct 7, 2026
633f050
XRPL: also accept payers built on t54's SDK
claude Oct 7, 2026
3033055
Merge remote-tracking branch 'origin/main' into claude/x402-agents-so…
claude Oct 7, 2026
fdab3b3
SEO: canonical tag, robots.txt and sitemap.xml for the homepage
claude Oct 7, 2026
0027283
Merge branch 'claude/x402-agents-solana-payments-nceg9b' of https://g…
claude Oct 7, 2026
823b132
CI: run the tests on every pull request and on main
claude Oct 7, 2026
60e2caa
Merge branch 'claude/x402-agents-solana-payments-nceg9b' of https://g…
claude Oct 7, 2026
d81e01e
Usage log: record why an MPP credential was refused
claude Oct 7, 2026
7a491d3
Merge branch 'claude/x402-agents-solana-payments-nceg9b' of https://g…
claude Oct 7, 2026
84c2f4e
Pay in USDC on Algorand (ALGORAND_PAY_TO)
claude Oct 8, 2026
a6cec2a
Merge remote branch
claude Oct 8, 2026
aa499c8
Name the seller in the 402: x402-merchant extension
claude Oct 9, 2026
7ec7ce1
Merge remote branch (already in main)
claude Oct 9, 2026
9c7b5d0
MCP: output schemas and structured content on every tool
claude Oct 9, 2026
3fdf50f
Merge remote branch (already in main)
claude Oct 9, 2026
80dd8e2
Merge stale remote branch claude/x402-agents-solana-payments-nceg9b
claude Oct 13, 2026
725218e
Discovery: a name and description per resource in /.well-known/x402
claude Oct 13, 2026
97ffd96
Merge stale remote branch claude/x402-agents-solana-payments-nceg9b
claude Oct 13, 2026
775fa73
Security headers on every answer
claude Oct 13, 2026
f2ea313
Merge stale remote branch claude/x402-agents-solana-payments-nceg9b
claude Oct 13, 2026
3ff3a26
Weekly dependency audit with one issue while a finding is open
claude Oct 13, 2026
5aba932
Merge stale remote branch claude/x402-agents-solana-payments-nceg9b
claude Oct 13, 2026
95976ef
Usage log: say why an x402 payment was refused
claude Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion test/usage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function logged(handler, request) {
app.use(log.middleware(describePlainTextCall));
app.all('*', handler);
const server = await new Promise((r) => { const s = app.listen(0, '127.0.0.1', () => r(s)); });
await fetch(`http://127.0.0.1:${server.address().port}${request.path}`, { method: 'POST', headers: { 'content-type': 'application/json', 'user-agent': request.agent || 'node' }, body: JSON.stringify(request.body || {}) });
await fetch(`http://127.0.0.1:${server.address().port}${request.path}`, { method: 'POST', headers: { 'content-type': 'application/json', 'user-agent': request.agent || 'node', ...request.headers }, body: JSON.stringify(request.body || {}) });
await new Promise((r) => setTimeout(r, 30));
await log.flush();
server.close();
Expand All @@ -55,6 +55,12 @@ test('usage log: a 402 is logged as a price shown, with the caller and a visitor
assert.ok(!JSON.stringify(e).includes('127.0.0.1'));
});

test('usage log: a refused x402 payment is logged with the reason the 402 gives', async () => {
const b64 = (o) => Buffer.from(JSON.stringify(o)).toString('base64');
const e = await logged((_req, res) => res.set('PAYMENT-REQUIRED', b64({ x402Version: 2, error: 'insufficient_funds', accepts: [] })).status(402).json({}), { path: '/api/check-wallet', headers: { 'payment-signature': b64({ x402Version: 2 }) } });
assert.deepEqual([e.status, e.payment_failed, e.reason], [402, true, 'insufficient_funds']);
});

test('usage log: an MCP reply sent as an event stream is read (the verdict is logged)', async () => {
const call = { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'check_wallet_approvals', arguments: { address: '0xabc' } } };
const reply = { jsonrpc: '2.0', id: 1, result: { content: [{ type: 'text', text: 'RISK: unlimited approval to an unverified spender' }] } };
Expand Down
20 changes: 19 additions & 1 deletion usage-log.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,23 @@ function visitorOf(ip, secret) {
return crypto.createHmac('sha256', secret).update(address).digest('hex').slice(0, 12);
}

// Why an x402 payment was refused. The 402 that answers it says so: PAYMENT-RESPONSE carries
// errorReason when settlement failed, PAYMENT-REQUIRED carries error when verification failed.
// Only the first line is kept, with URLs blanked: an RPC error could name a URL with a key in it.
function x402Refusal(res) {
for (const [header, field] of [['payment-response', 'errorReason'], ['payment-required', 'error']]) {
const value = res.getHeader(header);
if (!value) continue;
try {
const reason = JSON.parse(Buffer.from(String(value), 'base64').toString('utf8'))[field];
if (reason) return String(reason).split('\n')[0].replace(/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi, '<url>').slice(0, 160);
} catch {
// not an x402 header
}
}
return null;
}

function createUsageLog({ service, env = process.env, fetchFn = globalThis.fetch, now = () => new Date(), log = console } = {}) {
const token = env.USAGE_LOG_TOKEN;
const repo = env.USAGE_LOG_REPO || DEFAULT_REPO;
Expand Down Expand Up @@ -258,14 +275,15 @@ function createUsageLog({ service, env = process.env, fetchFn = globalThis.fetch
// An MPP credential (Authorization: Payment …, mpp-pay.js) counts as an offered payment too.
const mppOffered = /(?:^|,)\s*Payment\s/i.test(String(req.headers.authorization || ''));
const offered = Boolean(req.headers['payment-signature'] || req.headers['x-payment']) || mppOffered;
const refusal = quote && offered && !mppOffered ? x402Refusal(res) : null;
record({
route: described.route,
via: described.via || 'http',
status: res.statusCode,
ms: Date.now() - started,
paid: Boolean(payment),
...(payment || {}),
...(quote ? { quote: true, ...(offered ? { payment_failed: true, ...(mppOffered ? { protocol: 'mpp', ...(res.locals && res.locals.mppRefused ? { reason: res.locals.mppRefused } : {}) } : {}), ...(attemptedNetwork(req) ? { network: attemptedNetwork(req) } : {}) } : {}) } : {}),
...(quote ? { quote: true, ...(offered ? { payment_failed: true, ...(mppOffered ? { protocol: 'mpp', ...(res.locals && res.locals.mppRefused ? { reason: res.locals.mppRefused } : {}) } : refusal ? { reason: refusal } : {}), ...(attemptedNetwork(req) ? { network: attemptedNetwork(req) } : {}) } : {}) } : {}),
agent: agentOf(req.headers['user-agent']),
visitor: visitorOf(req.ip || (req.socket && req.socket.remoteAddress), visitorSecret),
input: described.input,
Expand Down
Loading