@attesso/mcp 1.0.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/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # @attesso/mcp
2
+
3
+ MCP (Model Context Protocol) server for Attesso agent payments. Exposes payment tools for AI assistants like Claude Desktop.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @attesso/mcp
9
+ ```
10
+
11
+ ## Claude Desktop Setup
12
+
13
+ Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
14
+
15
+ ```json
16
+ {
17
+ "mcpServers": {
18
+ "attesso": {
19
+ "command": "npx",
20
+ "args": ["@attesso/mcp"],
21
+ "env": {
22
+ "ATTESSO_API_KEY": "sk_bot_..."
23
+ }
24
+ }
25
+ }
26
+ }
27
+ ```
28
+
29
+ Restart Claude Desktop after updating the configuration.
30
+
31
+ ## Available Tools
32
+
33
+ ### Read Operations
34
+
35
+ | Tool | Description |
36
+ |------|-------------|
37
+ | `attesso_get_mandate` | Get mandate details (status, limits, restrictions) |
38
+ | `attesso_get_balance` | Quick balance check - available amount and status |
39
+ | `attesso_get_payment` | Check payment status and details |
40
+ | `attesso_get_passport` | Get passport token for merchant authentication |
41
+
42
+ ### Write Operations
43
+
44
+ | Tool | Description |
45
+ |------|-------------|
46
+ | `attesso_execute_payment` | Execute a payment against a mandate |
47
+ | `attesso_capture` | Capture an authorized payment with final amount |
48
+ | `attesso_cancel` | Cancel authorization and release held funds |
49
+
50
+ ## Environment Variables
51
+
52
+ | Variable | Description | Required |
53
+ |----------|-------------|----------|
54
+ | `ATTESSO_API_KEY` | Bot API key (`sk_bot_*` or `sk_test_*`) | Yes |
55
+ | `ATTESSO_BASE_URL` | Custom API URL | No |
56
+ | `ATTESSO_MANDATE_ID` | Default mandate ID for all operations | No |
57
+ | `ATTESSO_READ_ONLY` | Set to `"true"` to disable write operations | No |
58
+
59
+ ## Programmatic Usage
60
+
61
+ ```typescript
62
+ import { createAttessoMCPServer } from '@attesso/mcp';
63
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
64
+
65
+ const server = createAttessoMCPServer({
66
+ apiKey: process.env.ATTESSO_API_KEY,
67
+ mandateId: 'mandate_xyz', // Optional: pre-configure mandate
68
+ readOnlyMode: false, // Optional: disable write operations
69
+ });
70
+
71
+ const transport = new StdioServerTransport();
72
+ await server.connect(transport);
73
+ ```
74
+
75
+ ## Security Notes
76
+
77
+ 1. **API Keys**: Only use bot keys (`sk_bot_*`) or test keys (`sk_test_*`) with MCP. Never use user or management keys.
78
+
79
+ 2. **Mandate Creation**: Mandates require user biometric authentication (FaceID/TouchID) and cannot be created via MCP. The user must pre-authorize a mandate before the AI assistant can use it.
80
+
81
+ 3. **Read-Only Mode**: For monitoring dashboards or status checks, enable read-only mode to prevent accidental payments:
82
+ ```json
83
+ {
84
+ "env": {
85
+ "ATTESSO_API_KEY": "sk_bot_...",
86
+ "ATTESSO_READ_ONLY": "true"
87
+ }
88
+ }
89
+ ```
90
+
91
+ 4. **Idempotency**: Payment operations automatically generate idempotency keys for safe retries.
92
+
93
+ ## Example Conversation
94
+
95
+ **User**: What's my balance on mandate_abc123?
96
+
97
+ **Claude** (calls `attesso_get_balance`):
98
+ ```json
99
+ {
100
+ "available": 50000,
101
+ "currency": "USD",
102
+ "status": "active"
103
+ }
104
+ ```
105
+
106
+ **Claude**: You have $500.00 available on that mandate.
107
+
108
+ ---
109
+
110
+ **User**: Book me a flight to NYC for $347
111
+
112
+ **Claude** (calls `attesso_execute_payment`):
113
+ ```json
114
+ {
115
+ "id": "pay_xyz789",
116
+ "mandateId": "mandate_abc123",
117
+ "amount": 34700,
118
+ "merchant": "United Airlines",
119
+ "status": "completed"
120
+ }
121
+ ```
122
+
123
+ **Claude**: Done! I've charged $347.00 to United Airlines. Payment ID: pay_xyz789.
124
+
125
+ ## Related Packages
126
+
127
+ - [`@attesso/sdk`](https://www.npmjs.com/package/@attesso/sdk) - API client with Vercel AI SDK integration
128
+ - [`@attesso/types`](https://www.npmjs.com/package/@attesso/types) - TypeScript types
129
+
130
+ ## Documentation
131
+
132
+ Full documentation: https://www.attesso.com/docs
133
+
134
+ ## License
135
+
136
+ MIT
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point for Attesso MCP Server
4
+ *
5
+ * Run with: npx @attesso/mcp
6
+ *
7
+ * Configuration via environment variables:
8
+ * - ATTESSO_API_KEY: Your Attesso bot API key (sk_bot_*)
9
+ * - ATTESSO_BASE_URL: Optional custom API URL
10
+ * - ATTESSO_MANDATE_ID: Optional default mandate ID
11
+ * - ATTESSO_READ_ONLY: Set to "true" for read-only mode
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=attesso-mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attesso-mcp.d.ts","sourceRoot":"","sources":["../../bin/attesso-mcp.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG"}
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry point for Attesso MCP Server
4
+ *
5
+ * Run with: npx @attesso/mcp
6
+ *
7
+ * Configuration via environment variables:
8
+ * - ATTESSO_API_KEY: Your Attesso bot API key (sk_bot_*)
9
+ * - ATTESSO_BASE_URL: Optional custom API URL
10
+ * - ATTESSO_MANDATE_ID: Optional default mandate ID
11
+ * - ATTESSO_READ_ONLY: Set to "true" for read-only mode
12
+ */
13
+ import { createAttessoMCPServer } from '../src/index.js';
14
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
15
+ async function main() {
16
+ const config = {
17
+ apiKey: process.env.ATTESSO_API_KEY,
18
+ baseUrl: process.env.ATTESSO_BASE_URL,
19
+ mandateId: process.env.ATTESSO_MANDATE_ID,
20
+ readOnlyMode: process.env.ATTESSO_READ_ONLY === 'true',
21
+ };
22
+ const server = createAttessoMCPServer(config);
23
+ const transport = new StdioServerTransport();
24
+ await server.connect(transport);
25
+ // Handle graceful shutdown
26
+ process.on('SIGINT', async () => {
27
+ await server.close();
28
+ process.exit(0);
29
+ });
30
+ process.on('SIGTERM', async () => {
31
+ await server.close();
32
+ process.exit(0);
33
+ });
34
+ }
35
+ main().catch((error) => {
36
+ console.error('Failed to start Attesso MCP server:', error);
37
+ process.exit(1);
38
+ });
39
+ //# sourceMappingURL=attesso-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attesso-mcp.js","sourceRoot":"","sources":["../../bin/attesso-mcp.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG;QACb,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe;QACnC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QACrC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;QACzC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,MAAM;KACvD,CAAC;IAEF,MAAM,MAAM,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @attesso/mcp - MCP Server for Attesso Agent Payments
3
+ *
4
+ * Exposes Attesso payment tools via the Model Context Protocol (MCP),
5
+ * enabling AI assistants like Claude Desktop to execute payments
6
+ * within user-authorized mandates.
7
+ *
8
+ * @example Claude Desktop configuration (claude_desktop_config.json)
9
+ * ```json
10
+ * {
11
+ * "mcpServers": {
12
+ * "attesso": {
13
+ * "command": "npx",
14
+ * "args": ["@attesso/mcp"],
15
+ * "env": {
16
+ * "ATTESSO_API_KEY": "sk_bot_..."
17
+ * }
18
+ * }
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @example Programmatic usage
24
+ * ```typescript
25
+ * import { createAttessoMCPServer } from '@attesso/mcp';
26
+ * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
27
+ *
28
+ * const server = createAttessoMCPServer({
29
+ * mandateId: 'mandate_xyz', // Optional: pre-configure mandate
30
+ * readOnlyMode: false, // Optional: disable write operations
31
+ * });
32
+ *
33
+ * const transport = new StdioServerTransport();
34
+ * await server.connect(transport);
35
+ * ```
36
+ *
37
+ * @packageDocumentation
38
+ */
39
+ export { createAttessoMCPServer } from './server.js';
40
+ export type { AttessoMCPServerConfig } from './server.js';
41
+ export { schemas } from './schemas.js';
42
+ export { toolDefinitions, getToolByName, getReadOnlyTools, getAllTools } from './tools.js';
43
+ export type { ToolDefinition } from './tools.js';
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3F,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @attesso/mcp - MCP Server for Attesso Agent Payments
3
+ *
4
+ * Exposes Attesso payment tools via the Model Context Protocol (MCP),
5
+ * enabling AI assistants like Claude Desktop to execute payments
6
+ * within user-authorized mandates.
7
+ *
8
+ * @example Claude Desktop configuration (claude_desktop_config.json)
9
+ * ```json
10
+ * {
11
+ * "mcpServers": {
12
+ * "attesso": {
13
+ * "command": "npx",
14
+ * "args": ["@attesso/mcp"],
15
+ * "env": {
16
+ * "ATTESSO_API_KEY": "sk_bot_..."
17
+ * }
18
+ * }
19
+ * }
20
+ * }
21
+ * ```
22
+ *
23
+ * @example Programmatic usage
24
+ * ```typescript
25
+ * import { createAttessoMCPServer } from '@attesso/mcp';
26
+ * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
27
+ *
28
+ * const server = createAttessoMCPServer({
29
+ * mandateId: 'mandate_xyz', // Optional: pre-configure mandate
30
+ * readOnlyMode: false, // Optional: disable write operations
31
+ * });
32
+ *
33
+ * const transport = new StdioServerTransport();
34
+ * await server.connect(transport);
35
+ * ```
36
+ *
37
+ * @packageDocumentation
38
+ */
39
+ export { createAttessoMCPServer } from './server.js';
40
+ export { schemas } from './schemas.js';
41
+ export { toolDefinitions, getToolByName, getReadOnlyTools, getAllTools } from './tools.js';
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Zod schemas for MCP tool inputs.
3
+ * These define the parameters each tool accepts.
4
+ */
5
+ import { z } from 'zod';
6
+ export declare const schemas: {
7
+ getMandate: z.ZodObject<{
8
+ mandateId: z.ZodString;
9
+ }, "strip", z.ZodTypeAny, {
10
+ mandateId: string;
11
+ }, {
12
+ mandateId: string;
13
+ }>;
14
+ executePayment: z.ZodObject<{
15
+ mandateId: z.ZodString;
16
+ amount: z.ZodNumber;
17
+ merchant: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
19
+ mandateId: string;
20
+ amount: number;
21
+ merchant: string;
22
+ }, {
23
+ mandateId: string;
24
+ amount: number;
25
+ merchant: string;
26
+ }>;
27
+ getPayment: z.ZodObject<{
28
+ paymentId: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ paymentId: string;
31
+ }, {
32
+ paymentId: string;
33
+ }>;
34
+ getPassport: z.ZodObject<{
35
+ mandateId: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ mandateId: string;
38
+ }, {
39
+ mandateId: string;
40
+ }>;
41
+ capture: z.ZodObject<{
42
+ paymentId: z.ZodString;
43
+ amount: z.ZodNumber;
44
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
45
+ }, "strip", z.ZodTypeAny, {
46
+ amount: number;
47
+ paymentId: string;
48
+ metadata?: Record<string, string> | undefined;
49
+ }, {
50
+ amount: number;
51
+ paymentId: string;
52
+ metadata?: Record<string, string> | undefined;
53
+ }>;
54
+ cancel: z.ZodObject<{
55
+ paymentId: z.ZodString;
56
+ }, "strip", z.ZodTypeAny, {
57
+ paymentId: string;
58
+ }, {
59
+ paymentId: string;
60
+ }>;
61
+ checkBalance: z.ZodObject<{
62
+ mandateId: z.ZodString;
63
+ }, "strip", z.ZodTypeAny, {
64
+ mandateId: string;
65
+ }, {
66
+ mandateId: string;
67
+ }>;
68
+ };
69
+ export type GetMandateInput = z.infer<typeof schemas.getMandate>;
70
+ export type ExecutePaymentInput = z.infer<typeof schemas.executePayment>;
71
+ export type GetPaymentInput = z.infer<typeof schemas.getPayment>;
72
+ export type GetPassportInput = z.infer<typeof schemas.getPassport>;
73
+ export type CaptureInput = z.infer<typeof schemas.capture>;
74
+ export type CancelInput = z.infer<typeof schemas.cancel>;
75
+ export type CheckBalanceInput = z.infer<typeof schemas.checkBalance>;
76
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AACjE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,cAAc,CAAC,CAAC;AACzE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AACjE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Zod schemas for MCP tool inputs.
3
+ * These define the parameters each tool accepts.
4
+ */
5
+ import { z } from 'zod';
6
+ export const schemas = {
7
+ getMandate: z.object({
8
+ mandateId: z.string().describe('The unique identifier of the mandate to retrieve'),
9
+ }),
10
+ executePayment: z.object({
11
+ mandateId: z.string().describe('The mandate ID authorizing this payment'),
12
+ amount: z.number().positive().describe('Amount to charge in cents (e.g., 34700 for $347.00)'),
13
+ merchant: z.string().describe('Name of the merchant receiving payment'),
14
+ }),
15
+ getPayment: z.object({
16
+ paymentId: z.string().describe('The unique identifier of the payment to retrieve'),
17
+ }),
18
+ getPassport: z.object({
19
+ mandateId: z.string().describe('The mandate ID to generate a passport for'),
20
+ }),
21
+ capture: z.object({
22
+ paymentId: z.string().describe('The payment ID to capture'),
23
+ amount: z.number().positive().describe('Final amount to capture in cents (must be <= authorized amount)'),
24
+ metadata: z.record(z.string()).optional().describe('Optional metadata to attach to the capture'),
25
+ }),
26
+ cancel: z.object({
27
+ paymentId: z.string().describe('The payment ID to cancel and release funds'),
28
+ }),
29
+ checkBalance: z.object({
30
+ mandateId: z.string().describe('The mandate ID to check remaining balance for'),
31
+ }),
32
+ };
33
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,U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AC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;KAChF,CAAC;CACH,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * MCP Server Factory for Attesso
3
+ *
4
+ * Creates an MCP server that exposes Attesso payment tools.
5
+ * Used by Claude Desktop and other MCP-compatible AI assistants.
6
+ */
7
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
8
+ export interface AttessoMCPServerConfig {
9
+ /**
10
+ * Attesso API key. Falls back to ATTESSO_API_KEY env var.
11
+ * Only accepts bot keys (sk_bot_*) for security.
12
+ */
13
+ apiKey?: string;
14
+ /**
15
+ * Base URL for the Attesso API.
16
+ * @default "https://api.attesso.com"
17
+ */
18
+ baseUrl?: string;
19
+ /**
20
+ * If provided, use this mandate ID for all operations.
21
+ * Useful for pre-configured agents with a known mandate.
22
+ */
23
+ mandateId?: string;
24
+ /**
25
+ * If true, only expose read-only tools (get_mandate, get_balance, get_payment, get_passport).
26
+ * Write operations (execute_payment, capture, cancel) will not be available.
27
+ * @default false
28
+ */
29
+ readOnlyMode?: boolean;
30
+ }
31
+ /**
32
+ * Creates an Attesso MCP server with the specified configuration.
33
+ *
34
+ * @example Basic usage with Claude Desktop
35
+ * ```typescript
36
+ * import { createAttessoMCPServer } from '@attesso/mcp';
37
+ * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
38
+ *
39
+ * const server = createAttessoMCPServer();
40
+ * const transport = new StdioServerTransport();
41
+ * await server.connect(transport);
42
+ * ```
43
+ *
44
+ * @example With configuration
45
+ * ```typescript
46
+ * const server = createAttessoMCPServer({
47
+ * mandateId: 'mandate_xyz',
48
+ * readOnlyMode: true,
49
+ * });
50
+ * ```
51
+ */
52
+ export declare function createAttessoMCPServer(config?: AttessoMCPServerConfig): Server;
53
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAwBnE,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,GAAE,sBAA2B,GAAG,MAAM,CAmIlF"}
@@ -0,0 +1,201 @@
1
+ /**
2
+ * MCP Server Factory for Attesso
3
+ *
4
+ * Creates an MCP server that exposes Attesso payment tools.
5
+ * Used by Claude Desktop and other MCP-compatible AI assistants.
6
+ */
7
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
8
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
9
+ import { AttessoClient, AttessoError } from '@attesso/sdk';
10
+ import { randomUUID } from 'crypto';
11
+ import { getToolByName, getReadOnlyTools, getAllTools, } from './tools.js';
12
+ /**
13
+ * Creates an Attesso MCP server with the specified configuration.
14
+ *
15
+ * @example Basic usage with Claude Desktop
16
+ * ```typescript
17
+ * import { createAttessoMCPServer } from '@attesso/mcp';
18
+ * import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
19
+ *
20
+ * const server = createAttessoMCPServer();
21
+ * const transport = new StdioServerTransport();
22
+ * await server.connect(transport);
23
+ * ```
24
+ *
25
+ * @example With configuration
26
+ * ```typescript
27
+ * const server = createAttessoMCPServer({
28
+ * mandateId: 'mandate_xyz',
29
+ * readOnlyMode: true,
30
+ * });
31
+ * ```
32
+ */
33
+ export function createAttessoMCPServer(config = {}) {
34
+ const apiKey = config.apiKey ?? process.env.ATTESSO_API_KEY;
35
+ // Validate API key format (only bot keys allowed)
36
+ if (apiKey && !apiKey.startsWith('sk_bot_') && !apiKey.startsWith('sk_test_')) {
37
+ console.error('Warning: Attesso MCP server should use bot keys (sk_bot_*) or test keys (sk_test_*)');
38
+ }
39
+ const client = new AttessoClient({
40
+ apiKey,
41
+ baseUrl: config.baseUrl,
42
+ });
43
+ const defaultMandateId = config.mandateId;
44
+ const readOnlyMode = config.readOnlyMode ?? false;
45
+ // Get tools based on mode
46
+ const availableTools = readOnlyMode ? getReadOnlyTools() : getAllTools();
47
+ const server = new Server({
48
+ name: 'attesso',
49
+ version: '1.0.0',
50
+ }, {
51
+ capabilities: {
52
+ tools: {},
53
+ },
54
+ });
55
+ // Handle list_tools request
56
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
57
+ const tools = availableTools.map((tool) => ({
58
+ name: tool.name,
59
+ description: tool.description,
60
+ inputSchema: tool.inputSchema,
61
+ }));
62
+ return { tools };
63
+ });
64
+ // Handle call_tool request
65
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
66
+ const { name, arguments: args } = request.params;
67
+ const toolDef = getToolByName(name);
68
+ if (!toolDef) {
69
+ return {
70
+ content: [
71
+ {
72
+ type: 'text',
73
+ text: JSON.stringify({ error: `Unknown tool: ${name}` }),
74
+ },
75
+ ],
76
+ isError: true,
77
+ };
78
+ }
79
+ // Check read-only mode
80
+ if (readOnlyMode && toolDef.isWriteOperation) {
81
+ return {
82
+ content: [
83
+ {
84
+ type: 'text',
85
+ text: JSON.stringify({
86
+ error: 'Write operations are disabled in read-only mode',
87
+ tool: name,
88
+ }),
89
+ },
90
+ ],
91
+ isError: true,
92
+ };
93
+ }
94
+ // Validate input
95
+ const parseResult = toolDef.zodSchema.safeParse(args);
96
+ if (!parseResult.success) {
97
+ return {
98
+ content: [
99
+ {
100
+ type: 'text',
101
+ text: JSON.stringify({
102
+ error: 'Invalid input',
103
+ details: parseResult.error.format(),
104
+ }),
105
+ },
106
+ ],
107
+ isError: true,
108
+ };
109
+ }
110
+ try {
111
+ const result = await executeToolCall(client, name, parseResult.data, defaultMandateId);
112
+ return {
113
+ content: [
114
+ {
115
+ type: 'text',
116
+ text: JSON.stringify(result, null, 2),
117
+ },
118
+ ],
119
+ };
120
+ }
121
+ catch (error) {
122
+ const errorMessage = error instanceof AttessoError
123
+ ? { code: error.code, message: error.message }
124
+ : error instanceof Error
125
+ ? { error: error.message }
126
+ : { error: 'Unknown error' };
127
+ return {
128
+ content: [
129
+ {
130
+ type: 'text',
131
+ text: JSON.stringify(errorMessage),
132
+ },
133
+ ],
134
+ isError: true,
135
+ };
136
+ }
137
+ });
138
+ return server;
139
+ }
140
+ /**
141
+ * Execute a tool call against the Attesso API.
142
+ */
143
+ async function executeToolCall(client, toolName, input, defaultMandateId) {
144
+ switch (toolName) {
145
+ case 'attesso_get_mandate': {
146
+ const { mandateId } = input;
147
+ const id = mandateId ?? defaultMandateId;
148
+ if (!id) {
149
+ throw new AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
150
+ }
151
+ return client.getMandate(id);
152
+ }
153
+ case 'attesso_get_balance': {
154
+ const { mandateId } = input;
155
+ const id = mandateId ?? defaultMandateId;
156
+ if (!id) {
157
+ throw new AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
158
+ }
159
+ const mandate = await client.getMandate(id);
160
+ return {
161
+ available: mandate.maxAmount,
162
+ currency: mandate.currency,
163
+ status: mandate.status,
164
+ };
165
+ }
166
+ case 'attesso_get_payment': {
167
+ const { paymentId } = input;
168
+ return client.getPayment(paymentId);
169
+ }
170
+ case 'attesso_get_passport': {
171
+ const { mandateId } = input;
172
+ const id = mandateId ?? defaultMandateId;
173
+ if (!id) {
174
+ throw new AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
175
+ }
176
+ return client.getPassport(id);
177
+ }
178
+ case 'attesso_execute_payment': {
179
+ const { mandateId, amount, merchant } = input;
180
+ const id = mandateId ?? defaultMandateId;
181
+ if (!id) {
182
+ throw new AttessoError('MANDATE_NOT_FOUND', 'mandateId is required');
183
+ }
184
+ // Generate idempotency key for safe retries
185
+ const idempotencyKey = `mcp_${randomUUID()}`;
186
+ // Note: idempotency key would be passed as header in production
187
+ return client.executePayment({ mandateId: id, amount, merchant });
188
+ }
189
+ case 'attesso_capture': {
190
+ const { paymentId, amount, metadata } = input;
191
+ return client.capture(paymentId, { amount, metadata });
192
+ }
193
+ case 'attesso_cancel': {
194
+ const { paymentId } = input;
195
+ return client.cancel(paymentId);
196
+ }
197
+ default:
198
+ throw new Error(`Unknown tool: ${toolName}`);
199
+ }
200
+ }
201
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAEL,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,YAAY,CAAC;AAsCpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAiC,EAAE;IACxE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAE5D,kDAAkD;IAClD,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9E,OAAO,CAAC,KAAK,CACX,qFAAqF,CACtF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC/B,MAAM;QACN,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC,CA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AAS,EAAE,GAAG,KAAoB,CAAC;YAC3C,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MCP Tool Definitions for Attesso
3
+ *
4
+ * Defines the 7 tools exposed via MCP:
5
+ * - attesso_get_mandate (read)
6
+ * - attesso_get_balance (read)
7
+ * - attesso_get_payment (read)
8
+ * - attesso_get_passport (read)
9
+ * - attesso_execute_payment (write)
10
+ * - attesso_capture (write)
11
+ * - attesso_cancel (write)
12
+ */
13
+ import { z } from 'zod';
14
+ import { zodToJsonSchema } from 'zod-to-json-schema';
15
+ export interface ToolDefinition {
16
+ name: string;
17
+ description: string;
18
+ inputSchema: ReturnType<typeof zodToJsonSchema>;
19
+ zodSchema: z.ZodType;
20
+ isWriteOperation: boolean;
21
+ }
22
+ export declare const toolDefinitions: ToolDefinition[];
23
+ export declare function getToolByName(name: string): ToolDefinition | undefined;
24
+ export declare function getReadOnlyTools(): ToolDefinition[];
25
+ export declare function getAllTools(): ToolDefinition[];
26
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IAChD,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,eAAO,MAAM,eAAe,EAAE,cAAc,EAwE3C,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEtE;AAED,wBAAgB,gBAAgB,IAAI,cAAc,EAAE,CAEnD;AAED,wBAAgB,WAAW,IAAI,cAAc,EAAE,CAE9C"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * MCP Tool Definitions for Attesso
3
+ *
4
+ * Defines the 7 tools exposed via MCP:
5
+ * - attesso_get_mandate (read)
6
+ * - attesso_get_balance (read)
7
+ * - attesso_get_payment (read)
8
+ * - attesso_get_passport (read)
9
+ * - attesso_execute_payment (write)
10
+ * - attesso_capture (write)
11
+ * - attesso_cancel (write)
12
+ */
13
+ import { zodToJsonSchema } from 'zod-to-json-schema';
14
+ import { schemas } from './schemas.js';
15
+ export const toolDefinitions = [
16
+ // Read operations
17
+ {
18
+ name: 'attesso_get_mandate',
19
+ description: 'Get details about a spending mandate including the maximum amount, status, and restrictions. ' +
20
+ 'Use this to check how much money is available before making a purchase.',
21
+ inputSchema: zodToJsonSchema(schemas.getMandate, 'GetMandateInput'),
22
+ zodSchema: schemas.getMandate,
23
+ isWriteOperation: false,
24
+ },
25
+ {
26
+ name: 'attesso_get_balance',
27
+ description: 'Quickly check how much money is available to spend on a mandate. ' +
28
+ 'Returns the maximum amount and current status.',
29
+ inputSchema: zodToJsonSchema(schemas.checkBalance, 'CheckBalanceInput'),
30
+ zodSchema: schemas.checkBalance,
31
+ isWriteOperation: false,
32
+ },
33
+ {
34
+ name: 'attesso_get_payment',
35
+ description: 'Get the status and details of a specific payment. ' +
36
+ 'Use this to verify a payment was successful or check its current status.',
37
+ inputSchema: zodToJsonSchema(schemas.getPayment, 'GetPaymentInput'),
38
+ zodSchema: schemas.getPayment,
39
+ isWriteOperation: false,
40
+ },
41
+ {
42
+ name: 'attesso_get_passport',
43
+ description: 'Get a passport token that proves authorized spending power to merchants. ' +
44
+ 'Some merchants require this for fast-lane checkout without additional verification. ' +
45
+ 'The passport includes solvency proof and reputation data.',
46
+ inputSchema: zodToJsonSchema(schemas.getPassport, 'GetPassportInput'),
47
+ zodSchema: schemas.getPassport,
48
+ isWriteOperation: false,
49
+ },
50
+ // Write operations
51
+ {
52
+ name: 'attesso_execute_payment',
53
+ description: "Execute a payment to purchase something. The payment will be charged against the user's pre-authorized mandate. " +
54
+ 'Amount must be in cents (e.g., 34700 for $347.00). ' +
55
+ 'Only call this after finding the best deal and confirming the price.',
56
+ inputSchema: zodToJsonSchema(schemas.executePayment, 'ExecutePaymentInput'),
57
+ zodSchema: schemas.executePayment,
58
+ isWriteOperation: true,
59
+ },
60
+ {
61
+ name: 'attesso_capture',
62
+ description: 'Capture a previously authorized payment with the final amount. ' +
63
+ 'Use this when the exact price is known (e.g., after finding the best flight). ' +
64
+ 'The capture amount must be less than or equal to the authorized amount. ' +
65
+ 'Any excess funds are automatically released.',
66
+ inputSchema: zodToJsonSchema(schemas.capture, 'CaptureInput'),
67
+ zodSchema: schemas.capture,
68
+ isWriteOperation: true,
69
+ },
70
+ {
71
+ name: 'attesso_cancel',
72
+ description: 'Cancel an authorization and release the held funds back to the user. ' +
73
+ "Use this when a purchase won't proceed (e.g., no suitable options found, user changed mind). " +
74
+ 'Always cancel unused authorizations promptly.',
75
+ inputSchema: zodToJsonSchema(schemas.cancel, 'CancelInput'),
76
+ zodSchema: schemas.cancel,
77
+ isWriteOperation: true,
78
+ },
79
+ ];
80
+ export function getToolByName(name) {
81
+ return toolDefinitions.find((t) => t.name === name);
82
+ }
83
+ export function getReadOnlyTools() {
84
+ return toolDefinitions.filter((t) => !t.isWriteOperation);
85
+ }
86
+ export function getAllTools() {
87
+ return toolDefinitions;
88
+ }
89
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC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ACvB,WAAW,EACT,iEAAiE;YACjE,gFAAgF;YAChF,0EAA0E;YAC1E,8CAA8C;QAChD,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC;QAC7D,SAAS,EAAE,OAAO,CAAC,OAAO;QAC1B,gBAAgB,EAAE,IAAI;KACvB;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uEAAuE;YACvE,+FAA+F;YAC/F,+CAA+C;QACjD,WAAW,EAAE,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC;QAC3D,SAAS,EAAE,OAAO,CAAC,MAAM;QACzB,gBAAgB,EAAE,IAAI;KACvB;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,eAAe,CAAC;AACzB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@attesso/mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Attesso agent payments. Exposes payment tools for AI assistants like Claude Desktop.",
5
+ "author": "Attesso",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/attesso/attesso"
10
+ },
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "type": "module",
15
+ "bin": {
16
+ "attesso-mcp": "./dist/bin/attesso-mcp.js"
17
+ },
18
+ "main": "./dist/src/index.js",
19
+ "types": "./dist/src/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/src/index.d.ts",
23
+ "import": "./dist/src/index.js",
24
+ "require": "./dist/src/index.js"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "dev": "tsc --watch",
37
+ "clean": "rm -rf dist",
38
+ "test": "vitest run"
39
+ },
40
+ "keywords": [
41
+ "attesso",
42
+ "mcp",
43
+ "model-context-protocol",
44
+ "ai-agents",
45
+ "payments",
46
+ "claude",
47
+ "llm"
48
+ ],
49
+ "dependencies": {
50
+ "@attesso/sdk": "workspace:*",
51
+ "@attesso/types": "workspace:*",
52
+ "@modelcontextprotocol/sdk": "^1.25.0",
53
+ "zod-to-json-schema": "^3.23.0"
54
+ },
55
+ "peerDependencies": {
56
+ "zod": ">=3.25.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "zod": {
60
+ "optional": false
61
+ }
62
+ },
63
+ "devDependencies": {
64
+ "typescript": "^5.7.0",
65
+ "vitest": "^2.1.0",
66
+ "zod": "^3.25.0"
67
+ }
68
+ }