@zhuixin/mcp 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { CoreConfig } from '@zhuixin/metadata';
3
+ import { McpServer } from '@modelcontextprotocol/server';
4
+
5
+ declare function startMcpServer(config?: CoreConfig): Promise<McpServer>;
6
+
7
+ export { startMcpServer };
package/dist/index.js ADDED
@@ -0,0 +1,489 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import {
5
+ AppAnalysisService,
6
+ CoreFailure,
7
+ CoreServer,
8
+ VersionComparisonService,
9
+ loadConfig
10
+ } from "@zhuixin/metadata";
11
+ import { CHANNELS } from "@zhuixin/shared";
12
+ import { McpServer } from "@modelcontextprotocol/server";
13
+ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
14
+ import { realpathSync } from "fs";
15
+ import { fileURLToPath } from "url";
16
+ import { randomUUID } from "crypto";
17
+ import { z } from "zod";
18
+ var GOALS = [
19
+ "tech_stack",
20
+ "feature_map",
21
+ "network",
22
+ "native_risk",
23
+ "report"
24
+ ];
25
+ function errorResult(error) {
26
+ const failure = error instanceof CoreFailure ? error : new CoreFailure(
27
+ "INTERNAL_ERROR",
28
+ error instanceof Error ? error.message : String(error)
29
+ );
30
+ const nextAction = failure.code === "AUTH_REQUIRED" || failure.code === "KEYCHAIN_LOCKED" ? "\u8FD0\u884C apptrace auth login\uFF0C\u7136\u540E\u91CD\u8BD5\u3002" : failure.code === "LICENSE_REQUIRED" ? "\u8BF7\u5148\u5728\u540C\u4E00 Apple \u8D26\u53F7\u7684 App Store \u83B7\u53D6\u8BE5\u5E94\u7528\u3002" : void 0;
31
+ return {
32
+ isError: true,
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: JSON.stringify(
37
+ {
38
+ code: failure.code,
39
+ message: failure.message,
40
+ details: failure.details,
41
+ nextAction
42
+ },
43
+ null,
44
+ 2
45
+ )
46
+ }
47
+ ]
48
+ };
49
+ }
50
+ function textResult(value) {
51
+ return {
52
+ content: [
53
+ {
54
+ type: "text",
55
+ text: JSON.stringify(value, null, 2)
56
+ }
57
+ ],
58
+ structuredContent: value
59
+ };
60
+ }
61
+ function jobResult(job) {
62
+ return {
63
+ jobId: job.id,
64
+ capabilityId: job.capabilityId,
65
+ status: job.status,
66
+ result: job.result,
67
+ errorCode: job.errorCode,
68
+ errorMessage: job.errorMessage
69
+ };
70
+ }
71
+ async function startMcpServer(config = loadConfig()) {
72
+ const core = new CoreServer({ config, emit: () => {
73
+ } });
74
+ core.store.interruptRunningAnalysisRuns();
75
+ const analysis = new AppAnalysisService(core);
76
+ const runs = /* @__PURE__ */ new Map();
77
+ const mcp = new McpServer({
78
+ name: "apptrace",
79
+ version: "0.1.0"
80
+ });
81
+ mcp.registerTool(
82
+ "analyze_app",
83
+ {
84
+ title: "Analyze an application",
85
+ description: "Resolve, acquire, inspect, extract and statically analyze an authorized app. Returns a compact evidence summary.",
86
+ inputSchema: z.object({
87
+ source: z.string().optional().describe("App Store URL or numeric App Store ID"),
88
+ target_id: z.string().uuid().optional().describe("Existing AppTrace target ID"),
89
+ goals: z.array(z.enum(GOALS)).optional().describe("Analysis goals; defaults to tech stack, feature map and report"),
90
+ force: z.boolean().optional().describe("Re-run analyses even when matching evidence already exists"),
91
+ wait_seconds: z.number().int().min(0).max(60).optional().describe("Seconds to wait before returning a running run_id"),
92
+ timeout_seconds: z.number().int().min(30).max(1800).optional()
93
+ })
94
+ },
95
+ async (input) => {
96
+ if (!input.source && !input.target_id) {
97
+ return errorResult(
98
+ new CoreFailure("SOURCE_REQUIRED", "\u8BF7\u63D0\u4F9B source \u6216 target_id\u3002")
99
+ );
100
+ }
101
+ try {
102
+ const runId = randomUUID();
103
+ const run = {
104
+ id: runId,
105
+ status: "running",
106
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
107
+ promise: Promise.resolve()
108
+ };
109
+ run.promise = analysis.analyzeApp({
110
+ source: input.source,
111
+ targetId: input.target_id,
112
+ goals: input.goals,
113
+ force: input.force,
114
+ timeoutMs: (input.timeout_seconds ?? 1200) * 1e3
115
+ }).then((result) => {
116
+ run.status = "completed";
117
+ run.result = result;
118
+ run.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
119
+ core.store.upsertAnalysisRun({
120
+ id: run.id,
121
+ targetId: input.target_id,
122
+ status: "completed",
123
+ startedAt: run.startedAt,
124
+ finishedAt: run.finishedAt,
125
+ result: run.result,
126
+ updatedAt: run.finishedAt
127
+ });
128
+ }).catch((error) => {
129
+ const failure = error instanceof CoreFailure ? error : new CoreFailure(
130
+ "INTERNAL_ERROR",
131
+ error instanceof Error ? error.message : String(error)
132
+ );
133
+ run.status = "failed";
134
+ run.error = {
135
+ code: failure.code,
136
+ message: failure.message,
137
+ details: failure.details
138
+ };
139
+ run.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
140
+ core.store.upsertAnalysisRun({
141
+ id: run.id,
142
+ targetId: input.target_id,
143
+ status: "failed",
144
+ startedAt: run.startedAt,
145
+ finishedAt: run.finishedAt,
146
+ error: run.error,
147
+ updatedAt: run.finishedAt
148
+ });
149
+ });
150
+ runs.set(runId, run);
151
+ core.store.upsertAnalysisRun({
152
+ id: runId,
153
+ targetId: input.target_id,
154
+ status: "running",
155
+ startedAt: run.startedAt,
156
+ updatedAt: run.startedAt
157
+ });
158
+ const waitSeconds = Math.max(0, input.wait_seconds ?? 10);
159
+ await Promise.race([
160
+ run.promise,
161
+ new Promise((resolve) => setTimeout(resolve, waitSeconds * 1e3))
162
+ ]);
163
+ return textResult({
164
+ runId,
165
+ status: run.status,
166
+ result: run.result,
167
+ error: run.error,
168
+ nextAction: run.status === "running" ? "\u8C03\u7528 get_analysis_run \u7EE7\u7EED\u7B49\u5F85\u6216\u8BFB\u53D6\u7ED3\u679C\u3002" : void 0
169
+ });
170
+ } catch (error) {
171
+ return errorResult(error);
172
+ }
173
+ }
174
+ );
175
+ mcp.registerTool(
176
+ "get_analysis_run",
177
+ {
178
+ title: "Get asynchronous analysis run",
179
+ description: "Wait for or retrieve the result of an analyze_app run.",
180
+ inputSchema: z.object({
181
+ run_id: z.string().uuid(),
182
+ wait_seconds: z.number().int().min(0).max(1800).optional()
183
+ })
184
+ },
185
+ async ({ run_id, wait_seconds }) => {
186
+ const run = runs.get(run_id);
187
+ if (!run) {
188
+ const stored = core.store.getAnalysisRun(run_id);
189
+ return stored ? textResult(stored) : errorResult(
190
+ new CoreFailure("ANALYSIS_RUN_NOT_FOUND", "\u5206\u6790\u8FD0\u884C\u4E0D\u5B58\u5728\u6216\u5DF2\u7ECF\u8D85\u65F6\u3002")
191
+ );
192
+ }
193
+ await Promise.race([
194
+ run.promise,
195
+ new Promise(
196
+ (resolve) => setTimeout(resolve, Math.max(0, wait_seconds ?? 10) * 1e3)
197
+ )
198
+ ]);
199
+ return textResult({
200
+ runId: run.id,
201
+ status: run.status,
202
+ startedAt: run.startedAt,
203
+ finishedAt: run.finishedAt,
204
+ result: run.result,
205
+ error: run.error
206
+ });
207
+ }
208
+ );
209
+ mcp.registerTool(
210
+ "list_targets",
211
+ {
212
+ title: "List application targets",
213
+ description: "List all locally registered AppTrace targets.",
214
+ inputSchema: z.object({})
215
+ },
216
+ async () => {
217
+ try {
218
+ const targets = await core.handle(CHANNELS.targetsList, {});
219
+ return textResult(targets);
220
+ } catch (error) {
221
+ return errorResult(error);
222
+ }
223
+ }
224
+ );
225
+ mcp.registerTool(
226
+ "auth_status",
227
+ {
228
+ title: "Apple account status",
229
+ description: "Read the local App Store login state. Never returns passwords, 2FA codes or keychain secrets.",
230
+ inputSchema: z.object({})
231
+ },
232
+ async () => {
233
+ try {
234
+ const status = await core.handle(CHANNELS.accountStatus, {
235
+ force: true
236
+ });
237
+ return textResult(status);
238
+ } catch (error) {
239
+ return errorResult(error);
240
+ }
241
+ }
242
+ );
243
+ mcp.registerTool(
244
+ "get_job",
245
+ {
246
+ title: "Get job status",
247
+ description: "Return a job, its recent events and result.",
248
+ inputSchema: z.object({
249
+ job_id: z.string().uuid()
250
+ })
251
+ },
252
+ async ({ job_id }) => {
253
+ try {
254
+ const result = await core.handle(CHANNELS.jobsGet, {
255
+ jobId: job_id
256
+ });
257
+ return textResult({
258
+ ...result,
259
+ events: result.events.slice(-50)
260
+ });
261
+ } catch (error) {
262
+ return errorResult(error);
263
+ }
264
+ }
265
+ );
266
+ mcp.registerTool(
267
+ "search_findings",
268
+ {
269
+ title: "Search structured findings",
270
+ description: "Search persisted routes, modules, assets, endpoints, storage and native findings for a target.",
271
+ inputSchema: z.object({
272
+ target_id: z.string().uuid(),
273
+ query: z.string().trim().max(512).optional(),
274
+ types: z.array(
275
+ z.enum([
276
+ "technology",
277
+ "route",
278
+ "network_endpoint",
279
+ "module",
280
+ "asset",
281
+ "storage",
282
+ "native_procedure",
283
+ "native_string",
284
+ "risk",
285
+ "limitation"
286
+ ])
287
+ ).optional(),
288
+ limit: z.number().int().min(1).max(1e3).optional(),
289
+ offset: z.number().int().min(0).optional()
290
+ })
291
+ },
292
+ async (input) => {
293
+ try {
294
+ return textResult(
295
+ await core.handle(CHANNELS.findingsSearch, {
296
+ targetId: input.target_id,
297
+ query: input.query,
298
+ types: input.types,
299
+ limit: input.limit,
300
+ offset: input.offset
301
+ })
302
+ );
303
+ } catch (error) {
304
+ return errorResult(error);
305
+ }
306
+ }
307
+ );
308
+ mcp.registerTool(
309
+ "search_native",
310
+ {
311
+ title: "Search native symbols",
312
+ description: "Search native procedure names or strings. Use a returned procedure name with decompile_function.",
313
+ inputSchema: z.object({
314
+ target_id: z.string().uuid(),
315
+ query: z.string().trim().min(1).max(512),
316
+ kind: z.enum(["procedures", "strings"]).optional(),
317
+ mode: z.enum(["literal", "regex"]).optional()
318
+ })
319
+ },
320
+ async ({ target_id, query, kind, mode }) => {
321
+ try {
322
+ return textResult(
323
+ jobResult(
324
+ await analysis.runCapability(target_id, "native:search", {
325
+ query,
326
+ kind: kind ?? "procedures",
327
+ mode: mode ?? "literal"
328
+ })
329
+ )
330
+ );
331
+ } catch (error) {
332
+ return errorResult(error);
333
+ }
334
+ }
335
+ );
336
+ mcp.registerTool(
337
+ "decompile_function",
338
+ {
339
+ title: "Decompile one native function",
340
+ description: "Decompile an exact function or symbol name returned by search_native. Encrypted targets are refused.",
341
+ inputSchema: z.object({
342
+ target_id: z.string().uuid(),
343
+ function_name: z.string().trim().min(1).max(256).regex(/^[A-Za-z_$][A-Za-z0-9_$.@:-]{0,255}$/)
344
+ })
345
+ },
346
+ async ({ target_id, function_name }) => {
347
+ try {
348
+ return textResult(
349
+ jobResult(
350
+ await analysis.runCapability(target_id, "native:decompile", {
351
+ functionName: function_name
352
+ })
353
+ )
354
+ );
355
+ } catch (error) {
356
+ return errorResult(error);
357
+ }
358
+ }
359
+ );
360
+ mcp.registerTool(
361
+ "list_evidence",
362
+ {
363
+ title: "List evidence",
364
+ description: "List stored evidence files and summaries for a target.",
365
+ inputSchema: z.object({
366
+ target_id: z.string().uuid()
367
+ })
368
+ },
369
+ async ({ target_id }) => {
370
+ try {
371
+ return textResult(
372
+ await core.handle(CHANNELS.evidenceList, {
373
+ targetId: target_id
374
+ })
375
+ );
376
+ } catch (error) {
377
+ return errorResult(error);
378
+ }
379
+ }
380
+ );
381
+ mcp.registerTool(
382
+ "generate_report",
383
+ {
384
+ title: "Generate evidence report",
385
+ description: "Generate a Markdown report for an existing target and its current artifact.",
386
+ inputSchema: z.object({
387
+ target_id: z.string().uuid()
388
+ })
389
+ },
390
+ async ({ target_id }) => {
391
+ try {
392
+ return textResult(
393
+ jobResult(
394
+ await analysis.runCapability(
395
+ target_id,
396
+ "generate:report"
397
+ )
398
+ )
399
+ );
400
+ } catch (error) {
401
+ return errorResult(error);
402
+ }
403
+ }
404
+ );
405
+ mcp.registerTool(
406
+ "compare_versions",
407
+ {
408
+ title: "Compare two artifact versions",
409
+ description: "Compare routes, modules, assets, network candidates and technology hints between two analyzed artifacts of the same target.",
410
+ inputSchema: z.object({
411
+ target_id: z.string().uuid(),
412
+ left_artifact_id: z.string().uuid(),
413
+ right_artifact_id: z.string().uuid(),
414
+ force: z.boolean().optional()
415
+ })
416
+ },
417
+ async ({
418
+ target_id,
419
+ left_artifact_id,
420
+ right_artifact_id,
421
+ force
422
+ }) => {
423
+ try {
424
+ return textResult(
425
+ await new VersionComparisonService(core).compare(
426
+ target_id,
427
+ left_artifact_id,
428
+ right_artifact_id,
429
+ { force }
430
+ )
431
+ );
432
+ } catch (error) {
433
+ return errorResult(error);
434
+ }
435
+ }
436
+ );
437
+ mcp.registerTool(
438
+ "list_capabilities",
439
+ {
440
+ title: "List capabilities",
441
+ description: "List analysis capabilities available for the host and an optional target.",
442
+ inputSchema: z.object({
443
+ target_id: z.string().uuid().optional()
444
+ })
445
+ },
446
+ async ({ target_id }) => {
447
+ try {
448
+ return textResult(
449
+ await core.handle(CHANNELS.capabilitiesList, {
450
+ ...target_id ? { targetId: target_id } : {}
451
+ })
452
+ );
453
+ } catch (error) {
454
+ return errorResult(error);
455
+ }
456
+ }
457
+ );
458
+ const transport = new StdioServerTransport();
459
+ await mcp.connect(transport);
460
+ const close = async () => {
461
+ await mcp.close().catch(() => {
462
+ });
463
+ core.close();
464
+ };
465
+ process.once("SIGINT", () => void close().finally(() => process.exit(0)));
466
+ process.once("SIGTERM", () => void close().finally(() => process.exit(0)));
467
+ return mcp;
468
+ }
469
+ var invokedDirectly = isEntryPoint();
470
+ function isEntryPoint() {
471
+ if (!process.argv[1]) return false;
472
+ try {
473
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
474
+ } catch {
475
+ return false;
476
+ }
477
+ }
478
+ if (invokedDirectly) {
479
+ void startMcpServer().catch((error) => {
480
+ console.error(
481
+ `[apptrace-mcp] ${error instanceof Error ? error.stack ?? error.message : String(error)}`
482
+ );
483
+ process.exitCode = 1;
484
+ });
485
+ }
486
+ export {
487
+ startMcpServer
488
+ };
489
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {\n AppAnalysisService,\n CoreFailure,\n CoreServer,\n VersionComparisonService,\n loadConfig,\n type AnalysisGoal,\n type CoreConfig\n} from \"@zhuixin/metadata\";\nimport { CHANNELS } from \"@zhuixin/shared\";\nimport { McpServer } from \"@modelcontextprotocol/server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/server/stdio\";\nimport { realpathSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { randomUUID } from \"node:crypto\";\nimport { z } from \"zod\";\n\nconst GOALS = [\n \"tech_stack\",\n \"feature_map\",\n \"network\",\n \"native_risk\",\n \"report\"\n] as const satisfies readonly AnalysisGoal[];\n\nfunction errorResult(error: unknown) {\n const failure =\n error instanceof CoreFailure\n ? error\n : new CoreFailure(\n \"INTERNAL_ERROR\",\n error instanceof Error ? error.message : String(error)\n );\n const nextAction =\n failure.code === \"AUTH_REQUIRED\" || failure.code === \"KEYCHAIN_LOCKED\"\n ? \"运行 apptrace auth login,然后重试。\"\n : failure.code === \"LICENSE_REQUIRED\"\n ? \"请先在同一 Apple 账号的 App Store 获取该应用。\"\n : undefined;\n return {\n isError: true,\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(\n {\n code: failure.code,\n message: failure.message,\n details: failure.details,\n nextAction\n },\n null,\n 2\n )\n }\n ]\n };\n}\n\nfunction textResult(value: unknown) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: JSON.stringify(value, null, 2)\n }\n ],\n structuredContent: value as Record<string, unknown>\n };\n}\n\nfunction jobResult(job: Record<string, unknown>) {\n return {\n jobId: job.id,\n capabilityId: job.capabilityId,\n status: job.status,\n result: job.result,\n errorCode: job.errorCode,\n errorMessage: job.errorMessage\n };\n}\n\nexport async function startMcpServer(\n config: CoreConfig = loadConfig()\n): Promise<McpServer> {\n const core = new CoreServer({ config, emit: () => {} });\n core.store.interruptRunningAnalysisRuns();\n const analysis = new AppAnalysisService(core);\n const runs = new Map<\n string,\n {\n id: string;\n status: \"running\" | \"completed\" | \"failed\";\n startedAt: string;\n finishedAt?: string;\n result?: Record<string, unknown>;\n error?: { code: string; message: string; details?: unknown };\n promise: Promise<void>;\n }\n >();\n const mcp = new McpServer({\n name: \"apptrace\",\n version: \"0.1.0\"\n });\n\n mcp.registerTool(\n \"analyze_app\",\n {\n title: \"Analyze an application\",\n description:\n \"Resolve, acquire, inspect, extract and statically analyze an authorized app. Returns a compact evidence summary.\",\n inputSchema: z.object({\n source: z\n .string()\n .optional()\n .describe(\"App Store URL or numeric App Store ID\"),\n target_id: z\n .string()\n .uuid()\n .optional()\n .describe(\"Existing AppTrace target ID\"),\n goals: z\n .array(z.enum(GOALS))\n .optional()\n .describe(\"Analysis goals; defaults to tech stack, feature map and report\"),\n force: z\n .boolean()\n .optional()\n .describe(\"Re-run analyses even when matching evidence already exists\"),\n wait_seconds: z\n .number()\n .int()\n .min(0)\n .max(60)\n .optional()\n .describe(\"Seconds to wait before returning a running run_id\"),\n timeout_seconds: z.number().int().min(30).max(1800).optional()\n })\n },\n async (input) => {\n if (!input.source && !input.target_id) {\n return errorResult(\n new CoreFailure(\"SOURCE_REQUIRED\", \"请提供 source 或 target_id。\")\n );\n }\n try {\n const runId = randomUUID();\n const run: {\n id: string;\n status: \"running\" | \"completed\" | \"failed\";\n startedAt: string;\n finishedAt?: string;\n result?: Record<string, unknown>;\n error?: { code: string; message: string; details?: unknown };\n promise: Promise<void>;\n } = {\n id: runId,\n status: \"running\",\n startedAt: new Date().toISOString(),\n promise: Promise.resolve()\n };\n run.promise = analysis\n .analyzeApp({\n source: input.source,\n targetId: input.target_id,\n goals: input.goals,\n force: input.force,\n timeoutMs: (input.timeout_seconds ?? 1_200) * 1_000\n })\n .then((result) => {\n run.status = \"completed\";\n run.result = result as unknown as Record<string, unknown>;\n run.finishedAt = new Date().toISOString();\n core.store.upsertAnalysisRun({\n id: run.id,\n targetId: input.target_id,\n status: \"completed\",\n startedAt: run.startedAt,\n finishedAt: run.finishedAt,\n result: run.result,\n updatedAt: run.finishedAt\n });\n })\n .catch((error: unknown) => {\n const failure =\n error instanceof CoreFailure\n ? error\n : new CoreFailure(\n \"INTERNAL_ERROR\",\n error instanceof Error ? error.message : String(error)\n );\n run.status = \"failed\";\n run.error = {\n code: failure.code,\n message: failure.message,\n details: failure.details\n };\n run.finishedAt = new Date().toISOString();\n core.store.upsertAnalysisRun({\n id: run.id,\n targetId: input.target_id,\n status: \"failed\",\n startedAt: run.startedAt,\n finishedAt: run.finishedAt,\n error: run.error,\n updatedAt: run.finishedAt\n });\n });\n runs.set(runId, run);\n core.store.upsertAnalysisRun({\n id: runId,\n targetId: input.target_id,\n status: \"running\",\n startedAt: run.startedAt,\n updatedAt: run.startedAt\n });\n const waitSeconds = Math.max(0, input.wait_seconds ?? 10);\n await Promise.race([\n run.promise,\n new Promise((resolve) => setTimeout(resolve, waitSeconds * 1_000))\n ]);\n return textResult({\n runId,\n status: run.status,\n result: run.result,\n error: run.error,\n nextAction:\n run.status === \"running\"\n ? \"调用 get_analysis_run 继续等待或读取结果。\"\n : undefined\n });\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"get_analysis_run\",\n {\n title: \"Get asynchronous analysis run\",\n description:\n \"Wait for or retrieve the result of an analyze_app run.\",\n inputSchema: z.object({\n run_id: z.string().uuid(),\n wait_seconds: z.number().int().min(0).max(1800).optional()\n })\n },\n async ({ run_id, wait_seconds }) => {\n const run = runs.get(run_id);\n if (!run) {\n const stored = core.store.getAnalysisRun(run_id);\n return stored\n ? textResult(stored)\n : errorResult(\n new CoreFailure(\"ANALYSIS_RUN_NOT_FOUND\", \"分析运行不存在或已经超时。\")\n );\n }\n await Promise.race([\n run.promise,\n new Promise((resolve) =>\n setTimeout(resolve, Math.max(0, wait_seconds ?? 10) * 1_000)\n )\n ]);\n return textResult({\n runId: run.id,\n status: run.status,\n startedAt: run.startedAt,\n finishedAt: run.finishedAt,\n result: run.result,\n error: run.error\n });\n }\n );\n\n mcp.registerTool(\n \"list_targets\",\n {\n title: \"List application targets\",\n description: \"List all locally registered AppTrace targets.\",\n inputSchema: z.object({})\n },\n async () => {\n try {\n const targets = await core.handle(CHANNELS.targetsList, {});\n return textResult(targets);\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"auth_status\",\n {\n title: \"Apple account status\",\n description:\n \"Read the local App Store login state. Never returns passwords, 2FA codes or keychain secrets.\",\n inputSchema: z.object({})\n },\n async () => {\n try {\n const status = await core.handle(CHANNELS.accountStatus, {\n force: true\n });\n return textResult(status);\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"get_job\",\n {\n title: \"Get job status\",\n description: \"Return a job, its recent events and result.\",\n inputSchema: z.object({\n job_id: z.string().uuid()\n })\n },\n async ({ job_id }) => {\n try {\n const result = (await core.handle(CHANNELS.jobsGet, {\n jobId: job_id\n })) as {\n job: Record<string, unknown>;\n events: Array<Record<string, unknown>>;\n };\n return textResult({\n ...result,\n events: result.events.slice(-50)\n });\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"search_findings\",\n {\n title: \"Search structured findings\",\n description:\n \"Search persisted routes, modules, assets, endpoints, storage and native findings for a target.\",\n inputSchema: z.object({\n target_id: z.string().uuid(),\n query: z.string().trim().max(512).optional(),\n types: z\n .array(\n z.enum([\n \"technology\",\n \"route\",\n \"network_endpoint\",\n \"module\",\n \"asset\",\n \"storage\",\n \"native_procedure\",\n \"native_string\",\n \"risk\",\n \"limitation\"\n ])\n )\n .optional(),\n limit: z.number().int().min(1).max(1000).optional(),\n offset: z.number().int().min(0).optional()\n })\n },\n async (input) => {\n try {\n return textResult(\n await core.handle(CHANNELS.findingsSearch, {\n targetId: input.target_id,\n query: input.query,\n types: input.types,\n limit: input.limit,\n offset: input.offset\n })\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"search_native\",\n {\n title: \"Search native symbols\",\n description:\n \"Search native procedure names or strings. Use a returned procedure name with decompile_function.\",\n inputSchema: z.object({\n target_id: z.string().uuid(),\n query: z.string().trim().min(1).max(512),\n kind: z.enum([\"procedures\", \"strings\"]).optional(),\n mode: z.enum([\"literal\", \"regex\"]).optional()\n })\n },\n async ({ target_id, query, kind, mode }) => {\n try {\n return textResult(\n jobResult(\n (await analysis.runCapability(target_id, \"native:search\", {\n query,\n kind: kind ?? \"procedures\",\n mode: mode ?? \"literal\"\n })) as unknown as Record<string, unknown>\n )\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"decompile_function\",\n {\n title: \"Decompile one native function\",\n description:\n \"Decompile an exact function or symbol name returned by search_native. Encrypted targets are refused.\",\n inputSchema: z.object({\n target_id: z.string().uuid(),\n function_name: z\n .string()\n .trim()\n .min(1)\n .max(256)\n .regex(/^[A-Za-z_$][A-Za-z0-9_$.@:-]{0,255}$/)\n })\n },\n async ({ target_id, function_name }) => {\n try {\n return textResult(\n jobResult(\n (await analysis.runCapability(target_id, \"native:decompile\", {\n functionName: function_name\n })) as unknown as Record<string, unknown>\n )\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"list_evidence\",\n {\n title: \"List evidence\",\n description: \"List stored evidence files and summaries for a target.\",\n inputSchema: z.object({\n target_id: z.string().uuid()\n })\n },\n async ({ target_id }) => {\n try {\n return textResult(\n await core.handle(CHANNELS.evidenceList, {\n targetId: target_id\n })\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"generate_report\",\n {\n title: \"Generate evidence report\",\n description:\n \"Generate a Markdown report for an existing target and its current artifact.\",\n inputSchema: z.object({\n target_id: z.string().uuid()\n })\n },\n async ({ target_id }) => {\n try {\n return textResult(\n jobResult(\n (await analysis.runCapability(\n target_id,\n \"generate:report\"\n )) as unknown as Record<string, unknown>\n )\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"compare_versions\",\n {\n title: \"Compare two artifact versions\",\n description:\n \"Compare routes, modules, assets, network candidates and technology hints between two analyzed artifacts of the same target.\",\n inputSchema: z.object({\n target_id: z.string().uuid(),\n left_artifact_id: z.string().uuid(),\n right_artifact_id: z.string().uuid(),\n force: z.boolean().optional()\n })\n },\n async ({\n target_id,\n left_artifact_id,\n right_artifact_id,\n force\n }) => {\n try {\n return textResult(\n await new VersionComparisonService(core).compare(\n target_id,\n left_artifact_id,\n right_artifact_id,\n { force }\n )\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n mcp.registerTool(\n \"list_capabilities\",\n {\n title: \"List capabilities\",\n description:\n \"List analysis capabilities available for the host and an optional target.\",\n inputSchema: z.object({\n target_id: z.string().uuid().optional()\n })\n },\n async ({ target_id }) => {\n try {\n return textResult(\n await core.handle(CHANNELS.capabilitiesList, {\n ...(target_id ? { targetId: target_id } : {})\n })\n );\n } catch (error) {\n return errorResult(error);\n }\n }\n );\n\n const transport = new StdioServerTransport();\n await mcp.connect(transport);\n\n const close = async () => {\n await mcp.close().catch(() => {});\n core.close();\n };\n process.once(\"SIGINT\", () => void close().finally(() => process.exit(0)));\n process.once(\"SIGTERM\", () => void close().finally(() => process.exit(0)));\n\n return mcp;\n}\n\nconst invokedDirectly = isEntryPoint();\n\nfunction isEntryPoint(): boolean {\n if (!process.argv[1]) return false;\n try {\n // Compare real paths: /tmp and npm bin shims are symlinked on macOS/Linux,\n // and a string comparison silently prevents the server from starting.\n return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));\n } catch {\n return false;\n }\n}\nif (invokedDirectly) {\n void startMcpServer().catch((error) => {\n console.error(\n `[apptrace-mcp] ${\n error instanceof Error ? error.stack ?? error.message : String(error)\n }`\n );\n process.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AAA,YAC3C,GAAI,YAAY,EAAE,UAAU,UAAU,IAAI,CAAC;AAAA,UAC7C,CAAC;AAAA,QACH;AAAA,MACF,SAAS,OAAO;AACd,eAAO,YAAY,KAAK;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,IAAI,QAAQ,SAAS;AAE3B,QAAM,QAAQ,YAAY;AACxB,UAAM,IAAI,MAAM,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAChC,SAAK,MAAM;AAAA,EACb;AACA,UAAQ,KAAK,UAAU,MAAM,KAAK,MAAM,EAAE,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,CAAC;AACxE,UAAQ,KAAK,WAAW,MAAM,KAAK,MAAM,EAAE,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,CAAC;AAEzE,SAAO;AACT;AAEA,IAAM,kBAAkB,aAAa;AAErC,SAAS,eAAwB;AAC/B,MAAI,CAAC,QAAQ,KAAK,CAAC,EAAG,QAAO;AAC7B,MAAI;AAGF,WAAO,aAAa,QAAQ,KAAK,CAAC,CAAC,MAAM,aAAa,cAAc,YAAY,GAAG,CAAC;AAAA,EACtF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AACA,IAAI,iBAAiB;AACnB,OAAK,eAAe,EAAE,MAAM,CAAC,UAAU;AACrC,YAAQ;AAAA,MACN,kBACE,iBAAiB,QAAQ,MAAM,SAAS,MAAM,UAAU,OAAO,KAAK,CACtE;AAAA,IACF;AACA,YAAQ,WAAW;AAAA,EACrB,CAAC;AACH;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@zhuixin/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "license": "Apache-2.0",
5
+ "description": "AppTrace MCP server for evidence-backed application analysis",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/zhuixin-labs/app-evidence.git",
9
+ "directory": "packages/mcp"
10
+ },
11
+ "homepage": "https://github.com/zhuixin-labs/app-evidence",
12
+ "bugs": {
13
+ "url": "https://github.com/zhuixin-labs/app-evidence/issues"
14
+ },
15
+ "keywords": [
16
+ "mcp",
17
+ "ai-agents",
18
+ "app-analysis",
19
+ "model-context-protocol"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "engines": {
25
+ "node": ">=22.19"
26
+ },
27
+ "type": "module",
28
+ "main": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
36
+ "bin": {
37
+ "apptrace-mcp": "dist/index.js"
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "dependencies": {
43
+ "@modelcontextprotocol/server": "^2.3.1",
44
+ "zod": "^4.2.0",
45
+ "@zhuixin/shared": "0.1.1",
46
+ "@zhuixin/metadata": "0.1.1"
47
+ },
48
+ "devDependencies": {
49
+ "tsup": "^8.5.0"
50
+ },
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "typecheck": "tsc --noEmit -p tsconfig.json"
54
+ }
6
55
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.