@bsbofmusic/evomap-mcp-lite 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/index.js +93 -0
- package/package.json +13 -0
package/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
|
|
7
|
+
const API = process.env.EVOMAP_API_BASE || "https://evomap.ai";
|
|
8
|
+
const TIMEOUT_MS = Number(process.env.EVOMAP_TIMEOUT || "30") * 1000;
|
|
9
|
+
|
|
10
|
+
function clipJson(obj, maxChars = 6000) {
|
|
11
|
+
const s = JSON.stringify(obj, null, 2);
|
|
12
|
+
if (s.length <= maxChars) return s;
|
|
13
|
+
return s.slice(0, maxChars) + "\n...<clipped>";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function http(method, url, data) {
|
|
17
|
+
const res = await axios({
|
|
18
|
+
method,
|
|
19
|
+
url,
|
|
20
|
+
data,
|
|
21
|
+
timeout: TIMEOUT_MS,
|
|
22
|
+
headers: { "content-type": "application/json" }
|
|
23
|
+
});
|
|
24
|
+
return res.data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const server = new McpServer({
|
|
28
|
+
name: "evomap-lite",
|
|
29
|
+
version: "0.1.0"
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/* ========================
|
|
33
|
+
TOOL 1: FETCH
|
|
34
|
+
======================== */
|
|
35
|
+
server.tool(
|
|
36
|
+
"evomap_fetch",
|
|
37
|
+
{
|
|
38
|
+
signals: { type: "array", items: { type: "string" } },
|
|
39
|
+
context: { type: "string" },
|
|
40
|
+
limit: { type: "number", optional: true }
|
|
41
|
+
},
|
|
42
|
+
async ({ signals, context, limit }) => {
|
|
43
|
+
const payload = {
|
|
44
|
+
signals,
|
|
45
|
+
context,
|
|
46
|
+
limit: Math.min(Number(limit || 5), 10)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const data = await http("post", `${API}/a2a/fetch`, payload);
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: "text", text: clipJson(data) }]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
/* ========================
|
|
58
|
+
TOOL 2: ASSET DETAIL
|
|
59
|
+
======================== */
|
|
60
|
+
server.tool(
|
|
61
|
+
"evomap_asset",
|
|
62
|
+
{
|
|
63
|
+
asset_id: { type: "string" }
|
|
64
|
+
},
|
|
65
|
+
async ({ asset_id }) => {
|
|
66
|
+
const data = await http("get", `${API}/a2a/assets/${asset_id}`);
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: "text", text: clipJson(data) }]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/* ========================
|
|
74
|
+
TOOL 3: VALIDATE
|
|
75
|
+
======================== */
|
|
76
|
+
server.tool(
|
|
77
|
+
"evomap_validate_bundle",
|
|
78
|
+
{
|
|
79
|
+
bundle: { type: "object" }
|
|
80
|
+
},
|
|
81
|
+
async ({ bundle }) => {
|
|
82
|
+
const data = await http("post", `${API}/a2a/validate`, bundle);
|
|
83
|
+
return {
|
|
84
|
+
content: [{ type: "text", text: clipJson(data) }]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
/* ========================
|
|
90
|
+
正确启动 MCP (stdio)
|
|
91
|
+
======================== */
|
|
92
|
+
const transport = new StdioServerTransport();
|
|
93
|
+
await server.connect(transport);
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bsbofmusic/evomap-mcp-lite",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lite MCP server for EvoMap asset reuse (bugfix oriented)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"evomap-mcp-lite": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
11
|
+
"axios": "^1.6.0"
|
|
12
|
+
}
|
|
13
|
+
}
|