mcp-user-system 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 +122 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.js +17 -0
- package/dist/env.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +179 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/wallet.d.ts +54 -0
- package/dist/tools/wallet.js +55 -0
- package/dist/tools/wallet.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# mcp-user-system
|
|
2
|
+
|
|
3
|
+
[MCP](https://modelcontextprotocol.io) server for token-user-system — wallet operations via Model Context Protocol.
|
|
4
|
+
|
|
5
|
+
Supports: balance, consumption trend, transaction records, coupons, corporate transfer info.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Node.js >= 18
|
|
10
|
+
- `TUS_BASE_URL` and `TUS_ACCESS_TOKEN` environment variables
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
### 1. Clone & Build
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
git clone https://github.com/shenda-ai/mcp-user-system.git
|
|
18
|
+
cd mcp-user-system
|
|
19
|
+
npm install
|
|
20
|
+
npm run build
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### 2. Configure Environment
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
export TUS_BASE_URL=https://api.example.com
|
|
27
|
+
export TUS_ACCESS_TOKEN=eyJhbGciOiJIUzUxMiJ9...
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or create a `.env` file (add to `.gitignore`):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
TUS_BASE_URL=https://api.example.com
|
|
34
|
+
TUS_ACCESS_TOKEN=eyJhbGciOiJIUzUxMiJ9...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 3. Test Run
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm start
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## MCP Client Configuration
|
|
44
|
+
|
|
45
|
+
### Claude Desktop (macOS)
|
|
46
|
+
|
|
47
|
+
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"user-system": {
|
|
53
|
+
"command": "node",
|
|
54
|
+
"args": ["/path/to/mcp-user-system/dist/index.js"],
|
|
55
|
+
"env": {
|
|
56
|
+
"TUS_BASE_URL": "https://api.example.com",
|
|
57
|
+
"TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Cursor / VS Code
|
|
65
|
+
|
|
66
|
+
Add to settings (Cursor: `~/.cursor/mcp.json`, VS Code: settings.json):
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"user-system": {
|
|
72
|
+
"command": "node",
|
|
73
|
+
"args": ["/path/to/mcp-user-system/dist/index.js"],
|
|
74
|
+
"env": {
|
|
75
|
+
"TUS_BASE_URL": "https://api.example.com",
|
|
76
|
+
"TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Claude Code (CLI)
|
|
84
|
+
|
|
85
|
+
Add to `~/.claude/mcp.json`:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"mcpServers": {
|
|
90
|
+
"user-system": {
|
|
91
|
+
"command": "node",
|
|
92
|
+
"args": ["/path/to/mcp-user-system/dist/index.js"],
|
|
93
|
+
"env": {
|
|
94
|
+
"TUS_BASE_URL": "https://api.example.com",
|
|
95
|
+
"TUS_ACCESS_TOKEN": "eyJhbGciOiJIUzUxMiJ9..."
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Available Tools
|
|
103
|
+
|
|
104
|
+
| Tool | Description |
|
|
105
|
+
|------|-------------|
|
|
106
|
+
| `wallet_balance` | Get account wallet overview |
|
|
107
|
+
| `wallet_trend` | Get consumption trend (`days` param) |
|
|
108
|
+
| `wallet_transactions` | List transaction records (with filters) |
|
|
109
|
+
| `wallet_coupons` | List cash coupons |
|
|
110
|
+
| `wallet_corporate_info` | Get corporate transfer bank info |
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run dev # Watch mode
|
|
116
|
+
npm run build # Compile TypeScript
|
|
117
|
+
npm start # Run compiled server
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
package/dist/env.d.ts
ADDED
package/dist/env.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable loader for mcp-user-system.
|
|
3
|
+
*/
|
|
4
|
+
function requireEnv(name) {
|
|
5
|
+
const value = process.env[name];
|
|
6
|
+
if (!value) {
|
|
7
|
+
throw new Error(`Missing required environment variable: ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
export function loadConfig() {
|
|
12
|
+
return {
|
|
13
|
+
baseUrl: requireEnv("TUS_BASE_URL"),
|
|
14
|
+
accessToken: requireEnv("TUS_ACCESS_TOKEN"),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,cAAc,CAAC;QACnC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC;KAC5C,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server for token-user-system
|
|
4
|
+
*
|
|
5
|
+
* Provides wallet management tools via Model Context Protocol.
|
|
6
|
+
* Supports: balance, trend, transactions, coupons, corporate-info
|
|
7
|
+
*/
|
|
8
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
9
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
10
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
11
|
+
import { getBalance, getTrend, getTransactions, getCoupons, getCorporateInfo, } from "./tools/wallet.js";
|
|
12
|
+
// ── MCP Server Setup ──
|
|
13
|
+
const server = new Server({
|
|
14
|
+
name: "mcp-user-system",
|
|
15
|
+
version: "1.0.0",
|
|
16
|
+
}, {
|
|
17
|
+
capabilities: {
|
|
18
|
+
tools: {},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
// ── Tool Definitions ──
|
|
22
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
23
|
+
return {
|
|
24
|
+
tools: [
|
|
25
|
+
{
|
|
26
|
+
name: "wallet_balance",
|
|
27
|
+
description: "Get account wallet overview (balance, usable balance, voucher, credit limit, pending amount)",
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: "object",
|
|
30
|
+
properties: {},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "wallet_trend",
|
|
35
|
+
description: "Get consumption trend for a given number of days",
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
days: {
|
|
40
|
+
type: "number",
|
|
41
|
+
description: "Number of days to query (default: 30)",
|
|
42
|
+
default: 30,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "wallet_transactions",
|
|
49
|
+
description: "List wallet transaction records with optional filters",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: {
|
|
53
|
+
recordType: {
|
|
54
|
+
type: "string",
|
|
55
|
+
description: "Filter by record type",
|
|
56
|
+
},
|
|
57
|
+
startDate: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Start date (YYYY-MM-DD)",
|
|
60
|
+
},
|
|
61
|
+
endDate: {
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "End date (YYYY-MM-DD)",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "wallet_coupons",
|
|
70
|
+
description: "List my cash coupons",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "wallet_corporate_info",
|
|
78
|
+
description: "Get corporate transfer bank account info for recharge",
|
|
79
|
+
inputSchema: {
|
|
80
|
+
type: "object",
|
|
81
|
+
properties: {},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
// ── Tool Handlers ──
|
|
88
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
89
|
+
const { name, arguments: args } = request.params;
|
|
90
|
+
try {
|
|
91
|
+
switch (name) {
|
|
92
|
+
case "wallet_balance": {
|
|
93
|
+
const data = await getBalance();
|
|
94
|
+
return {
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: "text",
|
|
98
|
+
text: JSON.stringify(data, null, 2),
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
case "wallet_trend": {
|
|
104
|
+
const days = args?.days || 30;
|
|
105
|
+
const data = await getTrend(days);
|
|
106
|
+
return {
|
|
107
|
+
content: [
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
text: JSON.stringify(data, null, 2),
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
case "wallet_transactions": {
|
|
116
|
+
const data = await getTransactions({
|
|
117
|
+
recordType: args?.recordType || undefined,
|
|
118
|
+
startDate: args?.startDate || undefined,
|
|
119
|
+
endDate: args?.endDate || undefined,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: "text",
|
|
125
|
+
text: JSON.stringify(data, null, 2),
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
case "wallet_coupons": {
|
|
131
|
+
const data = await getCoupons();
|
|
132
|
+
return {
|
|
133
|
+
content: [
|
|
134
|
+
{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: JSON.stringify(data, null, 2),
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
case "wallet_corporate_info": {
|
|
142
|
+
const data = await getCorporateInfo();
|
|
143
|
+
return {
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: "text",
|
|
147
|
+
text: JSON.stringify(data, null, 2),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
default:
|
|
153
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
158
|
+
return {
|
|
159
|
+
content: [
|
|
160
|
+
{
|
|
161
|
+
type: "text",
|
|
162
|
+
text: `Error: ${message}`,
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
isError: true,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
// ── Start Server ──
|
|
170
|
+
async function main() {
|
|
171
|
+
const transport = new StdioServerTransport();
|
|
172
|
+
await server.connect(transport);
|
|
173
|
+
console.error("mcp-user-system server running on stdio");
|
|
174
|
+
}
|
|
175
|
+
main().catch((err) => {
|
|
176
|
+
console.error("Fatal error:", err);
|
|
177
|
+
process.exit(1);
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,QAAQ,EACR,eAAe,EACf,UAAU,EACV,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,yBAAyB;AAEzB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,OAAO;CACjB,EACD;IACE,YAAY,EAAE;Q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AC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet API client for token-user-system.
|
|
3
|
+
* Mirrors the front-end request.js interceptor logic.
|
|
4
|
+
*/
|
|
5
|
+
export interface BalanceVo {
|
|
6
|
+
balance?: number;
|
|
7
|
+
usableBalance?: number;
|
|
8
|
+
voucher?: number;
|
|
9
|
+
creditLimit?: number;
|
|
10
|
+
pendingAmount?: number;
|
|
11
|
+
pendingCount?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function getBalance(): Promise<BalanceVo>;
|
|
14
|
+
export interface TrendItem {
|
|
15
|
+
date: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function getTrend(days?: number): Promise<TrendItem[]>;
|
|
19
|
+
export interface TransactionRecord {
|
|
20
|
+
typeName?: string;
|
|
21
|
+
recordType?: string;
|
|
22
|
+
orderNo?: string;
|
|
23
|
+
eventTime?: string;
|
|
24
|
+
amount?: number;
|
|
25
|
+
status?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function getTransactions(params?: {
|
|
28
|
+
recordType?: string;
|
|
29
|
+
startDate?: string;
|
|
30
|
+
endDate?: string;
|
|
31
|
+
}): Promise<TransactionRecord[]>;
|
|
32
|
+
export interface CouponCount {
|
|
33
|
+
unredeemedCount?: number;
|
|
34
|
+
redeemedCount?: number;
|
|
35
|
+
voidedCount?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface Coupon {
|
|
38
|
+
couponCode?: string;
|
|
39
|
+
amount?: number;
|
|
40
|
+
status?: string;
|
|
41
|
+
expireDeadline?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface CouponVo {
|
|
44
|
+
count?: CouponCount;
|
|
45
|
+
coupons?: Coupon[];
|
|
46
|
+
}
|
|
47
|
+
export declare function getCoupons(): Promise<CouponVo>;
|
|
48
|
+
export interface CorporateInfo {
|
|
49
|
+
accountName?: string;
|
|
50
|
+
bankName?: string;
|
|
51
|
+
accountNo?: string;
|
|
52
|
+
bankCode?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function getCorporateInfo(): Promise<CorporateInfo>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet API client for token-user-system.
|
|
3
|
+
* Mirrors the front-end request.js interceptor logic.
|
|
4
|
+
*/
|
|
5
|
+
import { loadConfig } from "../env.js";
|
|
6
|
+
const config = loadConfig();
|
|
7
|
+
async function apiCall(method, path, body) {
|
|
8
|
+
const headers = {
|
|
9
|
+
Authorization: `Bearer ${config.accessToken}`,
|
|
10
|
+
"Content-Type": "application/json",
|
|
11
|
+
"Crypto-Version": "*.*.*",
|
|
12
|
+
accountType: "S_",
|
|
13
|
+
platformType: "skill",
|
|
14
|
+
DeviceType: "pc",
|
|
15
|
+
};
|
|
16
|
+
const res = await fetch(`${config.baseUrl}${path}`, {
|
|
17
|
+
method,
|
|
18
|
+
headers,
|
|
19
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
20
|
+
});
|
|
21
|
+
const text = await res.text();
|
|
22
|
+
if (!res.ok) {
|
|
23
|
+
throw new Error(`HTTP ${res.status}: ${text}`);
|
|
24
|
+
}
|
|
25
|
+
return JSON.parse(text);
|
|
26
|
+
}
|
|
27
|
+
export async function getBalance() {
|
|
28
|
+
const data = await apiCall("GET", "/console/wallet/overview");
|
|
29
|
+
return data.data;
|
|
30
|
+
}
|
|
31
|
+
export async function getTrend(days = 30) {
|
|
32
|
+
const data = await apiCall("GET", `/console/wallet/consumption/trend?days=${days}`);
|
|
33
|
+
return data.data;
|
|
34
|
+
}
|
|
35
|
+
export async function getTransactions(params) {
|
|
36
|
+
const query = new URLSearchParams();
|
|
37
|
+
if (params?.recordType)
|
|
38
|
+
query.append("recordType", params.recordType);
|
|
39
|
+
if (params?.startDate)
|
|
40
|
+
query.append("startDate", params.startDate);
|
|
41
|
+
if (params?.endDate)
|
|
42
|
+
query.append("endDate", params.endDate);
|
|
43
|
+
const qs = query.toString();
|
|
44
|
+
const data = await apiCall("GET", `/console/wallet/transaction/list${qs ? "?" + qs : ""}`);
|
|
45
|
+
return data.data;
|
|
46
|
+
}
|
|
47
|
+
export async function getCoupons() {
|
|
48
|
+
const data = await apiCall("GET", "/console/wallet/coupon/list");
|
|
49
|
+
return data.data;
|
|
50
|
+
}
|
|
51
|
+
export async function getCorporateInfo() {
|
|
52
|
+
const data = await apiCall("GET", "/console/wallet/recharge/corporate/info");
|
|
53
|
+
return data.data;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/tools/wallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;AAE5B,KAAK,UAAU,OAAO,CAAc,MAAc,EAAE,IAAY,EAAE,IAAc;IAC9E,MAAM,OAAO,GAA2B;QACtC,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;QAC7C,cAAc,EAAE,kBAAkB;QAClC,gBAAgB,EAAE,OAAO;QACzB,WAAW,EAAE,IAAI;QACjB,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,IAAI;KACjB,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE,EAAE;QAClD,MAAM;QACN,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;KAC9C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MA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I,CAAC;AACnB,CAAC;AAsBD,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,IAAI,GAAG,MAAM,OAAO,CAAmC,KAAK,EAAE,6BAA6B,CAAC,CAAC;IACnG,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAWD,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAwC,KAAK,EAAE,yCAAyC,CAAC,CAAC;IACpH,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-user-system",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for token-user-system — wallet operations via Model Context Protocol",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"mcp-user-system": "dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/shenda-ai/mcp-user-system.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/shenda-ai/mcp-user-system/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/shenda-ai/mcp-user-system#readme",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"dev": "tsc --watch",
|
|
30
|
+
"start": "node dist/index.js",
|
|
31
|
+
"prepublishOnly": "npm run build"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"mcp",
|
|
35
|
+
"model-context-protocol",
|
|
36
|
+
"token-user-system",
|
|
37
|
+
"wallet",
|
|
38
|
+
"claude",
|
|
39
|
+
"ai"
|
|
40
|
+
],
|
|
41
|
+
"author": "shenda-ai",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "^1.0.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"typescript": "^5.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|