@mikoto_zero/minigame-open-mcp 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 +235 -0
- package/bin/minigame-open-mcp +34 -0
- package/dist/data/leaderboardDocs.d.ts +37 -0
- package/dist/data/leaderboardDocs.d.ts.map +1 -0
- package/dist/data/leaderboardDocs.js +576 -0
- package/dist/data/leaderboardDocs.js.map +1 -0
- package/dist/network/httpClient.d.ts +80 -0
- package/dist/network/httpClient.d.ts.map +1 -0
- package/dist/network/httpClient.js +244 -0
- package/dist/network/httpClient.js.map +1 -0
- package/dist/network/leaderboardApi.d.ts +174 -0
- package/dist/network/leaderboardApi.d.ts.map +1 -0
- package/dist/network/leaderboardApi.js +219 -0
- package/dist/network/leaderboardApi.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +538 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/leaderboardTools.d.ts +56 -0
- package/dist/tools/leaderboardTools.d.ts.map +1 -0
- package/dist/tools/leaderboardTools.js +120 -0
- package/dist/tools/leaderboardTools.js.map +1 -0
- package/dist/utils/cache.d.ts +36 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +90 -0
- package/dist/utils/cache.js.map +1 -0
- package/package.json +66 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* TapTap 小游戏开发文档 MCP 服务器 - Node.js 版本
|
|
4
|
+
*/
|
|
5
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import process from 'node:process';
|
|
9
|
+
// 导入工具处理器
|
|
10
|
+
import { leaderboardTools } from './tools/leaderboardTools.js';
|
|
11
|
+
// 导入网络API
|
|
12
|
+
import { createLeaderboard, listLeaderboards, ensureAppInfo } from './network/leaderboardApi.js';
|
|
13
|
+
import { ApiConfig } from './network/httpClient.js';
|
|
14
|
+
// 环境变量配置
|
|
15
|
+
const apiConfig = ApiConfig.getInstance();
|
|
16
|
+
const TAPTAP_USER_TOKEN = apiConfig.userToken;
|
|
17
|
+
const TAPTAP_CLIENT_ID = apiConfig.clientId;
|
|
18
|
+
const TAPTAP_PROJECT_PATH = process.env.TAPTAP_PROJECT_PATH;
|
|
19
|
+
/**
|
|
20
|
+
* MCP 服务器类
|
|
21
|
+
*/
|
|
22
|
+
class TapTapDocsMCPServer {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.tools = [];
|
|
25
|
+
this.toolHandlers = new Map();
|
|
26
|
+
this.server = new Server({
|
|
27
|
+
name: 'taptap-leaderboard-mcp',
|
|
28
|
+
version: '1.0.0',
|
|
29
|
+
});
|
|
30
|
+
this.setupTools();
|
|
31
|
+
this.setupHandlers();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 设置所有工具定义
|
|
35
|
+
*/
|
|
36
|
+
setupTools() {
|
|
37
|
+
this.tools = [
|
|
38
|
+
// 🎯 Workflow Guidance Tool
|
|
39
|
+
{
|
|
40
|
+
name: 'start_leaderboard_integration',
|
|
41
|
+
description: 'START HERE when user asks about integrating leaderboards, implementing rankings, or "接入排行榜". This tool guides the complete workflow: check existing leaderboards, create if needed, then provide implementation docs. Use this as the first step for any leaderboard integration request.',
|
|
42
|
+
inputSchema: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
purpose: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'What the user wants to do with leaderboards (optional, for context)'
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
// 📖 Core LeaderboardManager API Documentation Tools (one tool per API)
|
|
53
|
+
{
|
|
54
|
+
name: 'get_leaderboard_manager',
|
|
55
|
+
description: 'Get documentation for tap.getLeaderboardManager() - how to obtain the LeaderboardManager instance. Use this when user asks how to initialize or access the leaderboard system.',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'open_leaderboard',
|
|
63
|
+
description: 'Get documentation for leaderboardManager.openLeaderboard() - how to display the TapTap leaderboard UI. Use this when user wants to show leaderboard interface to players.',
|
|
64
|
+
inputSchema: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'submit_scores',
|
|
71
|
+
description: 'Get documentation for leaderboardManager.submitScores() - how to submit player scores to leaderboards. Use this when user wants to upload scores or update rankings.',
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'load_leaderboard_scores',
|
|
79
|
+
description: 'Get documentation for leaderboardManager.loadLeaderboardScores() - how to retrieve paginated leaderboard data. Use this when user wants to fetch top scores or implement custom leaderboard UI.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'load_current_player_score',
|
|
87
|
+
description: 'Get documentation for leaderboardManager.loadCurrentPlayerLeaderboardScore() - how to get current player\'s score and rank. Use this when user wants to show player their own ranking.',
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'load_player_centered_scores',
|
|
95
|
+
description: 'Get documentation for leaderboardManager.loadPlayerCenteredScores() - how to load scores of players near current user. Use this when user wants to display surrounding competitors.',
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
// 🔍 Helper Tools
|
|
102
|
+
{
|
|
103
|
+
name: 'search_leaderboard_docs',
|
|
104
|
+
description: 'Search all leaderboard documentation by keyword. Use this when user asks a general question or you\'re not sure which specific API they need.',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
query: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'Search keyword, such as: leaderboard, score, ranking, submission, etc.'
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
required: ['query']
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'get_leaderboard_overview',
|
|
118
|
+
description: 'Get comprehensive overview of all TapTap leaderboard APIs and features. Use this when user wants to understand what leaderboard functionality is available.',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'get_leaderboard_patterns',
|
|
126
|
+
description: 'Get complete implementation examples and best practices for leaderboards. Use this when user wants to see full integration code or common usage patterns.',
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
properties: {}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
// 🔧 Environment Check Tool
|
|
133
|
+
{
|
|
134
|
+
name: 'check_environment',
|
|
135
|
+
description: 'Check environment configuration and user authentication status. Use this to verify if TAPTAP_USER_TOKEN and TAPTAP_CLIENT_ID are configured.',
|
|
136
|
+
inputSchema: {
|
|
137
|
+
type: 'object',
|
|
138
|
+
properties: {}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
// ⚙️ Leaderboard Management Tools (requires TAPTAP_USER_TOKEN and TAPTAP_CLIENT_ID)
|
|
142
|
+
{
|
|
143
|
+
name: 'create_leaderboard',
|
|
144
|
+
description: 'Create a new leaderboard on TapTap server. Use this AFTER checking existing leaderboards with list_leaderboards or start_leaderboard_integration. Auto-fetches developer_id and app_id if not provided. Returns the leaderboard_id needed for client-side APIs.',
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
developer_id: {
|
|
149
|
+
type: 'number',
|
|
150
|
+
description: 'Developer ID (optional, will be auto-fetched if not provided)'
|
|
151
|
+
},
|
|
152
|
+
app_id: {
|
|
153
|
+
type: 'number',
|
|
154
|
+
description: 'Application/Game ID (optional, will be auto-fetched if not provided)'
|
|
155
|
+
},
|
|
156
|
+
title: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'Leaderboard title/name (required)'
|
|
159
|
+
},
|
|
160
|
+
period_type: {
|
|
161
|
+
type: 'number',
|
|
162
|
+
description: 'Period type: 0=Daily, 1=Weekly, 2=Monthly, 3=Always, 4=Custom (required)',
|
|
163
|
+
enum: [0, 1, 2, 3, 4]
|
|
164
|
+
},
|
|
165
|
+
score_type: {
|
|
166
|
+
type: 'number',
|
|
167
|
+
description: 'Score type: 0=Integer, 1=Float, 2=Time (required)',
|
|
168
|
+
enum: [0, 1, 2]
|
|
169
|
+
},
|
|
170
|
+
score_order: {
|
|
171
|
+
type: 'number',
|
|
172
|
+
description: 'Score order: 0=Ascending (lower is better), 1=Descending (higher is better), 2=None (required)',
|
|
173
|
+
enum: [0, 1, 2]
|
|
174
|
+
},
|
|
175
|
+
calc_type: {
|
|
176
|
+
type: 'number',
|
|
177
|
+
description: 'Calculation type: 0=Best, 1=Latest, 2=Sum, 3=First (required)',
|
|
178
|
+
enum: [0, 1, 2, 3]
|
|
179
|
+
},
|
|
180
|
+
display_limit: {
|
|
181
|
+
type: 'number',
|
|
182
|
+
description: 'Display limit for leaderboard entries (optional, default 100)'
|
|
183
|
+
},
|
|
184
|
+
period_time: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: 'Period reset time in HH:MM:SS format (optional, for periodic leaderboards)'
|
|
187
|
+
},
|
|
188
|
+
score_unit: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Score unit display text (optional, e.g., "points", "seconds")'
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
required: ['title', 'period_type', 'score_type', 'score_order', 'calc_type']
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'list_leaderboards',
|
|
198
|
+
description: 'List all leaderboards created for the current app/game. Use this to check existing leaderboards before creating new ones or when user asks "我有哪些排行榜" or wants to see leaderboard IDs. Auto-fetches developer_id and app_id if not provided.',
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
developer_id: {
|
|
203
|
+
type: 'number',
|
|
204
|
+
description: 'Developer ID (optional, will be auto-fetched if not provided)'
|
|
205
|
+
},
|
|
206
|
+
app_id: {
|
|
207
|
+
type: 'number',
|
|
208
|
+
description: 'Application/Game ID (optional, will be auto-fetched if not provided)'
|
|
209
|
+
},
|
|
210
|
+
page: {
|
|
211
|
+
type: 'number',
|
|
212
|
+
description: 'Page number, starts from 1 (optional, default 1)'
|
|
213
|
+
},
|
|
214
|
+
page_size: {
|
|
215
|
+
type: 'number',
|
|
216
|
+
description: 'Results per page (optional, default 10)'
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
// 🔑 User Data Tools (requires TAPTAP_USER_TOKEN)
|
|
222
|
+
{
|
|
223
|
+
name: 'get_user_leaderboard_scores',
|
|
224
|
+
description: 'Get actual user leaderboard score data from TapTap API (requires user login). Use this when user wants to see their own scores or ranking positions. Falls back to documentation mode if token is not provided.',
|
|
225
|
+
inputSchema: {
|
|
226
|
+
type: 'object',
|
|
227
|
+
properties: {
|
|
228
|
+
leaderboardId: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
description: 'The specific leaderboard ID to query. Leave empty to get all leaderboards associated with the user.'
|
|
231
|
+
},
|
|
232
|
+
limit: {
|
|
233
|
+
type: 'number',
|
|
234
|
+
description: 'Maximum number of score entries to return. Default is 10.',
|
|
235
|
+
default: 10
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 设置工具处理器
|
|
244
|
+
*/
|
|
245
|
+
setupHandlers() {
|
|
246
|
+
// Workflow guidance tool
|
|
247
|
+
this.toolHandlers.set('start_leaderboard_integration', this.startLeaderboardIntegration.bind(this));
|
|
248
|
+
// Core LeaderboardManager API documentation tools
|
|
249
|
+
this.toolHandlers.set('get_leaderboard_manager', leaderboardTools.getLeaderboardManager);
|
|
250
|
+
this.toolHandlers.set('open_leaderboard', leaderboardTools.openLeaderboard);
|
|
251
|
+
this.toolHandlers.set('submit_scores', leaderboardTools.submitScores);
|
|
252
|
+
this.toolHandlers.set('load_leaderboard_scores', leaderboardTools.loadLeaderboardScores);
|
|
253
|
+
this.toolHandlers.set('load_current_player_score', leaderboardTools.loadCurrentPlayerScore);
|
|
254
|
+
this.toolHandlers.set('load_player_centered_scores', leaderboardTools.loadPlayerCenteredScores);
|
|
255
|
+
// Helper tools
|
|
256
|
+
this.toolHandlers.set('search_leaderboard_docs', leaderboardTools.searchLeaderboardDocs);
|
|
257
|
+
this.toolHandlers.set('get_leaderboard_overview', leaderboardTools.getLeaderboardOverview);
|
|
258
|
+
this.toolHandlers.set('get_leaderboard_patterns', leaderboardTools.getLeaderboardPatterns);
|
|
259
|
+
// 环境检查工具处理器
|
|
260
|
+
this.toolHandlers.set('check_environment', this.checkEnvironment.bind(this));
|
|
261
|
+
// 排行榜管理工具处理器(需要 token 和 client_id)
|
|
262
|
+
this.toolHandlers.set('create_leaderboard', this.createLeaderboard.bind(this));
|
|
263
|
+
this.toolHandlers.set('list_leaderboards', this.listLeaderboards.bind(this));
|
|
264
|
+
// 用户数据工具处理器(需要 token)
|
|
265
|
+
this.toolHandlers.set('get_user_leaderboard_scores', this.getUserLeaderboardScores.bind(this));
|
|
266
|
+
// 设置 MCP 服务器处理器
|
|
267
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
268
|
+
tools: this.tools
|
|
269
|
+
}));
|
|
270
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
271
|
+
const { name, arguments: args } = request.params;
|
|
272
|
+
const handler = this.toolHandlers.get(name);
|
|
273
|
+
if (!handler) {
|
|
274
|
+
throw new McpError(ErrorCode.MethodNotFound, `未知工具: ${name}`);
|
|
275
|
+
}
|
|
276
|
+
try {
|
|
277
|
+
const result = await handler(args || {});
|
|
278
|
+
return {
|
|
279
|
+
content: [
|
|
280
|
+
{
|
|
281
|
+
type: 'text',
|
|
282
|
+
text: result
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
throw new McpError(ErrorCode.InternalError, `工具执行失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* 排行榜接入工作流引导
|
|
294
|
+
*/
|
|
295
|
+
async startLeaderboardIntegration(args) {
|
|
296
|
+
try {
|
|
297
|
+
// Step 1: Check existing leaderboards
|
|
298
|
+
const leaderboardsResult = await listLeaderboards({}, TAPTAP_PROJECT_PATH);
|
|
299
|
+
if (!leaderboardsResult.list || leaderboardsResult.list.length === 0) {
|
|
300
|
+
// No leaderboards exist - guide to create one
|
|
301
|
+
return `🎯 排行榜接入流程\n\n` +
|
|
302
|
+
`📋 **当前状态:** 暂无排行榜\n\n` +
|
|
303
|
+
`**下一步操作:**\n` +
|
|
304
|
+
`您需要先创建一个排行榜。请使用 create_leaderboard 工具创建排行榜。\n\n` +
|
|
305
|
+
`**创建排行榜需要配置:**\n` +
|
|
306
|
+
`1. title - 排行榜名称(如 "每周高分榜")\n` +
|
|
307
|
+
`2. period_type - 周期类型:0=每日, 1=每周, 2=每月, 3=永久\n` +
|
|
308
|
+
`3. score_type - 分数类型:0=整数, 1=浮点数, 2=时间\n` +
|
|
309
|
+
`4. score_order - 排序:0=升序(越低越好), 1=降序(越高越好)\n` +
|
|
310
|
+
`5. calc_type - 计算方式:0=最佳, 1=最新, 2=累计, 3=首次\n\n` +
|
|
311
|
+
`💡 **建议配置示例(每周高分榜):**\n` +
|
|
312
|
+
`\`\`\`\n` +
|
|
313
|
+
`title: "每周高分榜"\n` +
|
|
314
|
+
`period_type: 1 (每周)\n` +
|
|
315
|
+
`score_type: 0 (整数)\n` +
|
|
316
|
+
`score_order: 1 (降序,分数越高越好)\n` +
|
|
317
|
+
`calc_type: 0 (保留最佳成绩)\n` +
|
|
318
|
+
`\`\`\``;
|
|
319
|
+
}
|
|
320
|
+
// Leaderboards exist - present options
|
|
321
|
+
let output = `🎯 排行榜接入流程\n\n`;
|
|
322
|
+
output += `📋 **当前状态:** 已有 ${leaderboardsResult.total} 个排行榜\n\n`;
|
|
323
|
+
if (leaderboardsResult.list.length === 1) {
|
|
324
|
+
// Only one leaderboard - recommend using it
|
|
325
|
+
const lb = leaderboardsResult.list[0];
|
|
326
|
+
output += `**推荐使用现有排行榜:**\n`;
|
|
327
|
+
output += `- 名称: ${lb.title}\n`;
|
|
328
|
+
output += `- ID: ${lb.leaderboard_open_id}\n`;
|
|
329
|
+
output += `- 周期: ${lb.period}\n\n`;
|
|
330
|
+
output += `**下一步:选择要实现的功能**\n`;
|
|
331
|
+
output += `请告诉我您想实现以下哪个功能,我会提供相应的代码示例:\n\n`;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
// Multiple leaderboards - let AI/user choose
|
|
335
|
+
output += `**现有排行榜列表:**\n\n`;
|
|
336
|
+
leaderboardsResult.list.forEach((lb, index) => {
|
|
337
|
+
output += `${index + 1}. **${lb.title}** (ID: ${lb.leaderboard_open_id})\n`;
|
|
338
|
+
output += ` - 周期: ${lb.period}\n`;
|
|
339
|
+
output += ` - 默认: ${lb.is_default ? '是' : '否'}\n\n`;
|
|
340
|
+
});
|
|
341
|
+
output += `**下一步:**\n`;
|
|
342
|
+
output += `请选择要使用的排行榜,或者告诉我您想创建新的排行榜。\n\n`;
|
|
343
|
+
}
|
|
344
|
+
output += `**可实现的功能:**\n`;
|
|
345
|
+
output += `1. 📊 **打开排行榜界面** - 使用 open_leaderboard 工具查看文档\n`;
|
|
346
|
+
output += `2. 📤 **提交玩家分数** - 使用 submit_scores 工具查看文档\n`;
|
|
347
|
+
output += `3. 📥 **查询排行榜数据** - 使用 load_leaderboard_scores 工具查看文档\n`;
|
|
348
|
+
output += `4. 🎯 **查询玩家排名** - 使用 load_current_player_score 工具查看文档\n`;
|
|
349
|
+
output += `5. 👥 **查询周围玩家** - 使用 load_player_centered_scores 工具查看文档\n`;
|
|
350
|
+
return output;
|
|
351
|
+
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
354
|
+
return `❌ 无法获取排行榜信息:\n${errorMsg}\n\n` +
|
|
355
|
+
`这可能是因为:\n` +
|
|
356
|
+
`1. 用户还没有创建应用/游戏\n` +
|
|
357
|
+
`2. 环境变量配置不正确\n\n` +
|
|
358
|
+
`请先确保用户已在 TapTap 平台创建了应用。`;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* 环境检查工具
|
|
363
|
+
*/
|
|
364
|
+
async checkEnvironment() {
|
|
365
|
+
const configStatus = apiConfig.getConfigStatus();
|
|
366
|
+
const envInfo = {
|
|
367
|
+
...configStatus,
|
|
368
|
+
'TAPTAP_PROJECT_PATH': TAPTAP_PROJECT_PATH ? '✅ 已配置' : '❌ 未配置 (可选)'
|
|
369
|
+
};
|
|
370
|
+
const envResult = Object.entries(envInfo)
|
|
371
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
372
|
+
.join('\n');
|
|
373
|
+
return `🔧 环境配置检查结果:\n\n${envResult}\n\n✨ 所有必需配置已就绪,可以使用完整功能`;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* 创建排行榜
|
|
377
|
+
*/
|
|
378
|
+
async createLeaderboard(args) {
|
|
379
|
+
try {
|
|
380
|
+
// Ensure developer_id and app_id are available
|
|
381
|
+
let developerId = args.developer_id;
|
|
382
|
+
let appId = args.app_id;
|
|
383
|
+
// If not provided, try to get from cache or API
|
|
384
|
+
if (!developerId || !appId) {
|
|
385
|
+
const appInfo = await ensureAppInfo(TAPTAP_PROJECT_PATH);
|
|
386
|
+
if (!developerId) {
|
|
387
|
+
developerId = appInfo.developer_id;
|
|
388
|
+
}
|
|
389
|
+
if (!appId) {
|
|
390
|
+
appId = appInfo.app_id;
|
|
391
|
+
}
|
|
392
|
+
if (!developerId || !appId) {
|
|
393
|
+
return `❌ 无法获取 developer_id 或 app_id\n\n` +
|
|
394
|
+
`系统会自动从 /level/v1/list 接口获取您的应用信息。\n` +
|
|
395
|
+
`如果失败,请检查:\n` +
|
|
396
|
+
`1. 用户是否已创建应用/游戏\n` +
|
|
397
|
+
`2. TAPTAP_USER_TOKEN 是否有效\n` +
|
|
398
|
+
`3. 您也可以手动指定 developer_id 和 app_id 参数`;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
const result = await createLeaderboard({
|
|
402
|
+
developer_id: developerId,
|
|
403
|
+
app_id: appId,
|
|
404
|
+
title: args.title,
|
|
405
|
+
period_type: args.period_type,
|
|
406
|
+
score_type: args.score_type,
|
|
407
|
+
score_order: args.score_order,
|
|
408
|
+
calc_type: args.calc_type,
|
|
409
|
+
display_limit: args.display_limit,
|
|
410
|
+
period_time: args.period_time,
|
|
411
|
+
score_unit: args.score_unit
|
|
412
|
+
});
|
|
413
|
+
return `✅ 排行榜创建成功!\n\n` +
|
|
414
|
+
`📊 排行榜信息:\n` +
|
|
415
|
+
`- Leaderboard ID: ${result.leaderboard_id}\n` +
|
|
416
|
+
`- Open ID: ${result.open_id}\n` +
|
|
417
|
+
`- Title: ${result.title}\n` +
|
|
418
|
+
`- Status: ${result.default_status}\n\n` +
|
|
419
|
+
`📝 应用信息(已缓存):\n` +
|
|
420
|
+
`- Developer ID: ${developerId}\n` +
|
|
421
|
+
`- App ID: ${appId}\n\n` +
|
|
422
|
+
`🎮 使用方法:\n` +
|
|
423
|
+
`在小游戏中使用 leaderboardId "${result.leaderboard_id}" 来调用排行榜 API`;
|
|
424
|
+
}
|
|
425
|
+
catch (error) {
|
|
426
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
427
|
+
return `❌ 创建排行榜失败:\n${errorMsg}\n\n请检查:\n1. 环境变量是否正确配置(TAPTAP_USER_TOKEN, TAPTAP_CLIENT_ID, TAPTAP_CLIENT_SECRET)\n2. 用户是否已创建应用/游戏\n3. 用户是否有创建排行榜的权限`;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* 查询排行榜列表
|
|
432
|
+
*/
|
|
433
|
+
async listLeaderboards(args) {
|
|
434
|
+
try {
|
|
435
|
+
const result = await listLeaderboards({
|
|
436
|
+
developer_id: args.developer_id,
|
|
437
|
+
app_id: args.app_id,
|
|
438
|
+
page: args.page,
|
|
439
|
+
page_size: args.page_size
|
|
440
|
+
}, TAPTAP_PROJECT_PATH);
|
|
441
|
+
if (!result.list || result.list.length === 0) {
|
|
442
|
+
return `📋 暂无排行榜\n\n您还没有创建任何排行榜。使用 create_leaderboard 工具创建第一个排行榜。`;
|
|
443
|
+
}
|
|
444
|
+
let output = `📋 排行榜列表 (共 ${result.total} 个)\n\n`;
|
|
445
|
+
result.list.forEach((item, index) => {
|
|
446
|
+
output += `${index + 1}. **${item.title}**\n`;
|
|
447
|
+
output += ` - ID: ${item.id}\n`;
|
|
448
|
+
output += ` - Open ID: ${item.leaderboard_open_id}\n`;
|
|
449
|
+
output += ` - Period: ${item.period}\n`;
|
|
450
|
+
output += ` - Default: ${item.is_default ? 'Yes' : 'No'}\n`;
|
|
451
|
+
output += ` - Whitelist Only: ${item.whitelist_only ? 'Yes' : 'No'}\n\n`;
|
|
452
|
+
});
|
|
453
|
+
const currentPage = args.page || 1;
|
|
454
|
+
const pageSize = args.page_size || 10;
|
|
455
|
+
const totalPages = Math.ceil(result.total / pageSize);
|
|
456
|
+
if (totalPages > 1) {
|
|
457
|
+
output += `\n📄 Page ${currentPage} of ${totalPages}\n`;
|
|
458
|
+
if (currentPage < totalPages) {
|
|
459
|
+
output += `Use page=${currentPage + 1} to see more results.\n`;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
return output;
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
466
|
+
return `❌ 查询排行榜列表失败:\n${errorMsg}`;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* 获取用户排行榜分数数据
|
|
471
|
+
*/
|
|
472
|
+
async getUserLeaderboardScores(args) {
|
|
473
|
+
if (!TAPTAP_USER_TOKEN) {
|
|
474
|
+
return `❌ 此功能需要用户登录 TapTap\n请设置 TAPTAP_USER_TOKEN 环境变量\n\n降级为文档模式:\n${await leaderboardTools.getLeaderboardOverview()}`;
|
|
475
|
+
}
|
|
476
|
+
try {
|
|
477
|
+
// 模拟 API 调用(实际项目中替换为真实 API)
|
|
478
|
+
const url = args.leaderboardId
|
|
479
|
+
? `https://api.taptap.com/leaderboard/${args.leaderboardId}/scores`
|
|
480
|
+
: 'https://api.taptap.com/leaderboard/user-scores';
|
|
481
|
+
// @ts-ignore - fetch 在 Node.js 18+ 中可用
|
|
482
|
+
const response = await fetch(url, {
|
|
483
|
+
method: 'GET',
|
|
484
|
+
headers: {
|
|
485
|
+
'Authorization': `Bearer ${TAPTAP_USER_TOKEN}`,
|
|
486
|
+
'Content-Type': 'application/json'
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
if (!response.ok) {
|
|
490
|
+
throw new Error(`API 调用失败: ${response.status} ${response.statusText}`);
|
|
491
|
+
}
|
|
492
|
+
const data = await response.json();
|
|
493
|
+
return `🏆 用户排行榜数据:\n${JSON.stringify(data, null, 2)}`;
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
497
|
+
return `❌ API 调用失败: ${errorMsg}\n\n降级为文档模式:\n${await leaderboardTools.getLeaderboardOverview()}`;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* 启动服务器
|
|
502
|
+
*/
|
|
503
|
+
async start() {
|
|
504
|
+
const transport = new StdioServerTransport();
|
|
505
|
+
await this.server.connect(transport);
|
|
506
|
+
process.stderr.write('🚀 TapTap Leaderboard MCP Server Started\n');
|
|
507
|
+
process.stderr.write(`📚 Providing ${this.tools.length} tools\n`);
|
|
508
|
+
process.stderr.write('🏆 Features: Leaderboard Documentation & Management API\n');
|
|
509
|
+
process.stderr.write(`🌍 Environment: ${apiConfig.environment}\n`);
|
|
510
|
+
process.stderr.write(`🔗 API Base: ${apiConfig.apiBaseUrl}\n`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
// 启动服务器
|
|
514
|
+
async function main() {
|
|
515
|
+
const server = new TapTapDocsMCPServer();
|
|
516
|
+
// 处理优雅关闭
|
|
517
|
+
process.on('SIGINT', () => {
|
|
518
|
+
process.stderr.write('\n📴 收到中断信号,正在关闭服务器...\n');
|
|
519
|
+
process.exit(0);
|
|
520
|
+
});
|
|
521
|
+
process.on('SIGTERM', () => {
|
|
522
|
+
process.stderr.write('\n📴 收到终止信号,正在关闭服务器...\n');
|
|
523
|
+
process.exit(0);
|
|
524
|
+
});
|
|
525
|
+
try {
|
|
526
|
+
await server.start();
|
|
527
|
+
}
|
|
528
|
+
catch (error) {
|
|
529
|
+
process.stderr.write(`❌ 服务器启动失败: ${error}\n`);
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
// 启动主函数
|
|
534
|
+
main().catch((error) => {
|
|
535
|
+
process.stderr.write(`❌ 服务器运行失败: ${error}\n`);
|
|
536
|
+
process.exit(1);
|
|
537
|
+
});
|
|
538
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,SAAS,EAEV,MAAM,oCAAoC,CAAC;AAC5C,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,UAAU;AACV,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,UAAU;AACV,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAKd,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,SAAS;AACT,MAAM,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;AAC1C,MAAM,iBAAiB,GAAG,SAAS,CAAC,SAAS,CAAC;AAC9C,MAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC;AAC5C,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE5D;;GAEG;AACH,MAAM,mBAAmB;IAKvB;QAHQ,UAAK,GAAW,EAAE,CAAC;QACnB,iBAAY,GAAgD,IAAI,GAAG,EAAE,CAAC;QAG5E,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CACtB;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,OAAO;SACjB,CACF,CAAC;QAEF,IAAI,CAAC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AM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,QAAQ;AACR,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TapTap Minigame Leaderboard Documentation Tools
|
|
3
|
+
* Each LeaderboardManager API has its own dedicated tool
|
|
4
|
+
*/
|
|
5
|
+
interface ToolArgs {
|
|
6
|
+
query?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get documentation for tap.getLeaderboardManager()
|
|
10
|
+
*/
|
|
11
|
+
declare function getLeaderboardManager(): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Get documentation for openLeaderboard()
|
|
14
|
+
*/
|
|
15
|
+
declare function openLeaderboard(): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Get documentation for submitScores()
|
|
18
|
+
*/
|
|
19
|
+
declare function submitScores(): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Get documentation for loadLeaderboardScores()
|
|
22
|
+
*/
|
|
23
|
+
declare function loadLeaderboardScores(): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Get documentation for loadCurrentPlayerLeaderboardScore()
|
|
26
|
+
*/
|
|
27
|
+
declare function loadCurrentPlayerScore(): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Get documentation for loadPlayerCenteredScores()
|
|
30
|
+
*/
|
|
31
|
+
declare function loadPlayerCenteredScores(): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Search leaderboard documentation by keyword
|
|
34
|
+
*/
|
|
35
|
+
declare function searchLeaderboardDocs(args: ToolArgs): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Get complete leaderboard system overview
|
|
38
|
+
*/
|
|
39
|
+
declare function getLeaderboardOverview(): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Get integration patterns and best practices
|
|
42
|
+
*/
|
|
43
|
+
declare function getLeaderboardPatterns(): Promise<string>;
|
|
44
|
+
export declare const leaderboardTools: {
|
|
45
|
+
getLeaderboardManager: typeof getLeaderboardManager;
|
|
46
|
+
openLeaderboard: typeof openLeaderboard;
|
|
47
|
+
submitScores: typeof submitScores;
|
|
48
|
+
loadLeaderboardScores: typeof loadLeaderboardScores;
|
|
49
|
+
loadCurrentPlayerScore: typeof loadCurrentPlayerScore;
|
|
50
|
+
loadPlayerCenteredScores: typeof loadPlayerCenteredScores;
|
|
51
|
+
searchLeaderboardDocs: typeof searchLeaderboardDocs;
|
|
52
|
+
getLeaderboardOverview: typeof getLeaderboardOverview;
|
|
53
|
+
getLeaderboardPatterns: typeof getLeaderboardPatterns;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=leaderboardTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaderboardTools.d.ts","sourceRoot":"","sources":["../../src/tools/leaderboardTools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,UAAU,QAAQ;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAuCD;;GAEG;AACH,iBAAe,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEtD;AAED;;GAEG;AACH,iBAAe,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAEhD;AAED;;GAEG;AACH,iBAAe,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAE7C;AAED;;GAEG;AACH,iBAAe,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEtD;AAED;;GAEG;AACH,iBAAe,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEvD;AAED;;GAEG;AACH,iBAAe,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEzD;AAID;;GAEG;AACH,iBAAe,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAcpE;AAED;;GAEG;AACH,iBAAe,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEvD;AAED;;GAEG;AACH,iBAAe,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAavD;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;CAa5B,CAAC"}
|