@zhuixin/mcp 0.2.0 → 0.2.2
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/dist/index.js +115 -53
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// package.json
|
|
4
|
+
var version = "0.2.2";
|
|
5
|
+
|
|
3
6
|
// src/index.ts
|
|
4
7
|
import {
|
|
5
8
|
AppAnalysisService,
|
|
6
9
|
CoreFailure,
|
|
7
10
|
CoreServer,
|
|
8
11
|
VersionComparisonService,
|
|
9
|
-
loadConfig
|
|
12
|
+
loadConfig,
|
|
13
|
+
OnboardingService
|
|
10
14
|
} from "@zhuixin/metadata";
|
|
11
15
|
import { CHANNELS } from "@zhuixin/shared";
|
|
12
16
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
@@ -14,7 +18,51 @@ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
|
|
|
14
18
|
import { realpathSync } from "fs";
|
|
15
19
|
import { fileURLToPath } from "url";
|
|
16
20
|
import { randomUUID } from "crypto";
|
|
21
|
+
import { z as z2 } from "zod";
|
|
22
|
+
|
|
23
|
+
// src/onboarding.ts
|
|
17
24
|
import { z } from "zod";
|
|
25
|
+
function result(status) {
|
|
26
|
+
return { content: [{ type: "text", text: JSON.stringify(status) }], structuredContent: { ...status } };
|
|
27
|
+
}
|
|
28
|
+
function registerOnboarding(mcp, service) {
|
|
29
|
+
mcp.registerTool("prepare_environment", {
|
|
30
|
+
title: "Prepare AppTrace automatically",
|
|
31
|
+
description: "Install missing local analysis tools using the bundled installer. Returns promptly; poll get_setup_status. No Apple credentials are accepted. Retry only after diagnosing a previous failure.",
|
|
32
|
+
inputSchema: z.object({ retry: z.boolean().optional() })
|
|
33
|
+
}, async ({ retry }) => result(await service.prepare(retry)));
|
|
34
|
+
mcp.registerTool("get_setup_status", {
|
|
35
|
+
title: "Wait for environment and login readiness",
|
|
36
|
+
description: "Read persistent installation progress and safe Apple login status. Follow next_tool; when ready, resume the original analyze_app arguments without asking the user to repeat them.",
|
|
37
|
+
inputSchema: z.object({ wait_seconds: z.number().int().min(0).max(30).optional(), require_account: z.boolean().default(false).describe("Set true when waiting for Apple sign-in; local artifact analysis needs no account.") })
|
|
38
|
+
}, async ({ wait_seconds, require_account }) => {
|
|
39
|
+
const deadline = Date.now() + (wait_seconds ?? 0) * 1e3;
|
|
40
|
+
const check = () => service.status(require_account, (wait_seconds ?? 0) > 0 ? Math.max(1, Math.min(5e3, deadline - Date.now())) : 5e3);
|
|
41
|
+
let status = await check();
|
|
42
|
+
while (["installing", "login_pending"].includes(status.state) && Date.now() < deadline) {
|
|
43
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(2e3, deadline - Date.now())));
|
|
44
|
+
if (Date.now() >= deadline) break;
|
|
45
|
+
status = await check();
|
|
46
|
+
}
|
|
47
|
+
return result(status);
|
|
48
|
+
});
|
|
49
|
+
mcp.registerTool("open_login", {
|
|
50
|
+
title: "Open local Apple sign-in window",
|
|
51
|
+
description: "Open a visible Windows sign-in terminal for the user. Reuses an active sign-in window. Credentials and terminal output never enter MCP. Poll get_setup_status afterwards, then resume the original analysis. Other hosts return a local-terminal fallback.",
|
|
52
|
+
inputSchema: z.object({})
|
|
53
|
+
}, async () => result(await service.openLogin()));
|
|
54
|
+
}
|
|
55
|
+
function setupResponse(status, input) {
|
|
56
|
+
return {
|
|
57
|
+
status: "awaiting_setup",
|
|
58
|
+
setup: status,
|
|
59
|
+
next_tool: status.next_tool,
|
|
60
|
+
resume: { tool: "analyze_app", arguments: input },
|
|
61
|
+
nextAction: "Agent \u5E94\u6309 next_tool \u7EE7\u7EED\u51C6\u5907\uFF1Bready \u540E\u7528 resume.arguments \u91CD\u53D1 analyze_app\u3002\u65E0\u9700\u7528\u6237\u91CD\u590D\u9700\u6C42\uFF1B\u4E0D\u8981\u5411\u7528\u6237\u7D22\u53D6\u51ED\u636E\u3002"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/index.ts
|
|
18
66
|
var GOALS = [
|
|
19
67
|
"tech_stack",
|
|
20
68
|
"feature_map",
|
|
@@ -27,7 +75,7 @@ function errorResult(error) {
|
|
|
27
75
|
"INTERNAL_ERROR",
|
|
28
76
|
error instanceof Error ? error.message : String(error)
|
|
29
77
|
);
|
|
30
|
-
const nextAction = failure.code === "AUTH_REQUIRED" || failure.code === "KEYCHAIN_LOCKED" ? "\
|
|
78
|
+
const nextAction = failure.code === "AUTH_REQUIRED" || failure.code === "KEYCHAIN_LOCKED" ? "\u8C03\u7528 open_login\uFF0C\u968F\u540E\u901A\u8FC7 get_setup_status \u7B49\u5F85\uFF0C\u518D\u6062\u590D\u539F\u8BF7\u6C42\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
79
|
return {
|
|
32
80
|
isError: true,
|
|
33
81
|
content: [
|
|
@@ -76,20 +124,22 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
76
124
|
const runs = /* @__PURE__ */ new Map();
|
|
77
125
|
const mcp = new McpServer({
|
|
78
126
|
name: "apptrace",
|
|
79
|
-
version
|
|
127
|
+
version
|
|
80
128
|
});
|
|
129
|
+
const onboarding = new OnboardingService(config);
|
|
130
|
+
registerOnboarding(mcp, onboarding);
|
|
81
131
|
mcp.registerTool(
|
|
82
132
|
"analyze_app",
|
|
83
133
|
{
|
|
84
134
|
title: "Analyze an application",
|
|
85
|
-
description: "
|
|
86
|
-
inputSchema:
|
|
87
|
-
source:
|
|
88
|
-
target_id:
|
|
89
|
-
goals:
|
|
90
|
-
force:
|
|
91
|
-
wait_seconds:
|
|
92
|
-
timeout_seconds:
|
|
135
|
+
description: "Analyze an authorized app. Automatically prepares missing tools and opens a local Windows login window when needed. awaiting_setup preserves resume.arguments: follow next_tool and retry when ready. Never request credentials in chat.",
|
|
136
|
+
inputSchema: z2.object({
|
|
137
|
+
source: z2.string().optional().describe("App Store URL or numeric App Store ID"),
|
|
138
|
+
target_id: z2.string().uuid().optional().describe("Existing AppTrace target ID"),
|
|
139
|
+
goals: z2.array(z2.enum(GOALS)).optional().describe("Analysis goals; defaults to tech stack, feature map and report"),
|
|
140
|
+
force: z2.boolean().optional().describe("Re-run analyses even when matching evidence already exists"),
|
|
141
|
+
wait_seconds: z2.number().int().min(0).max(60).optional().describe("Seconds to wait before returning a running run_id"),
|
|
142
|
+
timeout_seconds: z2.number().int().min(30).max(1800).optional()
|
|
93
143
|
})
|
|
94
144
|
},
|
|
95
145
|
async (input) => {
|
|
@@ -99,6 +149,18 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
99
149
|
);
|
|
100
150
|
}
|
|
101
151
|
try {
|
|
152
|
+
const tools = await onboarding.status(false);
|
|
153
|
+
if (tools.state !== "ready") {
|
|
154
|
+
return textResult(setupResponse(tools.state === "tools_missing" ? await onboarding.prepare() : tools, input));
|
|
155
|
+
}
|
|
156
|
+
const prepared = await analysis.prepareTarget({ source: input.source, targetId: input.target_id });
|
|
157
|
+
if (prepared.requiresAccount) {
|
|
158
|
+
const status = await onboarding.status();
|
|
159
|
+
if (status.state !== "ready") {
|
|
160
|
+
const next = ["login_required", "keychain_locked"].includes(status.state) ? await onboarding.openLogin() : status;
|
|
161
|
+
return textResult(setupResponse(next, input));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
102
164
|
const runId = randomUUID();
|
|
103
165
|
const run = {
|
|
104
166
|
id: runId,
|
|
@@ -108,17 +170,17 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
108
170
|
};
|
|
109
171
|
run.promise = analysis.analyzeApp({
|
|
110
172
|
source: input.source,
|
|
111
|
-
targetId:
|
|
173
|
+
targetId: prepared.targetId,
|
|
112
174
|
goals: input.goals,
|
|
113
175
|
force: input.force,
|
|
114
176
|
timeoutMs: (input.timeout_seconds ?? 1200) * 1e3
|
|
115
|
-
}).then((
|
|
177
|
+
}).then((result2) => {
|
|
116
178
|
run.status = "completed";
|
|
117
|
-
run.result =
|
|
179
|
+
run.result = result2;
|
|
118
180
|
run.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
119
181
|
core.store.upsertAnalysisRun({
|
|
120
182
|
id: run.id,
|
|
121
|
-
targetId:
|
|
183
|
+
targetId: prepared.targetId,
|
|
122
184
|
status: "completed",
|
|
123
185
|
startedAt: run.startedAt,
|
|
124
186
|
finishedAt: run.finishedAt,
|
|
@@ -139,7 +201,7 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
139
201
|
run.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
140
202
|
core.store.upsertAnalysisRun({
|
|
141
203
|
id: run.id,
|
|
142
|
-
targetId:
|
|
204
|
+
targetId: prepared.targetId,
|
|
143
205
|
status: "failed",
|
|
144
206
|
startedAt: run.startedAt,
|
|
145
207
|
finishedAt: run.finishedAt,
|
|
@@ -150,7 +212,7 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
150
212
|
runs.set(runId, run);
|
|
151
213
|
core.store.upsertAnalysisRun({
|
|
152
214
|
id: runId,
|
|
153
|
-
targetId:
|
|
215
|
+
targetId: prepared.targetId,
|
|
154
216
|
status: "running",
|
|
155
217
|
startedAt: run.startedAt,
|
|
156
218
|
updatedAt: run.startedAt
|
|
@@ -177,9 +239,9 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
177
239
|
{
|
|
178
240
|
title: "Get asynchronous analysis run",
|
|
179
241
|
description: "Wait for or retrieve the result of an analyze_app run.",
|
|
180
|
-
inputSchema:
|
|
181
|
-
run_id:
|
|
182
|
-
wait_seconds:
|
|
242
|
+
inputSchema: z2.object({
|
|
243
|
+
run_id: z2.string().uuid(),
|
|
244
|
+
wait_seconds: z2.number().int().min(0).max(1800).optional()
|
|
183
245
|
})
|
|
184
246
|
},
|
|
185
247
|
async ({ run_id, wait_seconds }) => {
|
|
@@ -211,7 +273,7 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
211
273
|
{
|
|
212
274
|
title: "List application targets",
|
|
213
275
|
description: "List all locally registered AppTrace targets.",
|
|
214
|
-
inputSchema:
|
|
276
|
+
inputSchema: z2.object({})
|
|
215
277
|
},
|
|
216
278
|
async () => {
|
|
217
279
|
try {
|
|
@@ -227,7 +289,7 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
227
289
|
{
|
|
228
290
|
title: "Apple account status",
|
|
229
291
|
description: "Read the local App Store login state. Never returns passwords, 2FA codes or keychain secrets.",
|
|
230
|
-
inputSchema:
|
|
292
|
+
inputSchema: z2.object({})
|
|
231
293
|
},
|
|
232
294
|
async () => {
|
|
233
295
|
try {
|
|
@@ -245,18 +307,18 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
245
307
|
{
|
|
246
308
|
title: "Get job status",
|
|
247
309
|
description: "Return a job, its recent events and result.",
|
|
248
|
-
inputSchema:
|
|
249
|
-
job_id:
|
|
310
|
+
inputSchema: z2.object({
|
|
311
|
+
job_id: z2.string().uuid()
|
|
250
312
|
})
|
|
251
313
|
},
|
|
252
314
|
async ({ job_id }) => {
|
|
253
315
|
try {
|
|
254
|
-
const
|
|
316
|
+
const result2 = await core.handle(CHANNELS.jobsGet, {
|
|
255
317
|
jobId: job_id
|
|
256
318
|
});
|
|
257
319
|
return textResult({
|
|
258
|
-
...
|
|
259
|
-
events:
|
|
320
|
+
...result2,
|
|
321
|
+
events: result2.events.slice(-50)
|
|
260
322
|
});
|
|
261
323
|
} catch (error) {
|
|
262
324
|
return errorResult(error);
|
|
@@ -268,11 +330,11 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
268
330
|
{
|
|
269
331
|
title: "Search structured findings",
|
|
270
332
|
description: "Search persisted routes, modules, assets, endpoints, storage and native findings for a target.",
|
|
271
|
-
inputSchema:
|
|
272
|
-
target_id:
|
|
273
|
-
query:
|
|
274
|
-
types:
|
|
275
|
-
|
|
333
|
+
inputSchema: z2.object({
|
|
334
|
+
target_id: z2.string().uuid(),
|
|
335
|
+
query: z2.string().trim().max(512).optional(),
|
|
336
|
+
types: z2.array(
|
|
337
|
+
z2.enum([
|
|
276
338
|
"technology",
|
|
277
339
|
"route",
|
|
278
340
|
"network_endpoint",
|
|
@@ -285,8 +347,8 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
285
347
|
"limitation"
|
|
286
348
|
])
|
|
287
349
|
).optional(),
|
|
288
|
-
limit:
|
|
289
|
-
offset:
|
|
350
|
+
limit: z2.number().int().min(1).max(1e3).optional(),
|
|
351
|
+
offset: z2.number().int().min(0).optional()
|
|
290
352
|
})
|
|
291
353
|
},
|
|
292
354
|
async (input) => {
|
|
@@ -310,11 +372,11 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
310
372
|
{
|
|
311
373
|
title: "Search native symbols",
|
|
312
374
|
description: "Search native procedure names or strings. Use a returned procedure name with decompile_function.",
|
|
313
|
-
inputSchema:
|
|
314
|
-
target_id:
|
|
315
|
-
query:
|
|
316
|
-
kind:
|
|
317
|
-
mode:
|
|
375
|
+
inputSchema: z2.object({
|
|
376
|
+
target_id: z2.string().uuid(),
|
|
377
|
+
query: z2.string().trim().min(1).max(512),
|
|
378
|
+
kind: z2.enum(["procedures", "strings"]).optional(),
|
|
379
|
+
mode: z2.enum(["literal", "regex"]).optional()
|
|
318
380
|
})
|
|
319
381
|
},
|
|
320
382
|
async ({ target_id, query, kind, mode }) => {
|
|
@@ -338,9 +400,9 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
338
400
|
{
|
|
339
401
|
title: "Decompile one native function",
|
|
340
402
|
description: "Decompile an exact function or symbol name returned by search_native. Encrypted targets are refused.",
|
|
341
|
-
inputSchema:
|
|
342
|
-
target_id:
|
|
343
|
-
function_name:
|
|
403
|
+
inputSchema: z2.object({
|
|
404
|
+
target_id: z2.string().uuid(),
|
|
405
|
+
function_name: z2.string().trim().min(1).max(256).regex(/^[A-Za-z_$][A-Za-z0-9_$.@:-]{0,255}$/)
|
|
344
406
|
})
|
|
345
407
|
},
|
|
346
408
|
async ({ target_id, function_name }) => {
|
|
@@ -362,8 +424,8 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
362
424
|
{
|
|
363
425
|
title: "List evidence",
|
|
364
426
|
description: "List stored evidence files and summaries for a target.",
|
|
365
|
-
inputSchema:
|
|
366
|
-
target_id:
|
|
427
|
+
inputSchema: z2.object({
|
|
428
|
+
target_id: z2.string().uuid()
|
|
367
429
|
})
|
|
368
430
|
},
|
|
369
431
|
async ({ target_id }) => {
|
|
@@ -383,8 +445,8 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
383
445
|
{
|
|
384
446
|
title: "Generate evidence report",
|
|
385
447
|
description: "Generate a Markdown report for an existing target and its current artifact.",
|
|
386
|
-
inputSchema:
|
|
387
|
-
target_id:
|
|
448
|
+
inputSchema: z2.object({
|
|
449
|
+
target_id: z2.string().uuid()
|
|
388
450
|
})
|
|
389
451
|
},
|
|
390
452
|
async ({ target_id }) => {
|
|
@@ -407,11 +469,11 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
407
469
|
{
|
|
408
470
|
title: "Compare two artifact versions",
|
|
409
471
|
description: "Compare routes, modules, assets, network candidates and technology hints between two analyzed artifacts of the same target.",
|
|
410
|
-
inputSchema:
|
|
411
|
-
target_id:
|
|
412
|
-
left_artifact_id:
|
|
413
|
-
right_artifact_id:
|
|
414
|
-
force:
|
|
472
|
+
inputSchema: z2.object({
|
|
473
|
+
target_id: z2.string().uuid(),
|
|
474
|
+
left_artifact_id: z2.string().uuid(),
|
|
475
|
+
right_artifact_id: z2.string().uuid(),
|
|
476
|
+
force: z2.boolean().optional()
|
|
415
477
|
})
|
|
416
478
|
},
|
|
417
479
|
async ({
|
|
@@ -439,8 +501,8 @@ async function startMcpServer(config = loadConfig()) {
|
|
|
439
501
|
{
|
|
440
502
|
title: "List capabilities",
|
|
441
503
|
description: "List analysis capabilities available for the host and an optional target.",
|
|
442
|
-
inputSchema:
|
|
443
|
-
target_id:
|
|
504
|
+
inputSchema: z2.object({
|
|
505
|
+
target_id: z2.string().uuid().optional()
|
|
444
506
|
})
|
|
445
507
|
},
|
|
446
508
|
async ({ target_id }) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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.exitCode = 1;\n });\n}\n"],"mappings":";;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,SAAS;AAElB,IAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,YAAY,OAAgB;AACnC,QAAM,UACJ,iBAAiB,cACb,QACA,IAAI;AAAA,IACF;AAAA,IACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EACvD;AACN,QAAM,aACJ,QAAQ,SAAS,mBAAmB,QAAQ,SAAS,oBACjD,yEACA,QAAQ,SAAS,qBACf,2GACA;AACR,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,UACT;AAAA,YACE,MAAM,QAAQ;AAAA,YACd,SAAS,QAAQ;AAAA,YACjB,SAAS,QAAQ;AAAA,YACjB;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,WAAW,OAAgB;AAClC,SAAO;AAAA,IACL,SAAS;AAAA,MACP;AAAA,QACE,MAAM;AAAA,QACN,MAAM,KAAK,UAAU,OAAO,MAAM,CAAC;AAAA,MACrC;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,EACrB;AACF;AAEA,SAAS,UAAU,KAA8B;AAC/C,SAAO;AAAA,IACL,OAAO,IAAI;AAAA,IACX,cAAc,IAAI;AAAA,IAClB,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CAAC;AAAA,IACH;AAAA,IACA,OAAO,EAAE,UAAU,MAAM;AACvB,UAAI;AACF,eAAO;AAAA,UACL,MAAM,KAAK,OAAO,SAAS,kBAAkB;AAAA,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":[]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/index.ts","../src/onboarding.ts"],"sourcesContent":["{\n \"name\": \"@zhuixin/mcp\",\n \"version\": \"0.2.2\",\n \"license\": \"Apache-2.0\",\n \"description\": \"AppTrace MCP server for evidence-backed application analysis\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/zhuixin-labs/app-evidence.git\",\n \"directory\": \"packages/mcp\"\n },\n \"homepage\": \"https://github.com/zhuixin-labs/app-evidence\",\n \"bugs\": {\"url\": \"https://github.com/zhuixin-labs/app-evidence/issues\"},\n \"keywords\": [\"mcp\", \"ai-agents\", \"app-analysis\", \"model-context-protocol\"],\n \"publishConfig\": {\"access\": \"public\"},\n \"engines\": {\"node\": \">=22.19\"},\n \"type\": \"module\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n }\n },\n \"bin\": {\n \"apptrace-mcp\": \"dist/index.js\"\n },\n \"files\": [\"dist\"],\n \"scripts\": {\n \"build\": \"tsup\",\n \"typecheck\": \"tsc --noEmit -p tsconfig.json\"\n },\n \"dependencies\": {\n \"@zhuixin/metadata\": \"workspace:*\",\n \"@zhuixin/shared\": \"workspace:*\",\n \"@modelcontextprotocol/server\": \"^2.3.1\",\n \"zod\": \"^4.2.0\"\n },\n \"devDependencies\": {\n \"tsup\": \"^8.5.0\"\n }\n}\n","#!/usr/bin/env node\nimport { version } from \"../package.json\";\nimport {\n AppAnalysisService,\n CoreFailure,\n CoreServer,\n VersionComparisonService,\n loadConfig,\n OnboardingService,\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\";\nimport { registerOnboarding, setupResponse } from \"./onboarding.js\";\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 ? \"调用 open_login,随后通过 get_setup_status 等待,再恢复原请求。\"\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\n });\n const onboarding = new OnboardingService(config);\n registerOnboarding(mcp, onboarding);\n\n mcp.registerTool(\n \"analyze_app\",\n {\n title: \"Analyze an application\",\n description:\n \"Analyze an authorized app. Automatically prepares missing tools and opens a local Windows login window when needed. awaiting_setup preserves resume.arguments: follow next_tool and retry when ready. Never request credentials in chat.\",\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 tools = await onboarding.status(false);\n if (tools.state !== \"ready\") {\n return textResult(setupResponse(tools.state === \"tools_missing\" ? await onboarding.prepare() : tools, input));\n }\n const prepared = await analysis.prepareTarget({ source: input.source, targetId: input.target_id });\n if (prepared.requiresAccount) {\n const status = await onboarding.status();\n if (status.state !== \"ready\") {\n const next = [\"login_required\", \"keychain_locked\"].includes(status.state) ? await onboarding.openLogin() : status;\n return textResult(setupResponse(next, input));\n }\n }\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: prepared.targetId,\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: prepared.targetId,\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: prepared.targetId,\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: prepared.targetId,\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.exitCode = 1;\n });\n}\n","import { OnboardingService, type SetupStatus } from \"@zhuixin/metadata\";\nimport type { McpServer } from \"@modelcontextprotocol/server\";\nimport { z } from \"zod\";\n\nfunction result(status: SetupStatus) {\n return { content: [{ type: \"text\" as const, text: JSON.stringify(status) }], structuredContent: { ...status } };\n}\n\nexport function registerOnboarding(mcp: McpServer, service: OnboardingService): void {\n mcp.registerTool(\"prepare_environment\", {\n title: \"Prepare AppTrace automatically\",\n description: \"Install missing local analysis tools using the bundled installer. Returns promptly; poll get_setup_status. No Apple credentials are accepted. Retry only after diagnosing a previous failure.\",\n inputSchema: z.object({ retry: z.boolean().optional() })\n }, async ({ retry }) => result(await service.prepare(retry)));\n mcp.registerTool(\"get_setup_status\", {\n title: \"Wait for environment and login readiness\",\n description: \"Read persistent installation progress and safe Apple login status. Follow next_tool; when ready, resume the original analyze_app arguments without asking the user to repeat them.\",\n inputSchema: z.object({ wait_seconds: z.number().int().min(0).max(30).optional(), require_account: z.boolean().default(false).describe(\"Set true when waiting for Apple sign-in; local artifact analysis needs no account.\") })\n }, async ({ wait_seconds, require_account }) => {\n const deadline = Date.now() + (wait_seconds ?? 0) * 1000;\n const check = () => service.status(require_account, (wait_seconds ?? 0) > 0\n ? Math.max(1, Math.min(5000, deadline - Date.now())) : 5000);\n let status = await check();\n while ([\"installing\", \"login_pending\"].includes(status.state) && Date.now() < deadline) {\n await new Promise(resolve => setTimeout(resolve, Math.min(2000, deadline - Date.now())));\n if (Date.now() >= deadline) break;\n status = await check();\n }\n return result(status);\n });\n mcp.registerTool(\"open_login\", {\n title: \"Open local Apple sign-in window\",\n description: \"Open a visible Windows sign-in terminal for the user. Reuses an active sign-in window. Credentials and terminal output never enter MCP. Poll get_setup_status afterwards, then resume the original analysis. Other hosts return a local-terminal fallback.\",\n inputSchema: z.object({})\n }, async () => result(await service.openLogin()));\n}\n\nexport function setupResponse(status: SetupStatus, input: Record<string, unknown>) {\n return {\n status: \"awaiting_setup\",\n setup: status,\n next_tool: status.next_tool,\n resume: { tool: \"analyze_app\", arguments: input },\n nextAction: \"Agent 应按 next_tool 继续准备;ready 后用 resume.arguments 重发 analyze_app。无需用户重复需求;不要向用户索取凭据。\"\n };\n}\n"],"mappings":";;;AAEE,cAAW;;;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Q,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":["z","z","result"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhuixin/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "AppTrace MCP server for evidence-backed application analysis",
|
|
6
6
|
"repository": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
44
44
|
"zod": "^4.2.0",
|
|
45
|
-
"@zhuixin/metadata": "0.2.
|
|
46
|
-
"@zhuixin/shared": "0.2.
|
|
45
|
+
"@zhuixin/metadata": "0.2.2",
|
|
46
|
+
"@zhuixin/shared": "0.2.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"tsup": "^8.5.0"
|