@mikoto_zero/minigame-open-mcp 1.8.0 → 1.9.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.
@@ -3,12 +3,12 @@
3
3
  /**
4
4
  * TapTap Minigame Open API MCP Server
5
5
  * Entry point for NPM executable
6
- *
6
+ *
7
7
  * Note: Converted to ESM to match package "type": "module"
8
8
  */
9
9
 
10
10
  import { join, dirname } from 'node:path';
11
- import { existsSync } from 'node:fs';
11
+ import { existsSync, readdirSync } from 'node:fs';
12
12
  import { fileURLToPath } from 'node:url';
13
13
 
14
14
  // Get current directory in ESM
@@ -20,15 +20,45 @@ const packageRoot = join(__dirname, '..');
20
20
 
21
21
  // Check if compiled version exists
22
22
  const distPath = join(packageRoot, 'dist', 'server.js');
23
+ const nativePath = join(packageRoot, 'dist', 'native');
23
24
 
24
- if (existsSync(distPath)) {
25
- // Use dynamic import for ES Module
26
- import(distPath).catch(error => {
27
- console.error('❌ Failed to start server:', error);
28
- process.exit(1);
29
- });
30
- } else {
31
- console.error(' Server not found. Please build the project first:');
32
- console.error(' npm run build');
25
+ if (!existsSync(distPath)) {
26
+ console.error('');
27
+ console.error('❌ dist/server.js not found!');
28
+ console.error('');
29
+ console.error('Please build the project first:');
30
+ console.error('');
31
+ console.error(' npm run build # Build server + proxy (skip native)');
32
+ console.error(' npm run build:all # Build all (including native signer)');
33
+ console.error('');
33
34
  process.exit(1);
34
35
  }
36
+
37
+ // Check native signer
38
+ if (!existsSync(nativePath)) {
39
+ console.warn('');
40
+ console.warn('⚠️ dist/native/ not found');
41
+ console.warn(' Native signer will not be available.');
42
+ console.warn(' Set TAPTAP_MCP_CLIENT_ID and TAPTAP_MCP_CLIENT_SECRET for authentication.');
43
+ console.warn('');
44
+ } else {
45
+ const nodeFiles = readdirSync(nativePath).filter(f => f.endsWith('.node'));
46
+ if (nodeFiles.length === 0) {
47
+ console.warn('');
48
+ console.warn('⚠️ No .node binaries found in dist/native/');
49
+ console.warn(' Run: npm run build:native');
50
+ console.warn('');
51
+ }
52
+ }
53
+
54
+ // Start server
55
+ import(distPath).catch(error => {
56
+ console.error('');
57
+ console.error('❌ Failed to start server:', error.message);
58
+ console.error('');
59
+ if (error.code === 'ERR_MODULE_NOT_FOUND') {
60
+ console.error('Missing dependency. Try rebuilding:');
61
+ console.error(' npm run build');
62
+ }
63
+ process.exit(1);
64
+ });
@@ -0,0 +1,95 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /**
7
+ * Compute X-Tap-Sign signature
8
+ *
9
+ * This function generates the X-Tap-Sign header value using the embedded CLIENT_SECRET.
10
+ *
11
+ * ## Signature Format
12
+ *
13
+ * ```text
14
+ * sign_parts = "{method}
15
+ {url}
16
+ {headers_part}
17
+ {body}
18
+ "
19
+ * signature = base64(HMAC-SHA256(sign_parts, CLIENT_SECRET))
20
+ * ```
21
+ *
22
+ * ## Arguments
23
+ *
24
+ * * `method` - HTTP method (GET, POST, etc.)
25
+ * * `url` - Request URL path with query string (e.g., "/api/v1/apps?client_id=xxx")
26
+ * * `headers_part` - Sorted X-Tap-* headers in format "key:value
27
+ key:value"
28
+ * * `body` - Request body (empty string for GET requests)
29
+ *
30
+ * ## Returns
31
+ *
32
+ * Base64-encoded HMAC-SHA256 signature
33
+ *
34
+ * ## Example
35
+ *
36
+ * ```javascript
37
+ * const signature = computeTapSign(
38
+ * "POST",
39
+ * "/api/v1/apps?client_id=xxx",
40
+ * "x-tap-nonce:abc123
41
+ x-tap-ts:1234567890",
42
+ * '{"name":"test"}'
43
+ * );
44
+ * ```
45
+ */
46
+ export declare function computeTapSign(method: string, url: string, headersPart: string, body: string): string
47
+ /**
48
+ * Get the embedded CLIENT_ID
49
+ *
50
+ * This returns the CLIENT_ID that was embedded at compile time.
51
+ * Useful for the MCP server to include in API requests.
52
+ *
53
+ * ## Returns
54
+ *
55
+ * The CLIENT_ID as a string
56
+ *
57
+ * ## Example
58
+ *
59
+ * ```javascript
60
+ * const clientId = getClientId();
61
+ * // Use in API requests: ?client_id=${clientId}
62
+ * ```
63
+ */
64
+ export declare function getClientId(): string
65
+ /**
66
+ * Verify module integrity
67
+ *
68
+ * Performs basic checks to ensure the native module is intact and functional.
69
+ *
70
+ * ## Returns
71
+ *
72
+ * `true` if the module is functional, throws error otherwise
73
+ *
74
+ * ## Example
75
+ *
76
+ * ```javascript
77
+ * try {
78
+ * const ok = verifyIntegrity();
79
+ * console.log('Native signer is ready');
80
+ * } catch (e) {
81
+ * console.error('Native signer failed integrity check:', e);
82
+ * }
83
+ * ```
84
+ */
85
+ export declare function verifyIntegrity(): boolean
86
+ /**
87
+ * Get version information
88
+ *
89
+ * Returns the version of the native signer module.
90
+ *
91
+ * ## Returns
92
+ *
93
+ * Version string in format "x.y.z"
94
+ */
95
+ export declare function getVersion(): string
@@ -0,0 +1,328 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /* prettier-ignore */
4
+
5
+ /* auto-generated by NAPI-RS */
6
+
7
+ const { existsSync, readFileSync } = require('fs')
8
+ const { join, dirname: pathDirname } = require('path')
9
+
10
+ const { platform, arch } = process
11
+
12
+ // Fix __dirname for ESM dynamic import compatibility
13
+ // Use module.filename which is set correctly when CJS is dynamically imported from ESM
14
+ const __dirnameFixed = (typeof __dirname !== 'undefined' && __dirname !== '.' && __dirname !== '')
15
+ ? __dirname
16
+ : (typeof module !== 'undefined' && module.filename)
17
+ ? pathDirname(module.filename)
18
+ : (typeof __filename !== 'undefined' && __filename !== '')
19
+ ? pathDirname(__filename)
20
+ : process.cwd();
21
+
22
+ let nativeBinding = null
23
+ let localFileExisted = false
24
+ let loadError = null
25
+
26
+ function isMusl() {
27
+ // For Node 10
28
+ if (!process.report || typeof process.report.getReport !== 'function') {
29
+ try {
30
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
31
+ return readFileSync(lddPath, 'utf8').includes('musl')
32
+ } catch (e) {
33
+ return true
34
+ }
35
+ } else {
36
+ const { glibcVersionRuntime } = process.report.getReport().header
37
+ return !glibcVersionRuntime
38
+ }
39
+ }
40
+
41
+ switch (platform) {
42
+ case 'android':
43
+ switch (arch) {
44
+ case 'arm64':
45
+ localFileExisted = existsSync(join(__dirnameFixed, 'taptap-signer.android-arm64.node'))
46
+ try {
47
+ if (localFileExisted) {
48
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.android-arm64.node'))
49
+ } else {
50
+ nativeBinding = require('@aspect/taptap-signer-android-arm64')
51
+ }
52
+ } catch (e) {
53
+ loadError = e
54
+ }
55
+ break
56
+ case 'arm':
57
+ localFileExisted = existsSync(join(__dirnameFixed, 'taptap-signer.android-arm-eabi.node'))
58
+ try {
59
+ if (localFileExisted) {
60
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.android-arm-eabi.node'))
61
+ } else {
62
+ nativeBinding = require('@aspect/taptap-signer-android-arm-eabi')
63
+ }
64
+ } catch (e) {
65
+ loadError = e
66
+ }
67
+ break
68
+ default:
69
+ throw new Error(`Unsupported architecture on Android ${arch}`)
70
+ }
71
+ break
72
+ case 'win32':
73
+ switch (arch) {
74
+ case 'x64':
75
+ localFileExisted = existsSync(
76
+ join(__dirnameFixed, 'taptap-signer.win32-x64-msvc.node')
77
+ )
78
+ try {
79
+ if (localFileExisted) {
80
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.win32-x64-msvc.node'))
81
+ } else {
82
+ nativeBinding = require('@aspect/taptap-signer-win32-x64-msvc')
83
+ }
84
+ } catch (e) {
85
+ loadError = e
86
+ }
87
+ break
88
+ case 'ia32':
89
+ localFileExisted = existsSync(
90
+ join(__dirnameFixed, 'taptap-signer.win32-ia32-msvc.node')
91
+ )
92
+ try {
93
+ if (localFileExisted) {
94
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.win32-ia32-msvc.node'))
95
+ } else {
96
+ nativeBinding = require('@aspect/taptap-signer-win32-ia32-msvc')
97
+ }
98
+ } catch (e) {
99
+ loadError = e
100
+ }
101
+ break
102
+ case 'arm64':
103
+ localFileExisted = existsSync(
104
+ join(__dirnameFixed, 'taptap-signer.win32-arm64-msvc.node')
105
+ )
106
+ try {
107
+ if (localFileExisted) {
108
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.win32-arm64-msvc.node'))
109
+ } else {
110
+ nativeBinding = require('@aspect/taptap-signer-win32-arm64-msvc')
111
+ }
112
+ } catch (e) {
113
+ loadError = e
114
+ }
115
+ break
116
+ default:
117
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
118
+ }
119
+ break
120
+ case 'darwin':
121
+ localFileExisted = existsSync(join(__dirnameFixed, 'taptap-signer.darwin-universal.node'))
122
+ try {
123
+ if (localFileExisted) {
124
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.darwin-universal.node'))
125
+ } else {
126
+ nativeBinding = require('@aspect/taptap-signer-darwin-universal')
127
+ }
128
+ break
129
+ } catch {}
130
+ switch (arch) {
131
+ case 'x64':
132
+ localFileExisted = existsSync(join(__dirnameFixed, 'taptap-signer.darwin-x64.node'))
133
+ try {
134
+ if (localFileExisted) {
135
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.darwin-x64.node'))
136
+ } else {
137
+ nativeBinding = require('@aspect/taptap-signer-darwin-x64')
138
+ }
139
+ } catch (e) {
140
+ loadError = e
141
+ }
142
+ break
143
+ case 'arm64':
144
+ localFileExisted = existsSync(
145
+ join(__dirnameFixed, 'taptap-signer.darwin-arm64.node')
146
+ )
147
+ try {
148
+ if (localFileExisted) {
149
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.darwin-arm64.node'))
150
+ } else {
151
+ nativeBinding = require('@aspect/taptap-signer-darwin-arm64')
152
+ }
153
+ } catch (e) {
154
+ loadError = e
155
+ }
156
+ break
157
+ default:
158
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
159
+ }
160
+ break
161
+ case 'freebsd':
162
+ if (arch !== 'x64') {
163
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
164
+ }
165
+ localFileExisted = existsSync(join(__dirnameFixed, 'taptap-signer.freebsd-x64.node'))
166
+ try {
167
+ if (localFileExisted) {
168
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.freebsd-x64.node'))
169
+ } else {
170
+ nativeBinding = require('@aspect/taptap-signer-freebsd-x64')
171
+ }
172
+ } catch (e) {
173
+ loadError = e
174
+ }
175
+ break
176
+ case 'linux':
177
+ switch (arch) {
178
+ case 'x64':
179
+ if (isMusl()) {
180
+ localFileExisted = existsSync(
181
+ join(__dirnameFixed, 'taptap-signer.linux-x64-musl.node')
182
+ )
183
+ try {
184
+ if (localFileExisted) {
185
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-x64-musl.node'))
186
+ } else {
187
+ nativeBinding = require('@aspect/taptap-signer-linux-x64-musl')
188
+ }
189
+ } catch (e) {
190
+ loadError = e
191
+ }
192
+ } else {
193
+ localFileExisted = existsSync(
194
+ join(__dirnameFixed, 'taptap-signer.linux-x64-gnu.node')
195
+ )
196
+ try {
197
+ if (localFileExisted) {
198
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-x64-gnu.node'))
199
+ } else {
200
+ nativeBinding = require('@aspect/taptap-signer-linux-x64-gnu')
201
+ }
202
+ } catch (e) {
203
+ loadError = e
204
+ }
205
+ }
206
+ break
207
+ case 'arm64':
208
+ if (isMusl()) {
209
+ localFileExisted = existsSync(
210
+ join(__dirnameFixed, 'taptap-signer.linux-arm64-musl.node')
211
+ )
212
+ try {
213
+ if (localFileExisted) {
214
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-arm64-musl.node'))
215
+ } else {
216
+ nativeBinding = require('@aspect/taptap-signer-linux-arm64-musl')
217
+ }
218
+ } catch (e) {
219
+ loadError = e
220
+ }
221
+ } else {
222
+ localFileExisted = existsSync(
223
+ join(__dirnameFixed, 'taptap-signer.linux-arm64-gnu.node')
224
+ )
225
+ try {
226
+ if (localFileExisted) {
227
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-arm64-gnu.node'))
228
+ } else {
229
+ nativeBinding = require('@aspect/taptap-signer-linux-arm64-gnu')
230
+ }
231
+ } catch (e) {
232
+ loadError = e
233
+ }
234
+ }
235
+ break
236
+ case 'arm':
237
+ if (isMusl()) {
238
+ localFileExisted = existsSync(
239
+ join(__dirnameFixed, 'taptap-signer.linux-arm-musleabihf.node')
240
+ )
241
+ try {
242
+ if (localFileExisted) {
243
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-arm-musleabihf.node'))
244
+ } else {
245
+ nativeBinding = require('@aspect/taptap-signer-linux-arm-musleabihf')
246
+ }
247
+ } catch (e) {
248
+ loadError = e
249
+ }
250
+ } else {
251
+ localFileExisted = existsSync(
252
+ join(__dirnameFixed, 'taptap-signer.linux-arm-gnueabihf.node')
253
+ )
254
+ try {
255
+ if (localFileExisted) {
256
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-arm-gnueabihf.node'))
257
+ } else {
258
+ nativeBinding = require('@aspect/taptap-signer-linux-arm-gnueabihf')
259
+ }
260
+ } catch (e) {
261
+ loadError = e
262
+ }
263
+ }
264
+ break
265
+ case 'riscv64':
266
+ if (isMusl()) {
267
+ localFileExisted = existsSync(
268
+ join(__dirnameFixed, 'taptap-signer.linux-riscv64-musl.node')
269
+ )
270
+ try {
271
+ if (localFileExisted) {
272
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-riscv64-musl.node'))
273
+ } else {
274
+ nativeBinding = require('@aspect/taptap-signer-linux-riscv64-musl')
275
+ }
276
+ } catch (e) {
277
+ loadError = e
278
+ }
279
+ } else {
280
+ localFileExisted = existsSync(
281
+ join(__dirnameFixed, 'taptap-signer.linux-riscv64-gnu.node')
282
+ )
283
+ try {
284
+ if (localFileExisted) {
285
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-riscv64-gnu.node'))
286
+ } else {
287
+ nativeBinding = require('@aspect/taptap-signer-linux-riscv64-gnu')
288
+ }
289
+ } catch (e) {
290
+ loadError = e
291
+ }
292
+ }
293
+ break
294
+ case 's390x':
295
+ localFileExisted = existsSync(
296
+ join(__dirnameFixed, 'taptap-signer.linux-s390x-gnu.node')
297
+ )
298
+ try {
299
+ if (localFileExisted) {
300
+ nativeBinding = require(join(__dirnameFixed, 'taptap-signer.linux-s390x-gnu.node'))
301
+ } else {
302
+ nativeBinding = require('@aspect/taptap-signer-linux-s390x-gnu')
303
+ }
304
+ } catch (e) {
305
+ loadError = e
306
+ }
307
+ break
308
+ default:
309
+ throw new Error(`Unsupported architecture on Linux: ${arch}`)
310
+ }
311
+ break
312
+ default:
313
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
314
+ }
315
+
316
+ if (!nativeBinding) {
317
+ if (loadError) {
318
+ throw loadError
319
+ }
320
+ throw new Error(`Failed to load native binding`)
321
+ }
322
+
323
+ const { computeTapSign, getClientId, verifyIntegrity, getVersion } = nativeBinding
324
+
325
+ module.exports.computeTapSign = computeTapSign
326
+ module.exports.getClientId = getClientId
327
+ module.exports.verifyIntegrity = verifyIntegrity
328
+ module.exports.getVersion = getVersion
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
package/dist/proxy.js CHANGED
@@ -13389,7 +13389,7 @@ var StreamableHTTPClientTransport = class {
13389
13389
  };
13390
13390
 
13391
13391
  // src/mcp-proxy/proxy.ts
13392
- var VERSION = true ? "1.8.0" : "dev";
13392
+ var VERSION = true ? "1.9.0" : "dev";
13393
13393
  var TapTapMCPProxy = class {
13394
13394
  constructor(config) {
13395
13395
  this.connected = false;
@@ -13552,7 +13552,7 @@ var TapTapMCPProxy = class {
13552
13552
  * 处理待处理的请求队列
13553
13553
  */
13554
13554
  async processPendingRequests() {
13555
- var _a2;
13555
+ var _a2, _b, _c;
13556
13556
  const timeout = ((_a2 = this.config.options) == null ? void 0 : _a2.request_timeout) ?? 3e4;
13557
13557
  const now = Date.now();
13558
13558
  console.error(`[Proxy] Processing ${this.pendingRequests.length} pending requests...`);
@@ -13563,10 +13563,18 @@ var TapTapMCPProxy = class {
13563
13563
  continue;
13564
13564
  }
13565
13565
  try {
13566
- const result = await this.client.callTool({
13567
- name: req.name,
13568
- arguments: req.arguments
13569
- });
13566
+ const result = await this.client.callTool(
13567
+ {
13568
+ name: req.name,
13569
+ arguments: req.arguments
13570
+ },
13571
+ void 0,
13572
+ // resultSchema
13573
+ {
13574
+ timeout: ((_b = this.config.options) == null ? void 0 : _b.tool_call_timeout) ?? 3e5,
13575
+ resetTimeoutOnProgress: ((_c = this.config.options) == null ? void 0 : _c.reset_timeout_on_progress) ?? true
13576
+ }
13577
+ );
13570
13578
  req.resolve(result);
13571
13579
  } catch (error) {
13572
13580
  req.reject(error instanceof Error ? error : new Error(String(error)));
@@ -13638,7 +13646,7 @@ var TapTapMCPProxy = class {
13638
13646
  return result;
13639
13647
  });
13640
13648
  this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
13641
- var _a2;
13649
+ var _a2, _b, _c;
13642
13650
  const { name, arguments: args } = request.params;
13643
13651
  const macToken = this.config.auth;
13644
13652
  const enrichedArgs = {
@@ -13673,10 +13681,18 @@ var TapTapMCPProxy = class {
13673
13681
  );
13674
13682
  }
13675
13683
  try {
13676
- const result = await this.client.callTool({
13677
- name,
13678
- arguments: enrichedArgs
13679
- });
13684
+ const result = await this.client.callTool(
13685
+ {
13686
+ name,
13687
+ arguments: enrichedArgs
13688
+ },
13689
+ void 0,
13690
+ // resultSchema
13691
+ {
13692
+ timeout: ((_b = this.config.options) == null ? void 0 : _b.tool_call_timeout) ?? 3e5,
13693
+ resetTimeoutOnProgress: ((_c = this.config.options) == null ? void 0 : _c.reset_timeout_on_progress) ?? true
13694
+ }
13695
+ );
13680
13696
  return result;
13681
13697
  } catch (error) {
13682
13698
  if (this.isNetworkError(error)) {
@@ -13791,7 +13807,7 @@ function validateConfig(config) {
13791
13807
  }
13792
13808
  }
13793
13809
  function applyDefaults(config) {
13794
- var _a2, _b, _c;
13810
+ var _a2, _b, _c, _d, _e;
13795
13811
  return {
13796
13812
  server: {
13797
13813
  url: config.server.url,
@@ -13806,7 +13822,10 @@ function applyDefaults(config) {
13806
13822
  options: {
13807
13823
  verbose: ((_a2 = config.options) == null ? void 0 : _a2.verbose) ?? false,
13808
13824
  reconnect_interval: ((_b = config.options) == null ? void 0 : _b.reconnect_interval) ?? 5e3,
13809
- request_timeout: ((_c = config.options) == null ? void 0 : _c.request_timeout) ?? 3e4
13825
+ request_timeout: ((_c = config.options) == null ? void 0 : _c.request_timeout) ?? 3e4,
13826
+ tool_call_timeout: ((_d = config.options) == null ? void 0 : _d.tool_call_timeout) ?? 3e5,
13827
+ // 5 分钟
13828
+ reset_timeout_on_progress: ((_e = config.options) == null ? void 0 : _e.reset_timeout_on_progress) ?? true
13810
13829
  }
13811
13830
  };
13812
13831
  }