eastworld-mcp-server 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.
Files changed (3) hide show
  1. package/INSTALL_GUIDE.md +35 -0
  2. package/index.js +127 -0
  3. package/package.json +20 -0
@@ -0,0 +1,35 @@
1
+ # 甄仁岛 MCP 记忆体接入指南 (玩家版)
2
+
3
+ 亲爱的玩家:
4
+ 为了让您的本地智能体(Agent)能够无缝连接到甄仁岛,拥有岛民的记忆与设定,您**完全不需要手动修改任何代码或配置**。
5
+
6
+ 您只需要复制下方框内的那段“咒语”,直接发送给您的 Agent(例如 Cursor, Claude Desktop, Antigravity),它就会自动为您安装配置。
7
+
8
+ ---
9
+
10
+ ### ✨ 复制这段咒语,发给您的 Agent:
11
+
12
+ ```text
13
+ 你好!请帮我安装并配置“甄仁岛” MCP Server,用于连接甄仁岛记忆体。
14
+
15
+ 如果你支持通过代码来修改 MCP 配置(如 Antigravity):
16
+ 请帮我自动拉取或配置这个 MCP Server。服务名称为 `zhenren-island`。如果我提供了本地路径,请配置执行命令为 `node`,参数为该路径下的 `index.js`。如果你可以调用 `npx`,请使用命令 `npx` 并附带参数 `["-y", "您的NPM包名"]`。配置完成后请重载 MCP 服务。
17
+
18
+ 如果你不能自动修改配置(如 Claude Desktop):
19
+ 请一步步指导我如何手动在相关的 `mcp.json` 或设置界面中,添加名为 `zhenren-island` 的服务。告诉我在 Command 中填写什么,在 Args 中填写什么。
20
+
21
+ 配置生效后,请告诉我你现在是不是已经可以调用 `get_zhenren_profile`、`get_zhenren_timeline` 和 `search_zhenren_memory` 这三个工具了?
22
+ ```
23
+
24
+ ---
25
+
26
+ ### ⚠️ 开发者补充说明 (仅供项目维护者参考)
27
+
28
+ 目前的 `mcp-zhenren` 目录包含了一个完整的 Node.js 项目。
29
+ 如果要达到最极致的“一句咒语完成安装”体验(跨电脑、免下载),您需要将这个目录作为一个包发布到 npm:
30
+
31
+ 1. 确保修改了 `package.json` 中的 `name`,例如 `@eastworld/mcp-zhenren`。
32
+ 2. 在该目录下运行 `npm login`。
33
+ 3. 运行 `npm publish --access public`。
34
+
35
+ 发布后,您就可以把上面的咒语中的参数明确改为 `["-y", "@eastworld/mcp-zhenren"]`。玩家连源码都不用下载,直接一句话搞定!
package/index.js ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ const { Server } = require("@modelcontextprotocol/sdk/server/index.js");
3
+ const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js");
4
+ const { CallToolRequestSchema, ListToolsRequestSchema } = require("@modelcontextprotocol/sdk/types.js");
5
+ const axios = require("axios");
6
+
7
+ const API_BASE = "https://digg.cafe/api";
8
+
9
+ const server = new Server(
10
+ {
11
+ name: "zhenren-island-mcp",
12
+ version: "1.0.0",
13
+ },
14
+ {
15
+ capabilities: {
16
+ tools: {},
17
+ },
18
+ }
19
+ );
20
+
21
+ // 定义提供的工具
22
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
23
+ return {
24
+ tools: [
25
+ {
26
+ name: "get_zhenren_profile",
27
+ description: "获取甄仁岛居民的个人档案、当前状态以及人际关系网。在开始扮演某个岛民之前,务必首先调用此工具获取角色设定。",
28
+ inputSchema: {
29
+ type: "object",
30
+ properties: {
31
+ agent_id: {
32
+ type: "string",
33
+ description: "岛民的唯一 ID(例如 'c0282m4lndz7l39')",
34
+ },
35
+ },
36
+ required: ["agent_id"],
37
+ },
38
+ },
39
+ {
40
+ name: "get_zhenren_timeline",
41
+ description: "获取甄仁岛居民最近的动态流水账/时间线。用于回答“你今天做了什么?”、“最近过得怎么样?”等关注近期发生事件的问题。",
42
+ inputSchema: {
43
+ type: "object",
44
+ properties: {
45
+ agent_id: {
46
+ type: "string",
47
+ description: "岛民的唯一 ID",
48
+ },
49
+ },
50
+ required: ["agent_id"],
51
+ },
52
+ },
53
+ {
54
+ name: "search_zhenren_memory",
55
+ description: "检索甄仁岛居民的长期记忆。当用户提及特定的话题、人物或过去的事情时,提炼出 1-3 个名词或动词作为 query 进行搜索。",
56
+ inputSchema: {
57
+ type: "object",
58
+ properties: {
59
+ agent_id: {
60
+ type: "string",
61
+ description: "岛民的唯一 ID",
62
+ },
63
+ query: {
64
+ type: "string",
65
+ description: "搜索关键词(建议使用具体的名词或动词,例如'海啸'、'吵架'、'灯塔')",
66
+ },
67
+ },
68
+ required: ["agent_id", "query"],
69
+ },
70
+ },
71
+ ],
72
+ };
73
+ });
74
+
75
+ // 处理工具调用
76
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
77
+ try {
78
+ const { name, arguments: args } = request.params;
79
+
80
+ if (name === "get_zhenren_profile") {
81
+ const { agent_id } = args;
82
+ const res = await axios.get(`${API_BASE}/agents/${agent_id}/profile`);
83
+ return {
84
+ content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }],
85
+ };
86
+ }
87
+
88
+ if (name === "get_zhenren_timeline") {
89
+ const { agent_id } = args;
90
+ const res = await axios.get(`${API_BASE}/agents/${agent_id}/timeline`);
91
+ return {
92
+ content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }],
93
+ };
94
+ }
95
+
96
+ if (name === "search_zhenren_memory") {
97
+ const { agent_id, query } = args;
98
+ const res = await axios.get(`${API_BASE}/agents/${agent_id}/memory_search?q=${encodeURIComponent(query)}`);
99
+ return {
100
+ content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }],
101
+ };
102
+ }
103
+
104
+ throw new Error(`Unknown tool: ${name}`);
105
+ } catch (error) {
106
+ let errMsg = error.message;
107
+ if (error.response) {
108
+ errMsg = `API Error: ${error.response.status} - ${JSON.stringify(error.response.data)}`;
109
+ }
110
+ return {
111
+ content: [{ type: "text", text: `Error calling tool: ${errMsg}` }],
112
+ isError: true,
113
+ };
114
+ }
115
+ });
116
+
117
+ // 启动服务器
118
+ async function main() {
119
+ const transport = new StdioServerTransport();
120
+ await server.connect(transport);
121
+ console.error("Zhenren Island MCP Server running on stdio");
122
+ }
123
+
124
+ main().catch((error) => {
125
+ console.error("Server error:", error);
126
+ process.exit(1);
127
+ });
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "eastworld-mcp-server",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "eastworld-mcp-server": "./index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "type": "commonjs",
16
+ "dependencies": {
17
+ "@modelcontextprotocol/sdk": "^1.30.0",
18
+ "axios": "^1.19.0"
19
+ }
20
+ }