@atxp/server 0.2.13 → 0.2.15
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 +2 -139
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,143 +6,6 @@ ATXP Server - MCP server implementation with payment processing capabilities.
|
|
|
6
6
|
|
|
7
7
|
The ATXP Server package provides middleware and utilities for creating MCP (Model Context Protocol) servers that require OAuth authentication and payment processing. It integrates seamlessly with Express.js applications to add payment requirements to any MCP tool.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Getting Started
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- 🔐 **OAuth Integration**: Complete OAuth 2.0 server middleware
|
|
14
|
-
- 💰 **Payment Validation**: Solana payment verification and processing
|
|
15
|
-
- 🛠️ **MCP Protocol**: Full Model Context Protocol server implementation
|
|
16
|
-
- 🚀 **Express Middleware**: Easy integration with existing Express applications
|
|
17
|
-
- 🔄 **Challenge System**: Automatic authentication challenges for unauthorized requests
|
|
18
|
-
- 📊 **Payment Tracking**: Built-in payment confirmation and tracking
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install @atxp/server
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Basic Usage
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
import express from 'express';
|
|
30
|
-
import { ATXPServer, requirePayment } from '@atxp/server';
|
|
31
|
-
|
|
32
|
-
const app = express();
|
|
33
|
-
const server = new ATXPServer({
|
|
34
|
-
clientId: 'your-oauth-client-id',
|
|
35
|
-
authServerUrl: 'https://auth.atxp.ai',
|
|
36
|
-
destinationAddress: 'your-solana-wallet-address'
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Add MCP tools with payment requirements
|
|
40
|
-
server.addTool({
|
|
41
|
-
name: 'hello_world',
|
|
42
|
-
description: 'A simple greeting tool',
|
|
43
|
-
inputSchema: {
|
|
44
|
-
type: 'object',
|
|
45
|
-
properties: {
|
|
46
|
-
name: { type: 'string' }
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}, requirePayment('0.01'), async ({ name }) => {
|
|
50
|
-
return `Hello, ${name || 'World'}!`;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// Mount server middleware
|
|
54
|
-
app.use('/', server.middleware());
|
|
55
|
-
app.listen(3010);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Authentication & Payment Flow
|
|
59
|
-
|
|
60
|
-
1. **Unauthenticated Request**: Client sends MCP request without auth token
|
|
61
|
-
2. **OAuth Challenge**: Server responds with OAuth challenge and redirect URL
|
|
62
|
-
3. **Client Authentication**: Client completes OAuth flow and obtains access token
|
|
63
|
-
4. **Authenticated Request**: Client retries request with valid access token
|
|
64
|
-
5. **Payment Required**: Server responds with payment requirement (amount, destination)
|
|
65
|
-
6. **Payment Processing**: Client makes Solana payment to specified address
|
|
66
|
-
7. **Payment Verification**: Server confirms payment on-chain
|
|
67
|
-
8. **Tool Execution**: Server executes requested tool and returns results
|
|
68
|
-
|
|
69
|
-
## API Reference
|
|
70
|
-
|
|
71
|
-
### ATXPServer
|
|
72
|
-
|
|
73
|
-
Main server class for handling ATXP protocol requests.
|
|
74
|
-
|
|
75
|
-
#### Constructor Options
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
interface ATXPServerConfig {
|
|
79
|
-
clientId: string; // OAuth client ID
|
|
80
|
-
authServerUrl?: string; // Auth server URL (defaults to https://auth.atxp.ai)
|
|
81
|
-
destinationAddress: string; // Solana wallet address for payments
|
|
82
|
-
oAuthDb?: OAuthDb; // Custom OAuth database implementation
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
#### Methods
|
|
87
|
-
|
|
88
|
-
- `addTool(definition, middleware, handler)`: Register MCP tool with payment requirements
|
|
89
|
-
- `middleware()`: Get Express middleware function
|
|
90
|
-
- `handleMCPRequest(req, res)`: Process MCP protocol requests
|
|
91
|
-
|
|
92
|
-
### requirePayment(amount)
|
|
93
|
-
|
|
94
|
-
Middleware function that adds payment requirements to tools.
|
|
95
|
-
|
|
96
|
-
```typescript
|
|
97
|
-
const paymentMiddleware = requirePayment('0.01'); // 0.01 SOL/USDC
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Payment Verification
|
|
101
|
-
|
|
102
|
-
The server automatically handles:
|
|
103
|
-
- On-chain payment confirmation
|
|
104
|
-
- Payment amount validation
|
|
105
|
-
- Duplicate payment prevention
|
|
106
|
-
- Transaction signature verification
|
|
107
|
-
|
|
108
|
-
## Tool Registration
|
|
109
|
-
|
|
110
|
-
Tools can be registered with various middleware combinations:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
// Free tool (no payment required)
|
|
114
|
-
server.addTool(toolDef, async (args) => {
|
|
115
|
-
return 'Free result';
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Paid tool with fixed amount
|
|
119
|
-
server.addTool(toolDef, requirePayment('0.01'), async (args) => {
|
|
120
|
-
return 'Paid result';
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
// Custom middleware chain
|
|
124
|
-
server.addTool(toolDef,
|
|
125
|
-
requirePayment('0.05'),
|
|
126
|
-
customValidation,
|
|
127
|
-
async (args) => {
|
|
128
|
-
return 'Premium result';
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Error Handling
|
|
134
|
-
|
|
135
|
-
The server provides structured error responses for:
|
|
136
|
-
- Authentication failures
|
|
137
|
-
- Payment requirement notifications
|
|
138
|
-
- Payment verification failures
|
|
139
|
-
- Tool execution errors
|
|
140
|
-
- Invalid MCP requests
|
|
141
|
-
|
|
142
|
-
## Examples
|
|
143
|
-
|
|
144
|
-
See the `examples/server/` directory for a complete working server implementation.
|
|
145
|
-
|
|
146
|
-
## License
|
|
147
|
-
|
|
148
|
-
MIT
|
|
11
|
+
Learn more about ATXP in [the docs](https://docs.atxp.ai/atxp), and follow the [MCP Server Quickstart](https://docs.atxp.ai/server) to build your first monetized MCP server using ATXP.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atxp/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "ATXP Server - MCP server implementation with payment processing capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "vitest run"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atxp/common": "0.2.
|
|
25
|
+
"@atxp/common": "0.2.15",
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
27
27
|
"@types/express": "^5.0.0",
|
|
28
28
|
"bignumber.js": "^9.3.0",
|