@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/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# TapTap Minigame Open API MCP Server
|
|
2
|
+
|
|
3
|
+
> Model Context Protocol (MCP) server for TapTap minigame leaderboard documentation and management APIs.
|
|
4
|
+
|
|
5
|
+
🚀 **Auto-fetch IDs** | 📚 **Complete Docs** | 🔧 **Server-side Management**
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### 📖 LeaderboardManager API Documentation
|
|
10
|
+
|
|
11
|
+
Complete documentation for all 5 LeaderboardManager APIs:
|
|
12
|
+
- `tap.getLeaderboardManager()` - Initialize leaderboard system
|
|
13
|
+
- `openLeaderboard()` - Display leaderboard UI
|
|
14
|
+
- `submitScores()` - Submit player scores
|
|
15
|
+
- `loadLeaderboardScores()` - Fetch leaderboard data
|
|
16
|
+
- `loadCurrentPlayerLeaderboardScore()` - Get player's rank
|
|
17
|
+
- `loadPlayerCenteredScores()` - Load nearby players
|
|
18
|
+
|
|
19
|
+
Each API includes:
|
|
20
|
+
- Method signature
|
|
21
|
+
- Parameter descriptions
|
|
22
|
+
- Return values
|
|
23
|
+
- Complete code examples
|
|
24
|
+
- Error handling
|
|
25
|
+
|
|
26
|
+
### ⚙️ Server-side Management
|
|
27
|
+
|
|
28
|
+
- **Create Leaderboards** - Create new leaderboards via TapTap API
|
|
29
|
+
- **List Leaderboards** - Query existing leaderboards
|
|
30
|
+
- **Auto ID Management** - Automatically fetch and cache developer_id and app_id
|
|
31
|
+
- **Smart Workflow** - Intelligent guidance for leaderboard integration
|
|
32
|
+
|
|
33
|
+
### 🎯 Intelligent Workflow
|
|
34
|
+
|
|
35
|
+
The `start_leaderboard_integration` tool provides step-by-step guidance:
|
|
36
|
+
1. Check existing leaderboards
|
|
37
|
+
2. Create if needed
|
|
38
|
+
3. Guide implementation with docs
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install -g minigame-open-mcp
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or use directly with npx (no installation needed):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx minigame-open-mcp
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Configuration
|
|
55
|
+
|
|
56
|
+
#### For Claude Desktop
|
|
57
|
+
|
|
58
|
+
Add to `~/.config/claude-desktop/config.json`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"taptap-leaderboard": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": ["minigame-open-mcp"],
|
|
66
|
+
"env": {
|
|
67
|
+
"TAPTAP_USER_TOKEN": "your_user_token",
|
|
68
|
+
"TAPTAP_CLIENT_ID": "your_client_id",
|
|
69
|
+
"TAPTAP_CLIENT_SECRET": "your_client_secret"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
#### For OpenHands
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"taptap-leaderboard": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": ["minigame-open-mcp"],
|
|
84
|
+
"env": {
|
|
85
|
+
"TAPTAP_USER_TOKEN": "${CURRENT_USER_TAPTAP_TOKEN}",
|
|
86
|
+
"TAPTAP_CLIENT_ID": "your_client_id",
|
|
87
|
+
"TAPTAP_CLIENT_SECRET": "your_client_secret",
|
|
88
|
+
"TAPTAP_PROJECT_PATH": "${CURRENT_PROJECT_PATH}"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Environment Variables
|
|
96
|
+
|
|
97
|
+
**Required:**
|
|
98
|
+
- `TAPTAP_USER_TOKEN` - User authentication token
|
|
99
|
+
- `TAPTAP_CLIENT_ID` - Client ID for API access
|
|
100
|
+
- `TAPTAP_CLIENT_SECRET` - Client secret for request signing
|
|
101
|
+
|
|
102
|
+
**Optional:**
|
|
103
|
+
- `TAPTAP_ENV` - Environment: `production` (default) or `rnd`
|
|
104
|
+
- `TAPTAP_PROJECT_PATH` - Project path for local caching
|
|
105
|
+
|
|
106
|
+
## Usage
|
|
107
|
+
|
|
108
|
+
### Scenario 1: Getting Started with Leaderboards
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
User: "I want to integrate leaderboards into my game"
|
|
112
|
+
|
|
113
|
+
AI Agent calls: start_leaderboard_integration
|
|
114
|
+
|
|
115
|
+
System response:
|
|
116
|
+
✅ Checks existing leaderboards
|
|
117
|
+
✅ Guides creation if needed
|
|
118
|
+
✅ Shows available leaderboard features
|
|
119
|
+
✅ Provides next steps
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Scenario 2: Get Implementation Code
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
User: "How do I submit scores to the leaderboard?"
|
|
126
|
+
|
|
127
|
+
AI Agent calls: submit_scores
|
|
128
|
+
|
|
129
|
+
System returns:
|
|
130
|
+
✅ Method signature: leaderboardManager.submitScores(scores, callback)
|
|
131
|
+
✅ Parameter documentation
|
|
132
|
+
✅ Complete code example
|
|
133
|
+
✅ Error handling guide
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Scenario 3: Create a Leaderboard
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
User: "Create a weekly high score leaderboard"
|
|
140
|
+
|
|
141
|
+
AI Agent calls: create_leaderboard
|
|
142
|
+
{
|
|
143
|
+
title: "Weekly High Score",
|
|
144
|
+
period_type: 1,
|
|
145
|
+
score_type: 0,
|
|
146
|
+
score_order: 1,
|
|
147
|
+
calc_type: 0
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
System:
|
|
151
|
+
✅ Auto-fetches developer_id and app_id
|
|
152
|
+
✅ Creates leaderboard
|
|
153
|
+
✅ Returns leaderboard_id
|
|
154
|
+
✅ Caches for future use
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Available Tools (14 total)
|
|
158
|
+
|
|
159
|
+
### Core API Documentation Tools (6)
|
|
160
|
+
- `get_leaderboard_manager`
|
|
161
|
+
- `open_leaderboard`
|
|
162
|
+
- `submit_scores`
|
|
163
|
+
- `load_leaderboard_scores`
|
|
164
|
+
- `load_current_player_score`
|
|
165
|
+
- `load_player_centered_scores`
|
|
166
|
+
|
|
167
|
+
### Management Tools (2)
|
|
168
|
+
- `create_leaderboard` - Create new leaderboards
|
|
169
|
+
- `list_leaderboards` - Query existing leaderboards
|
|
170
|
+
|
|
171
|
+
### Helper Tools (3)
|
|
172
|
+
- `search_leaderboard_docs` - Search documentation
|
|
173
|
+
- `get_leaderboard_overview` - System overview
|
|
174
|
+
- `get_leaderboard_patterns` - Best practices
|
|
175
|
+
|
|
176
|
+
### System Tools (2)
|
|
177
|
+
- `check_environment` - Environment check
|
|
178
|
+
- `start_leaderboard_integration` - Workflow guidance
|
|
179
|
+
|
|
180
|
+
### User Data Tool (1)
|
|
181
|
+
- `get_user_leaderboard_scores` - Query user scores (requires token)
|
|
182
|
+
|
|
183
|
+
## Technical Details
|
|
184
|
+
|
|
185
|
+
### Request Signing
|
|
186
|
+
|
|
187
|
+
All server-side API requests use HMAC-SHA256 signing:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
Signature = HMAC-SHA256(
|
|
191
|
+
method + "\n" +
|
|
192
|
+
url + "\n" +
|
|
193
|
+
x-tap-headers + "\n" +
|
|
194
|
+
body + "\n",
|
|
195
|
+
TAPTAP_CLIENT_SECRET
|
|
196
|
+
)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Auto ID Management
|
|
200
|
+
|
|
201
|
+
Developer ID and App ID are automatically managed:
|
|
202
|
+
|
|
203
|
+
1. First call to management tools triggers `/level/v1/list` API
|
|
204
|
+
2. Selects first developer and first app
|
|
205
|
+
3. Caches to `~/.config/taptap-minigame/app.json`
|
|
206
|
+
4. Subsequent calls use cached values
|
|
207
|
+
5. No manual ID input needed
|
|
208
|
+
|
|
209
|
+
### Multi-Environment Support
|
|
210
|
+
|
|
211
|
+
- **Production** (default): `https://agent.tapapis.cn`
|
|
212
|
+
- **RND**: `https://agent.api.xdrnd.cn`
|
|
213
|
+
|
|
214
|
+
Switch via `TAPTAP_ENV` environment variable.
|
|
215
|
+
|
|
216
|
+
## Requirements
|
|
217
|
+
|
|
218
|
+
- Node.js >= 16.0.0
|
|
219
|
+
- Valid TapTap user token
|
|
220
|
+
- Client ID and secret for API access
|
|
221
|
+
|
|
222
|
+
## API Reference
|
|
223
|
+
|
|
224
|
+
Based on TapTap official documentation:
|
|
225
|
+
- https://developer.taptap.cn/minigameapidoc/dev/api/open-api/leaderboard/
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT
|
|
230
|
+
|
|
231
|
+
## Links
|
|
232
|
+
|
|
233
|
+
- [TapTap Developer Portal](https://developer.taptap.cn/)
|
|
234
|
+
- [MCP Protocol](https://modelcontextprotocol.io/)
|
|
235
|
+
- [Issues](https://github.com/taptap/taptap-minigame-mcp-server/issues)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TapTap Minigame Open API MCP Server
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
|
|
10
|
+
// Get package root directory
|
|
11
|
+
const packageRoot = path.join(__dirname, '..');
|
|
12
|
+
|
|
13
|
+
// Check if compiled version exists
|
|
14
|
+
const distPath = path.join(packageRoot, 'dist', 'server.js');
|
|
15
|
+
const srcPath = path.join(packageRoot, 'src', 'server.ts');
|
|
16
|
+
|
|
17
|
+
if (fs.existsSync(distPath)) {
|
|
18
|
+
// Use compiled version
|
|
19
|
+
require(distPath);
|
|
20
|
+
} else if (fs.existsSync(srcPath)) {
|
|
21
|
+
// Development mode, use ts-node
|
|
22
|
+
try {
|
|
23
|
+
require('ts-node/register');
|
|
24
|
+
require(srcPath);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('❌ Please install dependencies or build the project:');
|
|
27
|
+
console.error(' npm install');
|
|
28
|
+
console.error(' npm run build');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
console.error('❌ Server file not found');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TapTap Minigame Leaderboard API Documentation
|
|
3
|
+
* Based on: https://developer.taptap.cn/minigameapidoc/dev/api/open-api/leaderboard/
|
|
4
|
+
*/
|
|
5
|
+
export interface LeaderboardAPI {
|
|
6
|
+
name: string;
|
|
7
|
+
method: string;
|
|
8
|
+
description: string;
|
|
9
|
+
parameters?: Record<string, string>;
|
|
10
|
+
returnValue?: string;
|
|
11
|
+
example: string;
|
|
12
|
+
}
|
|
13
|
+
export interface LeaderboardCategory {
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
apis: LeaderboardAPI[];
|
|
17
|
+
}
|
|
18
|
+
export interface LeaderboardDocumentation {
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
apiReference: string;
|
|
22
|
+
categories: Record<string, LeaderboardCategory>;
|
|
23
|
+
}
|
|
24
|
+
export declare const LEADERBOARD_DOCUMENTATION: LeaderboardDocumentation;
|
|
25
|
+
/**
|
|
26
|
+
* Search leaderboard documentation by keyword
|
|
27
|
+
*/
|
|
28
|
+
export declare function searchLeaderboardDocs(query: string, category?: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Get overview of leaderboard system
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLeaderboardOverview(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get detailed documentation for a specific category
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCategoryDocs(category: string): string;
|
|
37
|
+
//# sourceMappingURL=leaderboardDocs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leaderboardDocs.d.ts","sourceRoot":"","sources":["../../src/data/leaderboardDocs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,cAAc,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CACjD;AAED,eAAO,MAAM,yBAAyB,EAAE,wBA0cvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAqChF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAoC/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoCxD"}
|