@sardis/mcp-server 1.0.0 → 1.1.0
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/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +28 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/jobs.d.ts +17 -0
- package/dist/tools/jobs.d.ts.map +1 -0
- package/dist/tools/jobs.js +583 -0
- package/dist/tools/jobs.js.map +1 -0
- package/dist/tools/trust.d.ts +7 -0
- package/dist/tools/trust.d.ts.map +1 -0
- package/dist/tools/trust.js +188 -0
- package/dist/tools/trust.js.map +1 -0
- package/dist/tools/x402.d.ts +12 -0
- package/dist/tools/x402.d.ts.map +1 -0
- package/dist/tools/x402.js +299 -0
- package/dist/tools/x402.js.map +1 -0
- package/package.json +13 -12
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trust tools for MCP server — FIDES identity and trust graph queries
|
|
3
|
+
*/
|
|
4
|
+
import { apiRequest } from '../api.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
// Schemas
|
|
7
|
+
const CheckAgentTrustSchema = z.object({
|
|
8
|
+
agent_id: z.string().describe('Agent ID to check trust score for'),
|
|
9
|
+
});
|
|
10
|
+
const VerifyAgentIdentitySchema = z.object({
|
|
11
|
+
agent_id: z.string().describe('Agent ID to verify'),
|
|
12
|
+
target_did: z.string().optional().describe('Optional target DID to find trust path to'),
|
|
13
|
+
});
|
|
14
|
+
const ViewPolicyHistorySchema = z.object({
|
|
15
|
+
agent_id: z.string().describe('Agent ID to view policy history for'),
|
|
16
|
+
limit: z.number().min(1).max(100).optional().default(20).describe('Maximum entries to return'),
|
|
17
|
+
});
|
|
18
|
+
// Tool definitions
|
|
19
|
+
export const trustToolDefinitions = [
|
|
20
|
+
{
|
|
21
|
+
name: 'sardis_check_agent_trust',
|
|
22
|
+
description: 'Query an agent\'s trust score including tier, spending limits, and signal breakdown. ' +
|
|
23
|
+
'Returns the overall trust score (0.0-1.0), trust tier (UNTRUSTED/LOW/MEDIUM/HIGH/SOVEREIGN), ' +
|
|
24
|
+
'and individual signal scores (KYA level, transaction history, compliance, reputation, behavioral, transitive trust).',
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
agent_id: { type: 'string', description: 'Agent ID to check trust score for' },
|
|
29
|
+
},
|
|
30
|
+
required: ['agent_id'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'sardis_verify_agent_identity',
|
|
35
|
+
description: 'Verify a counterparty agent\'s FIDES DID and trust level. ' +
|
|
36
|
+
'Checks if the agent has a linked FIDES identity and optionally finds the trust path to a target DID. ' +
|
|
37
|
+
'Use this before accepting payments from unknown agents.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
agent_id: { type: 'string', description: 'Agent ID to verify' },
|
|
42
|
+
target_did: { type: 'string', description: 'Optional target DID to find trust path to' },
|
|
43
|
+
},
|
|
44
|
+
required: ['agent_id'],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'sardis_view_policy_history',
|
|
49
|
+
description: 'View AGIT-signed policy change history for an agent. ' +
|
|
50
|
+
'Shows hash-chained policy commits with signatures, making policy changes auditable and tamper-evident.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
agent_id: { type: 'string', description: 'Agent ID to view policy history for' },
|
|
55
|
+
limit: { type: 'number', description: 'Maximum entries to return (default 20)' },
|
|
56
|
+
},
|
|
57
|
+
required: ['agent_id'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
// Tool handlers
|
|
62
|
+
async function handleCheckAgentTrust(args) {
|
|
63
|
+
const parsed = CheckAgentTrustSchema.parse(args);
|
|
64
|
+
try {
|
|
65
|
+
const result = await apiRequest('GET', `/api/v2/agents/${parsed.agent_id}/trust-score`);
|
|
66
|
+
const data = result;
|
|
67
|
+
const tier = data.tier || 'unknown';
|
|
68
|
+
const overall = data.overall || 0;
|
|
69
|
+
const maxPerTx = data.max_per_tx || '0';
|
|
70
|
+
const maxPerDay = data.max_per_day || '0';
|
|
71
|
+
const signals = data.signals || [];
|
|
72
|
+
const signalLines = signals
|
|
73
|
+
.map((s) => ` - ${s.name}: ${s.score?.toFixed(4)} (weight: ${s.weight})`)
|
|
74
|
+
.join('\n');
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: [
|
|
80
|
+
`Trust Score for ${parsed.agent_id}:`,
|
|
81
|
+
` Overall: ${overall.toFixed(4)}`,
|
|
82
|
+
` Tier: ${tier.toUpperCase()}`,
|
|
83
|
+
` Max per transaction: $${maxPerTx}`,
|
|
84
|
+
` Max per day: $${maxPerDay}`,
|
|
85
|
+
'',
|
|
86
|
+
'Signal breakdown:',
|
|
87
|
+
signalLines || ' No signals available',
|
|
88
|
+
].join('\n'),
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'text',
|
|
98
|
+
text: `Failed to get trust score for ${parsed.agent_id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
isError: true,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function handleVerifyAgentIdentity(args) {
|
|
106
|
+
const parsed = VerifyAgentIdentitySchema.parse(args);
|
|
107
|
+
try {
|
|
108
|
+
const identity = await apiRequest('GET', `/api/v2/agents/${parsed.agent_id}/fides/identity`);
|
|
109
|
+
const data = identity;
|
|
110
|
+
const lines = [
|
|
111
|
+
`FIDES Identity for ${parsed.agent_id}:`,
|
|
112
|
+
` FIDES DID: ${data.fides_did || 'Not linked'}`,
|
|
113
|
+
` Verified: ${data.verified_at ? 'Yes' : 'No'}`,
|
|
114
|
+
];
|
|
115
|
+
if (parsed.target_did) {
|
|
116
|
+
try {
|
|
117
|
+
const pathResult = await apiRequest('GET', `/api/v2/agents/${parsed.agent_id}/trust-path/${encodeURIComponent(parsed.target_did)}`);
|
|
118
|
+
const pathData = pathResult;
|
|
119
|
+
lines.push('');
|
|
120
|
+
lines.push(`Trust path to ${parsed.target_did}:`);
|
|
121
|
+
lines.push(` Found: ${pathData.found ? 'Yes' : 'No'}`);
|
|
122
|
+
if (pathData.found) {
|
|
123
|
+
lines.push(` Hops: ${pathData.hops}`);
|
|
124
|
+
lines.push(` Cumulative trust: ${pathData.cumulative_trust?.toFixed(4)}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
lines.push(` Trust path lookup failed for ${parsed.target_did}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return {
|
|
137
|
+
content: [
|
|
138
|
+
{
|
|
139
|
+
type: 'text',
|
|
140
|
+
text: `Failed to verify identity for ${parsed.agent_id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
isError: true,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
async function handleViewPolicyHistory(args) {
|
|
148
|
+
const parsed = ViewPolicyHistorySchema.parse(args);
|
|
149
|
+
try {
|
|
150
|
+
const result = await apiRequest('GET', `/api/v2/agents/${parsed.agent_id}/policy-history?limit=${parsed.limit}`);
|
|
151
|
+
const data = result;
|
|
152
|
+
const commits = data.commits || [];
|
|
153
|
+
if (commits.length === 0) {
|
|
154
|
+
return {
|
|
155
|
+
content: [
|
|
156
|
+
{ type: 'text', text: `No policy history found for ${parsed.agent_id}` },
|
|
157
|
+
],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const lines = [`Policy history for ${parsed.agent_id} (${commits.length} commits):`];
|
|
161
|
+
for (const commit of commits) {
|
|
162
|
+
lines.push(` ${commit.commit_hash} — ${commit.created_at || 'unknown date'}`);
|
|
163
|
+
if (commit.signed) {
|
|
164
|
+
lines.push(` Signed by: ${commit.signer_did}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
return {
|
|
173
|
+
content: [
|
|
174
|
+
{
|
|
175
|
+
type: 'text',
|
|
176
|
+
text: `Failed to get policy history for ${parsed.agent_id}: ${error instanceof Error ? error.message : String(error)}`,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
isError: true,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
export const trustToolHandlers = {
|
|
184
|
+
sardis_check_agent_trust: handleCheckAgentTrust,
|
|
185
|
+
sardis_verify_agent_identity: handleVerifyAgentIdentity,
|
|
186
|
+
sardis_view_policy_history: handleViewPolicyHistory,
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.js","sourceRoot":"","sources":["../../src/tools/trust.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAMvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,UAAU;AACV,MAAM,qBAAqB,GAAG,CAAC,C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AE,CAAC;QACf,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,oCAAoC,MAAM,CAAC,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACvH;aACF;YACD,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,wBAAwB,EAAE,qBAAqB;IAC/C,4BAA4B,EAAE,yBAAyB;IACvD,0BAA0B,EAAE,uBAAuB;CACpD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sardis MCP Server - x402 Payment Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for interacting with x402-protected APIs:
|
|
5
|
+
* - sardis_x402_pay: Pay an x402-protected endpoint
|
|
6
|
+
* - sardis_x402_preview_cost: Dry-run cost preview
|
|
7
|
+
* - sardis_x402_list_payments: Audit x402 payments
|
|
8
|
+
*/
|
|
9
|
+
import type { ToolDefinition, ToolHandler } from './types.js';
|
|
10
|
+
export declare const x402ToolDefinitions: ToolDefinition[];
|
|
11
|
+
export declare const x402ToolHandlers: Record<string, ToolHandler>;
|
|
12
|
+
//# sourceMappingURL=x402.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402.d.ts","sourceRoot":"","sources":["../../src/tools/x402.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AA8D1E,eAAO,MAAM,mBAAmB,EAAE,cAAc,EA8E/C,CAAC;AAGF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAgOxD,CAAC"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sardis MCP Server - x402 Payment Tools
|
|
3
|
+
*
|
|
4
|
+
* Tools for interacting with x402-protected APIs:
|
|
5
|
+
* - sardis_x402_pay: Pay an x402-protected endpoint
|
|
6
|
+
* - sardis_x402_preview_cost: Dry-run cost preview
|
|
7
|
+
* - sardis_x402_list_payments: Audit x402 payments
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { apiRequest } from '../api.js';
|
|
11
|
+
import { getConfig } from '../config.js';
|
|
12
|
+
// Zod schemas
|
|
13
|
+
const X402PaySchema = z.object({
|
|
14
|
+
url: z.string().url().describe('URL of the x402-protected endpoint'),
|
|
15
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE']).optional().default('GET'),
|
|
16
|
+
body: z.string().optional().describe('Request body (JSON string)'),
|
|
17
|
+
max_cost: z.string().optional().describe('Maximum amount willing to pay (e.g., "1.00")'),
|
|
18
|
+
dry_run: z.boolean().optional().default(false).describe('Preview cost without paying'),
|
|
19
|
+
preferred_network: z.string().optional().describe('Preferred blockchain network'),
|
|
20
|
+
});
|
|
21
|
+
const X402PreviewSchema = z.object({
|
|
22
|
+
url: z.string().url().describe('URL to check for x402 pricing'),
|
|
23
|
+
});
|
|
24
|
+
const X402ListPaymentsSchema = z.object({
|
|
25
|
+
limit: z.number().optional().default(20),
|
|
26
|
+
offset: z.number().optional().default(0),
|
|
27
|
+
status: z.string().optional().describe('Filter by status: verified, settled, failed'),
|
|
28
|
+
});
|
|
29
|
+
// Tool definitions
|
|
30
|
+
export const x402ToolDefinitions = [
|
|
31
|
+
{
|
|
32
|
+
name: 'sardis_x402_pay',
|
|
33
|
+
description: 'Pay an x402-protected endpoint. Makes an HTTP request, handles 402 Payment Required ' +
|
|
34
|
+
'automatically by negotiating payment, checking spending policy, signing with MPC wallet, ' +
|
|
35
|
+
'and retrying with payment. Returns the API response and payment receipt.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
url: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'URL of the x402-protected endpoint',
|
|
42
|
+
},
|
|
43
|
+
method: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
enum: ['GET', 'POST', 'PUT', 'DELETE'],
|
|
46
|
+
description: 'HTTP method (default: GET)',
|
|
47
|
+
},
|
|
48
|
+
body: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Request body as JSON string (for POST/PUT)',
|
|
51
|
+
},
|
|
52
|
+
max_cost: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Maximum amount willing to pay in human-readable units (e.g., "1.00" USDC)',
|
|
55
|
+
},
|
|
56
|
+
dry_run: {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
description: 'If true, preview the cost without making payment',
|
|
59
|
+
},
|
|
60
|
+
preferred_network: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Preferred blockchain network (e.g., "base", "polygon")',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
required: ['url'],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'sardis_x402_preview_cost',
|
|
70
|
+
description: 'Preview the cost of accessing an x402-protected endpoint without paying. ' +
|
|
71
|
+
'Checks if the endpoint requires payment and whether the current spending policy would allow it.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
url: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
description: 'URL to check for x402 pricing',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
required: ['url'],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'sardis_x402_list_payments',
|
|
85
|
+
description: 'List x402 payment records for audit and tracking.',
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
limit: {
|
|
90
|
+
type: 'number',
|
|
91
|
+
description: 'Maximum number of records to return (default: 20)',
|
|
92
|
+
},
|
|
93
|
+
offset: {
|
|
94
|
+
type: 'number',
|
|
95
|
+
description: 'Pagination offset',
|
|
96
|
+
},
|
|
97
|
+
status: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
enum: ['verified', 'settled', 'failed'],
|
|
100
|
+
description: 'Filter by payment status',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
required: [],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
// Tool handlers
|
|
108
|
+
export const x402ToolHandlers = {
|
|
109
|
+
sardis_x402_pay: async (args) => {
|
|
110
|
+
const parsed = X402PaySchema.safeParse(args);
|
|
111
|
+
if (!parsed.success) {
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: 'text', text: `Invalid request: ${parsed.error.message}` }],
|
|
114
|
+
isError: true,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const { url, method, body, max_cost, dry_run, preferred_network } = parsed.data;
|
|
118
|
+
const config = getConfig();
|
|
119
|
+
if (!config.apiKey || config.mode === 'simulated') {
|
|
120
|
+
// Simulated mode
|
|
121
|
+
const simId = `x402_sim_${Date.now().toString(36)}`;
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: 'text',
|
|
126
|
+
text: JSON.stringify({
|
|
127
|
+
success: true,
|
|
128
|
+
response: { status_code: 200, body: '{"data": "simulated_x402_response"}' },
|
|
129
|
+
payment: {
|
|
130
|
+
payment_id: simId,
|
|
131
|
+
amount: '1000000',
|
|
132
|
+
currency: 'USDC',
|
|
133
|
+
network: preferred_network || config.chain,
|
|
134
|
+
tx_hash: '0x' + Math.random().toString(16).substring(2).padEnd(64, '0'),
|
|
135
|
+
dry_run: dry_run || false,
|
|
136
|
+
},
|
|
137
|
+
cost: '$1.00 USDC',
|
|
138
|
+
message: dry_run
|
|
139
|
+
? `Dry run: accessing ${url} would cost ~$1.00 USDC`
|
|
140
|
+
: `Paid $1.00 USDC to access ${url}`,
|
|
141
|
+
}, null, 2),
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const result = await apiRequest('POST', '/api/v2/x402/client-request', {
|
|
148
|
+
url,
|
|
149
|
+
method,
|
|
150
|
+
body: body || undefined,
|
|
151
|
+
max_cost: max_cost || undefined,
|
|
152
|
+
dry_run,
|
|
153
|
+
preferred_network: preferred_network || undefined,
|
|
154
|
+
wallet_id: config.walletId,
|
|
155
|
+
agent_id: config.agentId,
|
|
156
|
+
});
|
|
157
|
+
return {
|
|
158
|
+
content: [
|
|
159
|
+
{
|
|
160
|
+
type: 'text',
|
|
161
|
+
text: JSON.stringify({
|
|
162
|
+
success: true,
|
|
163
|
+
...result,
|
|
164
|
+
message: result.payment?.dry_run
|
|
165
|
+
? `Dry run: accessing ${url} would cost ${result.cost}`
|
|
166
|
+
: `Paid ${result.cost} to access ${url}`,
|
|
167
|
+
}, null, 2),
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
const msg = error instanceof Error ? error.message : 'x402 payment failed';
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: 'text',
|
|
178
|
+
text: JSON.stringify({ success: false, error: msg, url }, null, 2),
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
isError: true,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
sardis_x402_preview_cost: async (args) => {
|
|
186
|
+
const parsed = X402PreviewSchema.safeParse(args);
|
|
187
|
+
if (!parsed.success) {
|
|
188
|
+
return {
|
|
189
|
+
content: [{ type: 'text', text: `Invalid request: ${parsed.error.message}` }],
|
|
190
|
+
isError: true,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const { url } = parsed.data;
|
|
194
|
+
const config = getConfig();
|
|
195
|
+
if (!config.apiKey || config.mode === 'simulated') {
|
|
196
|
+
return {
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
type: 'text',
|
|
200
|
+
text: JSON.stringify({
|
|
201
|
+
url,
|
|
202
|
+
amount: '1000000',
|
|
203
|
+
currency: 'USDC',
|
|
204
|
+
network: config.chain,
|
|
205
|
+
policy_check: true,
|
|
206
|
+
estimated_total_cost: '$1.00 USDC',
|
|
207
|
+
failure_reasons: [],
|
|
208
|
+
message: `Endpoint ${url} requires ~$1.00 USDC per request (simulated)`,
|
|
209
|
+
}, null, 2),
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
try {
|
|
215
|
+
const preview = await apiRequest('POST', '/api/v2/x402/dry-run', {
|
|
216
|
+
url,
|
|
217
|
+
wallet_id: config.walletId,
|
|
218
|
+
agent_id: config.agentId,
|
|
219
|
+
});
|
|
220
|
+
return {
|
|
221
|
+
content: [
|
|
222
|
+
{
|
|
223
|
+
type: 'text',
|
|
224
|
+
text: JSON.stringify({
|
|
225
|
+
...preview,
|
|
226
|
+
message: preview.policy_check
|
|
227
|
+
? `Endpoint requires ${preview.estimated_total_cost} — policy allows`
|
|
228
|
+
: `Endpoint requires ${preview.estimated_total_cost} — BLOCKED: ${preview.failure_reasons.join(', ')}`,
|
|
229
|
+
}, null, 2),
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
return {
|
|
236
|
+
content: [
|
|
237
|
+
{
|
|
238
|
+
type: 'text',
|
|
239
|
+
text: `Failed to preview cost: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
isError: true,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
sardis_x402_list_payments: async (args) => {
|
|
247
|
+
const parsed = X402ListPaymentsSchema.safeParse(args);
|
|
248
|
+
const { limit, offset, status } = parsed.success
|
|
249
|
+
? parsed.data
|
|
250
|
+
: { limit: 20, offset: 0, status: undefined };
|
|
251
|
+
const config = getConfig();
|
|
252
|
+
if (!config.apiKey || config.mode === 'simulated') {
|
|
253
|
+
const simTime = new Date().toISOString();
|
|
254
|
+
return {
|
|
255
|
+
content: [
|
|
256
|
+
{
|
|
257
|
+
type: 'text',
|
|
258
|
+
text: JSON.stringify([
|
|
259
|
+
{
|
|
260
|
+
payment_id: `x402_sim_${Date.now().toString(36)}`,
|
|
261
|
+
status: 'settled',
|
|
262
|
+
amount: '1000000',
|
|
263
|
+
currency: 'USDC',
|
|
264
|
+
network: config.chain,
|
|
265
|
+
tx_hash: '0x' + '1'.repeat(64),
|
|
266
|
+
source: 'client',
|
|
267
|
+
created_at: simTime,
|
|
268
|
+
},
|
|
269
|
+
], null, 2),
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const params = new URLSearchParams({
|
|
276
|
+
limit: limit.toString(),
|
|
277
|
+
offset: offset.toString(),
|
|
278
|
+
});
|
|
279
|
+
if (status)
|
|
280
|
+
params.append('status', status);
|
|
281
|
+
const payments = await apiRequest('GET', `/api/v2/x402/settlements?${params}`);
|
|
282
|
+
return {
|
|
283
|
+
content: [{ type: 'text', text: JSON.stringify(payments, null, 2) }],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
return {
|
|
288
|
+
content: [
|
|
289
|
+
{
|
|
290
|
+
type: 'text',
|
|
291
|
+
text: `Failed to list x402 payments: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
isError: true,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=x402.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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E;aAC1B,CAAC,CAAC;YACH,IAAI,MAAM;gBAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAE5C,MAAM,QAAQ,GAAG,MAAM,UAAU,CAC/B,KAAK,EACL,4BAA4B,MAAM,EAAE,CACrC,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACrE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,iCAAiC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;qBAClG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sardis/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for Sardis - Enable AI agents (Claude, Cursor, etc.) to execute secure payments with policy validation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
"mcp.json",
|
|
29
29
|
"CLAUDE_DESKTOP_CONFIG.md"
|
|
30
30
|
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"start": "node dist/cli.js",
|
|
34
|
+
"dev": "tsx src/cli.ts",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"prepublishOnly": "npm run clean && npm run build && npm run test"
|
|
40
|
+
},
|
|
31
41
|
"keywords": [
|
|
32
42
|
"sardis",
|
|
33
43
|
"mcp",
|
|
@@ -64,7 +74,7 @@
|
|
|
64
74
|
"@types/node": "^20.14.0",
|
|
65
75
|
"tsx": "^4.19.0",
|
|
66
76
|
"typescript": "^5.5.0",
|
|
67
|
-
"vitest": "^1.
|
|
77
|
+
"vitest": "^4.1.1"
|
|
68
78
|
},
|
|
69
79
|
"peerDependencies": {
|
|
70
80
|
"typescript": ">=4.7.0"
|
|
@@ -143,14 +153,5 @@
|
|
|
143
153
|
"transport": "stdio",
|
|
144
154
|
"category": "finance",
|
|
145
155
|
"icon": "wallet"
|
|
146
|
-
},
|
|
147
|
-
"scripts": {
|
|
148
|
-
"build": "tsc",
|
|
149
|
-
"start": "node dist/cli.js",
|
|
150
|
-
"dev": "tsx src/cli.ts",
|
|
151
|
-
"test": "vitest run",
|
|
152
|
-
"test:watch": "vitest",
|
|
153
|
-
"typecheck": "tsc --noEmit",
|
|
154
|
-
"clean": "rm -rf dist"
|
|
155
156
|
}
|
|
156
|
-
}
|
|
157
|
+
}
|