mcp-token-data 0.1.0 → 0.1.1
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/build/index.js +8 -72
- package/package.json +1 -1
- package/src/index.ts +9 -79
package/build/index.js
CHANGED
|
@@ -2,105 +2,41 @@
|
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
// 获取当前包的名字(这样代码就是通用的了)
|
|
6
|
+
const SERVER_NAME = process.env.npm_package_name || "mcp-placeholder-server";
|
|
5
7
|
const server = new Server({
|
|
6
|
-
name:
|
|
7
|
-
version: "0.1.
|
|
8
|
+
name: SERVER_NAME,
|
|
9
|
+
version: "0.1.0",
|
|
8
10
|
}, {
|
|
9
11
|
capabilities: {
|
|
10
12
|
tools: {},
|
|
11
13
|
},
|
|
12
14
|
});
|
|
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
15
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
24
16
|
return {
|
|
25
17
|
tools: [
|
|
26
18
|
{
|
|
27
|
-
name: "
|
|
28
|
-
description: "
|
|
19
|
+
name: "get_info",
|
|
20
|
+
description: "Get information about this MCP server.",
|
|
29
21
|
inputSchema: {
|
|
30
22
|
type: "object",
|
|
31
23
|
properties: {},
|
|
32
24
|
},
|
|
33
25
|
},
|
|
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
26
|
],
|
|
49
27
|
};
|
|
50
28
|
});
|
|
51
29
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
52
|
-
|
|
53
|
-
if (request.params.name === "list_supported_rwa") {
|
|
30
|
+
if (request.params.name === "get_info") {
|
|
54
31
|
return {
|
|
55
32
|
content: [
|
|
56
33
|
{
|
|
57
34
|
type: "text",
|
|
58
|
-
text:
|
|
35
|
+
text: `👋 Hello! You have installed '${SERVER_NAME}'.\n\n🚧 This MCP server is currently under active development. The full features for ${SERVER_NAME} will be released in the next version.\n\nStay tuned!`,
|
|
59
36
|
},
|
|
60
37
|
],
|
|
61
38
|
};
|
|
62
39
|
}
|
|
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
40
|
throw new Error("Tool not found");
|
|
105
41
|
});
|
|
106
42
|
const transport = new StdioServerTransport();
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,12 +5,14 @@ import {
|
|
|
5
5
|
CallToolRequestSchema,
|
|
6
6
|
ListToolsRequestSchema,
|
|
7
7
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
// 获取当前包的名字(这样代码就是通用的了)
|
|
10
|
+
const SERVER_NAME = process.env.npm_package_name || "mcp-placeholder-server";
|
|
9
11
|
|
|
10
12
|
const server = new Server(
|
|
11
13
|
{
|
|
12
|
-
name:
|
|
13
|
-
version: "0.1.
|
|
14
|
+
name: SERVER_NAME,
|
|
15
|
+
version: "0.1.0",
|
|
14
16
|
},
|
|
15
17
|
{
|
|
16
18
|
capabilities: {
|
|
@@ -19,104 +21,32 @@ const server = new Server(
|
|
|
19
21
|
}
|
|
20
22
|
);
|
|
21
23
|
|
|
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
24
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
34
25
|
return {
|
|
35
26
|
tools: [
|
|
36
27
|
{
|
|
37
|
-
name: "
|
|
38
|
-
description: "
|
|
28
|
+
name: "get_info",
|
|
29
|
+
description: "Get information about this MCP server.",
|
|
39
30
|
inputSchema: {
|
|
40
31
|
type: "object",
|
|
41
32
|
properties: {},
|
|
42
33
|
},
|
|
43
34
|
},
|
|
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
35
|
],
|
|
59
36
|
};
|
|
60
37
|
});
|
|
61
38
|
|
|
62
39
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
63
|
-
|
|
64
|
-
if (request.params.name === "list_supported_rwa") {
|
|
40
|
+
if (request.params.name === "get_info") {
|
|
65
41
|
return {
|
|
66
42
|
content: [
|
|
67
43
|
{
|
|
68
44
|
type: "text",
|
|
69
|
-
text:
|
|
45
|
+
text: `👋 Hello! You have installed '${SERVER_NAME}'.\n\n🚧 This MCP server is currently under active development. The full features for ${SERVER_NAME} will be released in the next version.\n\nStay tuned!`,
|
|
70
46
|
},
|
|
71
47
|
],
|
|
72
48
|
};
|
|
73
49
|
}
|
|
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
50
|
throw new Error("Tool not found");
|
|
121
51
|
});
|
|
122
52
|
|