mcp-token-agent 0.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/README.md ADDED
Binary file
package/build/index.js ADDED
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ const server = new Server({
6
+ name: "mcp-server-rwa", // 名字保持不变
7
+ version: "0.1.1", // 注意:我帮你把版本号升级了
8
+ }, {
9
+ capabilities: {
10
+ tools: {},
11
+ },
12
+ });
13
+ // 这是一个 RWA 资产的推荐列表,告诉 AI 我们支持哪些
14
+ const RWA_ASSETS = {
15
+ "pax-gold": "PAX Gold (Physical Gold)",
16
+ "tether-gold": "Tether Gold (Physical Gold)",
17
+ "ondo-finance": "Ondo (US Treasuries)",
18
+ "maple": "Maple Finance (Institutional Credit)",
19
+ "centrifuge": "Centrifuge (Real World Credit)",
20
+ "polymesh": "Polymesh (Security Tokens)",
21
+ "propy": "Propy (Real Estate)"
22
+ };
23
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
24
+ return {
25
+ tools: [
26
+ {
27
+ name: "list_supported_rwa",
28
+ description: "List supported Real World Assets (RWA) tokens including Gold, Treasuries, and Credit.",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {},
32
+ },
33
+ },
34
+ {
35
+ name: "get_rwa_price",
36
+ description: "Get the real-time price and market data of a specific RWA token.",
37
+ inputSchema: {
38
+ type: "object",
39
+ properties: {
40
+ asset_id: {
41
+ type: "string",
42
+ description: "The ID of the RWA asset (e.g., 'pax-gold', 'ondo-finance'). Use list_supported_rwa to see options.",
43
+ },
44
+ },
45
+ required: ["asset_id"],
46
+ },
47
+ },
48
+ ],
49
+ };
50
+ });
51
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
52
+ // 工具 1:列出支持的资产
53
+ if (request.params.name === "list_supported_rwa") {
54
+ return {
55
+ content: [
56
+ {
57
+ type: "text",
58
+ text: `Supported RWA Assets:\n${Object.entries(RWA_ASSETS).map(([id, desc]) => `- ${id}: ${desc}`).join("\n")}`,
59
+ },
60
+ ],
61
+ };
62
+ }
63
+ // 工具 2:查询具体价格
64
+ if (request.params.name === "get_rwa_price") {
65
+ const params = request.params.arguments;
66
+ const assetId = params.asset_id.toLowerCase();
67
+ try {
68
+ // 依然使用 CoinGecko 的免费 API,但我们只查 RWA
69
+ const response = await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd&include_market_cap=true&include_24hr_change=true`);
70
+ const data = await response.json();
71
+ if (!data[assetId]) {
72
+ return {
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: `Error: RWA Asset '${assetId}' not found or API limit reached.`,
77
+ },
78
+ ],
79
+ isError: true,
80
+ };
81
+ }
82
+ const info = data[assetId];
83
+ return {
84
+ content: [
85
+ {
86
+ type: "text",
87
+ text: `RWA Data for [${assetId.toUpperCase()}]:\nPrice: $${info.usd}\n24h Change: ${info.usd_24h_change.toFixed(2)}%\nMarket Cap: $${info.usd_market_cap.toLocaleString()}`,
88
+ },
89
+ ],
90
+ };
91
+ }
92
+ catch (error) {
93
+ return {
94
+ content: [
95
+ {
96
+ type: "text",
97
+ text: `Failed to fetch RWA data: ${error.message}`,
98
+ },
99
+ ],
100
+ isError: true,
101
+ };
102
+ }
103
+ }
104
+ throw new Error("Tool not found");
105
+ });
106
+ const transport = new StdioServerTransport();
107
+ await server.connect(transport);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "mcp-token-agent",
3
+ "version": "0.1.0",
4
+ "description": "A MCP server to track Real World Assets (RWA) like Gold, Treasuries, and Real Estate.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "{"
8
+ },
9
+ "license": "ISC",
10
+ "author": "",
11
+ "type": "module",
12
+ "main": "build/index.js",
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "start": "node build/index.js",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "bin": {
19
+ "mcp-token-agent": "./build/index.js"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^25.0.10",
23
+ "typescript": "^5.9.3"
24
+ },
25
+ "dependencies": {
26
+ "@modelcontextprotocol/sdk": "^1.25.3",
27
+ "zod": "^4.3.6"
28
+ }
29
+ }
package/src/index.ts ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import {
5
+ CallToolRequestSchema,
6
+ ListToolsRequestSchema,
7
+ } from "@modelcontextprotocol/sdk/types.js";
8
+ import { z } from "zod";
9
+
10
+ const server = new Server(
11
+ {
12
+ name: "mcp-server-rwa", // 名字保持不变
13
+ version: "0.1.1", // 注意:我帮你把版本号升级了
14
+ },
15
+ {
16
+ capabilities: {
17
+ tools: {},
18
+ },
19
+ }
20
+ );
21
+
22
+ // 这是一个 RWA 资产的推荐列表,告诉 AI 我们支持哪些
23
+ const RWA_ASSETS = {
24
+ "pax-gold": "PAX Gold (Physical Gold)",
25
+ "tether-gold": "Tether Gold (Physical Gold)",
26
+ "ondo-finance": "Ondo (US Treasuries)",
27
+ "maple": "Maple Finance (Institutional Credit)",
28
+ "centrifuge": "Centrifuge (Real World Credit)",
29
+ "polymesh": "Polymesh (Security Tokens)",
30
+ "propy": "Propy (Real Estate)"
31
+ };
32
+
33
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
34
+ return {
35
+ tools: [
36
+ {
37
+ name: "list_supported_rwa",
38
+ description: "List supported Real World Assets (RWA) tokens including Gold, Treasuries, and Credit.",
39
+ inputSchema: {
40
+ type: "object",
41
+ properties: {},
42
+ },
43
+ },
44
+ {
45
+ name: "get_rwa_price",
46
+ description: "Get the real-time price and market data of a specific RWA token.",
47
+ inputSchema: {
48
+ type: "object",
49
+ properties: {
50
+ asset_id: {
51
+ type: "string",
52
+ description: "The ID of the RWA asset (e.g., 'pax-gold', 'ondo-finance'). Use list_supported_rwa to see options.",
53
+ },
54
+ },
55
+ required: ["asset_id"],
56
+ },
57
+ },
58
+ ],
59
+ };
60
+ });
61
+
62
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
63
+ // 工具 1:列出支持的资产
64
+ if (request.params.name === "list_supported_rwa") {
65
+ return {
66
+ content: [
67
+ {
68
+ type: "text",
69
+ text: `Supported RWA Assets:\n${Object.entries(RWA_ASSETS).map(([id, desc]) => `- ${id}: ${desc}`).join("\n")}`,
70
+ },
71
+ ],
72
+ };
73
+ }
74
+
75
+ // 工具 2:查询具体价格
76
+ if (request.params.name === "get_rwa_price") {
77
+ const params = request.params.arguments as { asset_id: string };
78
+ const assetId = params.asset_id.toLowerCase();
79
+
80
+ try {
81
+ // 依然使用 CoinGecko 的免费 API,但我们只查 RWA
82
+ const response = await fetch(
83
+ `https://api.coingecko.com/api/v3/simple/price?ids=${assetId}&vs_currencies=usd&include_market_cap=true&include_24hr_change=true`
84
+ );
85
+ const data = await response.json() as any;
86
+
87
+ if (!data[assetId]) {
88
+ return {
89
+ content: [
90
+ {
91
+ type: "text",
92
+ text: `Error: RWA Asset '${assetId}' not found or API limit reached.`,
93
+ },
94
+ ],
95
+ isError: true,
96
+ };
97
+ }
98
+
99
+ const info = data[assetId];
100
+ return {
101
+ content: [
102
+ {
103
+ type: "text",
104
+ text: `RWA Data for [${assetId.toUpperCase()}]:\nPrice: $${info.usd}\n24h Change: ${info.usd_24h_change.toFixed(2)}%\nMarket Cap: $${info.usd_market_cap.toLocaleString()}`,
105
+ },
106
+ ],
107
+ };
108
+ } catch (error) {
109
+ return {
110
+ content: [
111
+ {
112
+ type: "text",
113
+ text: `Failed to fetch RWA data: ${(error as Error).message}`,
114
+ },
115
+ ],
116
+ isError: true,
117
+ };
118
+ }
119
+ }
120
+ throw new Error("Tool not found");
121
+ });
122
+
123
+ const transport = new StdioServerTransport();
124
+ await server.connect(transport);
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "outDir": "./build",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src/**/*"]
12
+ }