@prontiq/ariscan-mcp 0.35.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 +95 -0
- package/dist/cli.js +302 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.js +256 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Prontiq
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
14
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
15
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
16
|
+
the limitations and conditions below.
|
|
17
|
+
|
|
18
|
+
## Limitations
|
|
19
|
+
|
|
20
|
+
You may not provide the software to third parties as a hosted or managed
|
|
21
|
+
service, where the service provides users with access to any substantial set of
|
|
22
|
+
the features or functionality of the software.
|
|
23
|
+
|
|
24
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
25
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
26
|
+
software that is protected by the license key.
|
|
27
|
+
|
|
28
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
29
|
+
of the licensor in the software. Any use of the licensor's trademarks is subject
|
|
30
|
+
to applicable law.
|
|
31
|
+
|
|
32
|
+
## Patents
|
|
33
|
+
|
|
34
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
35
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
36
|
+
sale, import and have imported the software, in each case subject to the
|
|
37
|
+
limitations and conditions in this license. This license does not cover any
|
|
38
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
39
|
+
the software. If you or your company make any written claim that the software
|
|
40
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
41
|
+
the software granted under these terms ends immediately. If your company makes
|
|
42
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
43
|
+
company.
|
|
44
|
+
|
|
45
|
+
## Notices
|
|
46
|
+
|
|
47
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
48
|
+
also gets a copy of these terms.
|
|
49
|
+
|
|
50
|
+
If you modify the software, you must include in any modified copies of the
|
|
51
|
+
software prominent notices stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
## No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
56
|
+
these terms.
|
|
57
|
+
|
|
58
|
+
## Termination
|
|
59
|
+
|
|
60
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
61
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
62
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
63
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
64
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
65
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
66
|
+
to terminate automatically and permanently.
|
|
67
|
+
|
|
68
|
+
## No Liability
|
|
69
|
+
|
|
70
|
+
As far as the law allows, the software comes as is, without any warranty or
|
|
71
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
72
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
73
|
+
legal claim.
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
78
|
+
software the licensor makes available under these terms, including any portion
|
|
79
|
+
of it.
|
|
80
|
+
|
|
81
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
84
|
+
organization that you work for, plus all organizations that have control over,
|
|
85
|
+
are under the control of, or are under common control with that
|
|
86
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
87
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
88
|
+
otherwise. Control can be direct or indirect.
|
|
89
|
+
|
|
90
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
91
|
+
these terms.
|
|
92
|
+
|
|
93
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
94
|
+
|
|
95
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { resolve } from "path";
|
|
5
|
+
|
|
6
|
+
// src/server.ts
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { scan, analyzeTokenBudget, createRepoContext } from "@prontiq/ariscan-engine";
|
|
10
|
+
|
|
11
|
+
// src/resources/score.ts
|
|
12
|
+
function extractScore(result) {
|
|
13
|
+
return {
|
|
14
|
+
score: result.score,
|
|
15
|
+
level: result.level,
|
|
16
|
+
levelMeta: result.levelMeta,
|
|
17
|
+
securityGateTriggered: result.securityGateTriggered,
|
|
18
|
+
metadata: {
|
|
19
|
+
version: result.metadata.version,
|
|
20
|
+
timestamp: result.metadata.timestamp,
|
|
21
|
+
duration: result.metadata.duration,
|
|
22
|
+
repoPath: result.metadata.repoPath
|
|
23
|
+
},
|
|
24
|
+
...result.scoreBreakdown ? { scoreBreakdown: result.scoreBreakdown } : {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/resources/pillars.ts
|
|
29
|
+
function extractPillars(result) {
|
|
30
|
+
return {
|
|
31
|
+
pillars: result.pillars.map((p) => ({
|
|
32
|
+
pillar: p.pillar,
|
|
33
|
+
name: p.name,
|
|
34
|
+
score: p.score,
|
|
35
|
+
weight: p.weight,
|
|
36
|
+
confidence: p.confidence,
|
|
37
|
+
...p.status ? { status: p.status } : {},
|
|
38
|
+
summary: p.summary,
|
|
39
|
+
...p.dataStatus ? { dataStatus: p.dataStatus } : {},
|
|
40
|
+
findingCount: p.findings.length,
|
|
41
|
+
findings: p.findings.map((f) => ({
|
|
42
|
+
code: f.code,
|
|
43
|
+
severity: f.severity,
|
|
44
|
+
message: f.message,
|
|
45
|
+
...f.confidence ? { confidence: f.confidence } : {},
|
|
46
|
+
...f.applicability ? { applicability: f.applicability } : {},
|
|
47
|
+
...f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}
|
|
48
|
+
}))
|
|
49
|
+
}))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/resources/recommendations.ts
|
|
54
|
+
function extractRecommendations(result) {
|
|
55
|
+
const actionable = result.findings.filter((f) => f.remediation && !f.suppressed).sort((a, b) => {
|
|
56
|
+
const deltaA = a.scoreImpact?.compositeDelta ?? 0;
|
|
57
|
+
const deltaB = b.scoreImpact?.compositeDelta ?? 0;
|
|
58
|
+
return deltaB - deltaA;
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
recommendations: actionable.map((f) => ({
|
|
62
|
+
code: f.code,
|
|
63
|
+
pillar: f.pillar,
|
|
64
|
+
severity: f.severity,
|
|
65
|
+
message: f.message,
|
|
66
|
+
...f.remediation ? {
|
|
67
|
+
remediation: {
|
|
68
|
+
action: f.remediation.action,
|
|
69
|
+
description: f.remediation.description,
|
|
70
|
+
...f.remediation.estimatedImpact ? { estimatedImpact: f.remediation.estimatedImpact } : {},
|
|
71
|
+
confidence: f.remediation.confidence
|
|
72
|
+
}
|
|
73
|
+
} : {},
|
|
74
|
+
...f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}
|
|
75
|
+
}))
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/resources/context-files.ts
|
|
80
|
+
function extractContextFiles(result) {
|
|
81
|
+
return {
|
|
82
|
+
contextFiles: (result.contextFiles ?? []).map((cf) => ({
|
|
83
|
+
path: cf.path,
|
|
84
|
+
type: cf.type,
|
|
85
|
+
...cf.size != null ? { size: cf.size } : {},
|
|
86
|
+
...cf.lineCount != null ? { lineCount: cf.lineCount } : {},
|
|
87
|
+
...cf.lastModified ? { lastModified: cf.lastModified } : {},
|
|
88
|
+
...cf.parseStatus ? { parseStatus: cf.parseStatus } : {}
|
|
89
|
+
}))
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/resources/budget.ts
|
|
94
|
+
function extractBudget(budget) {
|
|
95
|
+
return {
|
|
96
|
+
totalTokens: budget.totalTokens,
|
|
97
|
+
totalFiles: budget.totalFiles,
|
|
98
|
+
totalBytes: budget.totalBytes,
|
|
99
|
+
categories: budget.byCategory.map((c) => ({
|
|
100
|
+
category: c.category,
|
|
101
|
+
fileCount: c.fileCount,
|
|
102
|
+
totalBytes: c.totalBytes,
|
|
103
|
+
totalTokens: c.totalTokens,
|
|
104
|
+
percentage: c.percentage
|
|
105
|
+
})),
|
|
106
|
+
hotspots: budget.hotspots.map((h) => ({
|
|
107
|
+
path: h.path,
|
|
108
|
+
category: h.category,
|
|
109
|
+
estimatedTokens: h.estimatedTokens
|
|
110
|
+
})),
|
|
111
|
+
recommendations: budget.recommendations.map((r) => ({
|
|
112
|
+
description: r.description,
|
|
113
|
+
targetFiles: r.targetFiles,
|
|
114
|
+
estimatedSavingsTokens: r.estimatedSavingsTokens,
|
|
115
|
+
priority: r.priority
|
|
116
|
+
}))
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/server.ts
|
|
121
|
+
function createMcpServer(config) {
|
|
122
|
+
const { repoPath: repoPath2, cacheTtlMs: cacheTtlMs2 = 3e5, scanTimeoutMs: scanTimeoutMs2 = 6e4 } = config;
|
|
123
|
+
const server = new McpServer(
|
|
124
|
+
{
|
|
125
|
+
name: "ariscan",
|
|
126
|
+
version: "0.35.0"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
capabilities: {
|
|
130
|
+
resources: {}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
let cached = null;
|
|
135
|
+
async function getScanResult() {
|
|
136
|
+
const now = Date.now();
|
|
137
|
+
if (cached && now - cached.timestamp < cacheTtlMs2) {
|
|
138
|
+
return cached;
|
|
139
|
+
}
|
|
140
|
+
const doScan = async () => {
|
|
141
|
+
const result = await scan(repoPath2);
|
|
142
|
+
const context = await createRepoContext(repoPath2);
|
|
143
|
+
const budget = await analyzeTokenBudget(context);
|
|
144
|
+
return { result, budget, timestamp: Date.now() };
|
|
145
|
+
};
|
|
146
|
+
let timer;
|
|
147
|
+
cached = await Promise.race([
|
|
148
|
+
doScan(),
|
|
149
|
+
new Promise((_, reject) => {
|
|
150
|
+
timer = setTimeout(
|
|
151
|
+
() => reject(new Error(`Scan timed out after ${scanTimeoutMs2}ms`)),
|
|
152
|
+
scanTimeoutMs2
|
|
153
|
+
);
|
|
154
|
+
})
|
|
155
|
+
]).finally(() => {
|
|
156
|
+
if (timer) clearTimeout(timer);
|
|
157
|
+
});
|
|
158
|
+
return cached;
|
|
159
|
+
}
|
|
160
|
+
server.resource(
|
|
161
|
+
"readiness-score",
|
|
162
|
+
"readiness://score",
|
|
163
|
+
{ description: "Composite ARI score and maturity level" },
|
|
164
|
+
async () => {
|
|
165
|
+
const { result } = await getScanResult();
|
|
166
|
+
return {
|
|
167
|
+
contents: [
|
|
168
|
+
{
|
|
169
|
+
uri: "readiness://score",
|
|
170
|
+
mimeType: "application/json",
|
|
171
|
+
text: JSON.stringify(extractScore(result), null, 2)
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
server.resource(
|
|
178
|
+
"readiness-pillars",
|
|
179
|
+
"readiness://pillars",
|
|
180
|
+
{ description: "Per-pillar scores, findings, and summaries" },
|
|
181
|
+
async () => {
|
|
182
|
+
const { result } = await getScanResult();
|
|
183
|
+
return {
|
|
184
|
+
contents: [
|
|
185
|
+
{
|
|
186
|
+
uri: "readiness://pillars",
|
|
187
|
+
mimeType: "application/json",
|
|
188
|
+
text: JSON.stringify(extractPillars(result), null, 2)
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
server.resource(
|
|
195
|
+
"readiness-recommendations",
|
|
196
|
+
"readiness://recommendations",
|
|
197
|
+
{ description: "Prioritized action items sorted by score impact" },
|
|
198
|
+
async () => {
|
|
199
|
+
const { result } = await getScanResult();
|
|
200
|
+
return {
|
|
201
|
+
contents: [
|
|
202
|
+
{
|
|
203
|
+
uri: "readiness://recommendations",
|
|
204
|
+
mimeType: "application/json",
|
|
205
|
+
text: JSON.stringify(extractRecommendations(result), null, 2)
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
server.resource(
|
|
212
|
+
"readiness-context-files",
|
|
213
|
+
"readiness://context-files",
|
|
214
|
+
{ description: "Inventory of discovered context files (metadata only)" },
|
|
215
|
+
async () => {
|
|
216
|
+
const { result } = await getScanResult();
|
|
217
|
+
return {
|
|
218
|
+
contents: [
|
|
219
|
+
{
|
|
220
|
+
uri: "readiness://context-files",
|
|
221
|
+
mimeType: "application/json",
|
|
222
|
+
text: JSON.stringify(extractContextFiles(result), null, 2)
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
server.resource(
|
|
229
|
+
"readiness-budget",
|
|
230
|
+
"readiness://budget",
|
|
231
|
+
{ description: "Token budget analysis with hotspots and compression recommendations" },
|
|
232
|
+
async () => {
|
|
233
|
+
const { budget } = await getScanResult();
|
|
234
|
+
return {
|
|
235
|
+
contents: [
|
|
236
|
+
{
|
|
237
|
+
uri: "readiness://budget",
|
|
238
|
+
mimeType: "application/json",
|
|
239
|
+
text: JSON.stringify(extractBudget(budget), null, 2)
|
|
240
|
+
}
|
|
241
|
+
]
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
return server;
|
|
246
|
+
}
|
|
247
|
+
async function startServer(config) {
|
|
248
|
+
const server = createMcpServer(config);
|
|
249
|
+
const transport = new StdioServerTransport();
|
|
250
|
+
await server.connect(transport);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/cli.ts
|
|
254
|
+
var args = process.argv.slice(2);
|
|
255
|
+
var repoPath = process.cwd();
|
|
256
|
+
var cacheTtlMs = 3e5;
|
|
257
|
+
var scanTimeoutMs = 6e4;
|
|
258
|
+
for (let i = 0; i < args.length; i++) {
|
|
259
|
+
const arg = args[i];
|
|
260
|
+
if (arg === "--path" && args[i + 1]) {
|
|
261
|
+
i++;
|
|
262
|
+
repoPath = resolve(String(args[i]));
|
|
263
|
+
} else if (arg === "--cache-ttl" && args[i + 1]) {
|
|
264
|
+
i++;
|
|
265
|
+
const val = Number(args[i]);
|
|
266
|
+
if (Number.isNaN(val) || val < 0) {
|
|
267
|
+
process.stderr.write(`Error: --cache-ttl must be a non-negative number, got '${args[i]}'
|
|
268
|
+
`);
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
cacheTtlMs = val * 1e3;
|
|
272
|
+
} else if (arg === "--timeout" && args[i + 1]) {
|
|
273
|
+
i++;
|
|
274
|
+
const val = Number(args[i]);
|
|
275
|
+
if (Number.isNaN(val) || val < 0) {
|
|
276
|
+
process.stderr.write(`Error: --timeout must be a non-negative number, got '${args[i]}'
|
|
277
|
+
`);
|
|
278
|
+
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
scanTimeoutMs = val * 1e3;
|
|
281
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
282
|
+
process.stderr.write(
|
|
283
|
+
`ariscan-mcp \u2014 MCP server exposing read-only ARI readiness data
|
|
284
|
+
|
|
285
|
+
Usage: ariscan-mcp [options]
|
|
286
|
+
|
|
287
|
+
Options:
|
|
288
|
+
--path <dir> Repository path (default: cwd)
|
|
289
|
+
--cache-ttl <sec> Scan cache TTL in seconds (default: 300)
|
|
290
|
+
--timeout <sec> Scan timeout in seconds (default: 60)
|
|
291
|
+
-h, --help Show this help message
|
|
292
|
+
`
|
|
293
|
+
);
|
|
294
|
+
process.exit(0);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
startServer({ repoPath, cacheTtlMs, scanTimeoutMs }).catch((error) => {
|
|
298
|
+
process.stderr.write(`Fatal: ${error instanceof Error ? error.message : String(error)}
|
|
299
|
+
`);
|
|
300
|
+
process.exit(1);
|
|
301
|
+
});
|
|
302
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/server.ts","../src/resources/score.ts","../src/resources/pillars.ts","../src/resources/recommendations.ts","../src/resources/context-files.ts","../src/resources/budget.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { startServer } from \"./server.js\";\n\nconst args = process.argv.slice(2);\n\nlet repoPath = process.cwd();\nlet cacheTtlMs = 300_000; // 5 minutes\nlet scanTimeoutMs = 60_000; // 60 seconds\n\nfor (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === \"--path\" && args[i + 1]) {\n i++;\n repoPath = resolve(String(args[i]));\n } else if (arg === \"--cache-ttl\" && args[i + 1]) {\n i++;\n const val = Number(args[i]);\n if (Number.isNaN(val) || val < 0) {\n process.stderr.write(`Error: --cache-ttl must be a non-negative number, got '${args[i]}'\\n`);\n process.exit(1);\n }\n cacheTtlMs = val * 1000;\n } else if (arg === \"--timeout\" && args[i + 1]) {\n i++;\n const val = Number(args[i]);\n if (Number.isNaN(val) || val < 0) {\n process.stderr.write(`Error: --timeout must be a non-negative number, got '${args[i]}'\\n`);\n process.exit(1);\n }\n scanTimeoutMs = val * 1000;\n } else if (arg === \"--help\" || arg === \"-h\") {\n process.stderr.write(\n `ariscan-mcp — MCP server exposing read-only ARI readiness data\n\nUsage: ariscan-mcp [options]\n\nOptions:\n --path <dir> Repository path (default: cwd)\n --cache-ttl <sec> Scan cache TTL in seconds (default: 300)\n --timeout <sec> Scan timeout in seconds (default: 60)\n -h, --help Show this help message\n`,\n );\n process.exit(0);\n }\n}\n\nstartServer({ repoPath, cacheTtlMs, scanTimeoutMs }).catch((error: unknown) => {\n process.stderr.write(`Fatal: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n});\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { scan, analyzeTokenBudget, createRepoContext } from \"@prontiq/ariscan-engine\";\nimport type { ScanResult } from \"@prontiq/ariscan-schema\";\nimport type { TokenBudgetResult } from \"@prontiq/ariscan-engine\";\nimport {\n extractScore,\n extractPillars,\n extractRecommendations,\n extractContextFiles,\n extractBudget,\n} from \"./resources/index.js\";\n\n/** Configuration for the MCP server. */\nexport interface McpServerConfig {\n /** Path to the repository to scan. */\n repoPath: string;\n /** Cache TTL in milliseconds. Default: 300_000 (5 minutes). */\n cacheTtlMs?: number;\n /** Scan timeout in milliseconds. Default: 60_000 (60 seconds). */\n scanTimeoutMs?: number;\n}\n\n/** Cached scan state. */\ninterface CachedScan {\n result: ScanResult;\n budget: TokenBudgetResult;\n timestamp: number;\n}\n\n/**\n * Create and configure an MCP server exposing read-only ARI readiness data.\n *\n * Resources:\n * - readiness://score — composite score and maturity level\n * - readiness://pillars — per-pillar scores and findings\n * - readiness://recommendations — prioritized action items\n * - readiness://context-files — discovered context file inventory\n * - readiness://budget — token budget analysis\n */\nexport function createMcpServer(config: McpServerConfig): McpServer {\n const { repoPath, cacheTtlMs = 300_000, scanTimeoutMs = 60_000 } = config;\n\n const server = new McpServer(\n {\n name: \"ariscan\",\n version: \"0.35.0\",\n },\n {\n capabilities: {\n resources: {},\n },\n },\n );\n\n let cached: CachedScan | null = null;\n\n async function getScanResult(): Promise<CachedScan> {\n const now = Date.now();\n if (cached && now - cached.timestamp < cacheTtlMs) {\n return cached;\n }\n\n const doScan = async () => {\n const result = await scan(repoPath);\n const context = await createRepoContext(repoPath);\n const budget = await analyzeTokenBudget(context);\n return { result, budget, timestamp: Date.now() };\n };\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n cached = await Promise.race([\n doScan(),\n new Promise<never>((_, reject) => {\n timer = setTimeout(\n () => reject(new Error(`Scan timed out after ${scanTimeoutMs}ms`)),\n scanTimeoutMs,\n );\n }),\n ]).finally(() => {\n if (timer) clearTimeout(timer);\n });\n return cached;\n }\n\n // readiness://score\n server.resource(\n \"readiness-score\",\n \"readiness://score\",\n { description: \"Composite ARI score and maturity level\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://score\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractScore(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://pillars\n server.resource(\n \"readiness-pillars\",\n \"readiness://pillars\",\n { description: \"Per-pillar scores, findings, and summaries\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://pillars\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractPillars(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://recommendations\n server.resource(\n \"readiness-recommendations\",\n \"readiness://recommendations\",\n { description: \"Prioritized action items sorted by score impact\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://recommendations\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractRecommendations(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://context-files\n server.resource(\n \"readiness-context-files\",\n \"readiness://context-files\",\n { description: \"Inventory of discovered context files (metadata only)\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://context-files\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractContextFiles(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://budget\n server.resource(\n \"readiness-budget\",\n \"readiness://budget\",\n { description: \"Token budget analysis with hotspots and compression recommendations\" },\n async () => {\n const { budget } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://budget\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractBudget(budget), null, 2),\n },\n ],\n };\n },\n );\n\n return server;\n}\n\n/** Start the MCP server with stdio transport. */\nexport async function startServer(config: McpServerConfig): Promise<void> {\n const server = createMcpServer(config);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Extract composite score, maturity level, and metadata from a scan result. */\nexport function extractScore(result: ScanResult): {\n score: number;\n level: string;\n levelMeta: { level: string; name: string; description: string };\n securityGateTriggered: boolean;\n metadata: {\n version: string;\n timestamp: string;\n duration: number;\n repoPath: string;\n };\n scoreBreakdown?: {\n activePillars: number;\n insufficientPillars: number;\n effectiveWeightSum: number;\n };\n} {\n return {\n score: result.score,\n level: result.level,\n levelMeta: result.levelMeta,\n securityGateTriggered: result.securityGateTriggered,\n metadata: {\n version: result.metadata.version,\n timestamp: result.metadata.timestamp,\n duration: result.metadata.duration,\n repoPath: result.metadata.repoPath,\n },\n ...(result.scoreBreakdown ? { scoreBreakdown: result.scoreBreakdown } : {}),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Per-pillar summary without raw file content. Finding messages are metadata, not content. */\nexport function extractPillars(result: ScanResult): {\n pillars: Array<{\n pillar: string;\n name: string;\n score: number;\n weight: number;\n confidence: string;\n status?: string;\n summary: string;\n dataStatus?: string;\n findingCount: number;\n findings: Array<{\n code: string;\n severity: string;\n message: string;\n confidence?: string;\n applicability?: string;\n scoreImpact?: { pillarDelta: number; compositeDelta: number };\n }>;\n }>;\n} {\n return {\n pillars: result.pillars.map((p) => ({\n pillar: p.pillar,\n name: p.name,\n score: p.score,\n weight: p.weight,\n confidence: p.confidence,\n ...(p.status ? { status: p.status } : {}),\n summary: p.summary,\n ...(p.dataStatus ? { dataStatus: p.dataStatus } : {}),\n findingCount: p.findings.length,\n findings: p.findings.map((f) => ({\n code: f.code,\n severity: f.severity,\n message: f.message,\n ...(f.confidence ? { confidence: f.confidence } : {}),\n ...(f.applicability ? { applicability: f.applicability } : {}),\n ...(f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}),\n })),\n })),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Prioritized action items sorted by composite score impact. */\nexport function extractRecommendations(result: ScanResult): {\n recommendations: Array<{\n code: string;\n pillar: string;\n severity: string;\n message: string;\n remediation?: {\n action: string;\n description: string;\n estimatedImpact?: string;\n confidence: string;\n };\n scoreImpact?: { pillarDelta: number; compositeDelta: number };\n }>;\n} {\n // Collect all findings with remediation, sorted by composite delta (descending)\n const actionable = result.findings\n .filter((f) => f.remediation && !f.suppressed)\n .sort((a, b) => {\n const deltaA = a.scoreImpact?.compositeDelta ?? 0;\n const deltaB = b.scoreImpact?.compositeDelta ?? 0;\n return deltaB - deltaA;\n });\n\n return {\n recommendations: actionable.map((f) => ({\n code: f.code,\n pillar: f.pillar,\n severity: f.severity,\n message: f.message,\n ...(f.remediation\n ? {\n remediation: {\n action: f.remediation.action,\n description: f.remediation.description,\n ...(f.remediation.estimatedImpact\n ? { estimatedImpact: f.remediation.estimatedImpact }\n : {}),\n confidence: f.remediation.confidence,\n },\n }\n : {}),\n ...(f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}),\n })),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Inventory of discovered context files — metadata only, no content. */\nexport function extractContextFiles(result: ScanResult): {\n contextFiles: Array<{\n path: string;\n type: string;\n size?: number;\n lineCount?: number;\n lastModified?: string;\n parseStatus?: string;\n }>;\n} {\n return {\n contextFiles: (result.contextFiles ?? []).map((cf) => ({\n path: cf.path,\n type: cf.type,\n ...(cf.size != null ? { size: cf.size } : {}),\n ...(cf.lineCount != null ? { lineCount: cf.lineCount } : {}),\n ...(cf.lastModified ? { lastModified: cf.lastModified } : {}),\n ...(cf.parseStatus ? { parseStatus: cf.parseStatus } : {}),\n })),\n };\n}\n","import type { TokenBudgetResult } from \"@prontiq/ariscan-engine\";\n\n/** Token budget analysis — category totals, hotspots, compression recommendations. */\nexport function extractBudget(budget: TokenBudgetResult): {\n totalTokens: number;\n totalFiles: number;\n totalBytes: number;\n categories: Array<{\n category: string;\n fileCount: number;\n totalBytes: number;\n totalTokens: number;\n percentage: number;\n }>;\n hotspots: Array<{\n path: string;\n category: string;\n estimatedTokens: number;\n }>;\n recommendations: Array<{\n description: string;\n targetFiles: string[];\n estimatedSavingsTokens: number;\n priority: string;\n }>;\n} {\n return {\n totalTokens: budget.totalTokens,\n totalFiles: budget.totalFiles,\n totalBytes: budget.totalBytes,\n categories: budget.byCategory.map((c) => ({\n category: c.category,\n fileCount: c.fileCount,\n totalBytes: c.totalBytes,\n totalTokens: c.totalTokens,\n percentage: c.percentage,\n })),\n hotspots: budget.hotspots.map((h) => ({\n path: h.path,\n category: h.category,\n estimatedTokens: h.estimatedTokens,\n })),\n recommendations: budget.recommendations.map((r) => ({\n description: r.description,\n targetFiles: r.targetFiles,\n estimatedSavingsTokens: r.estimatedSavingsTokens,\n priority: r.priority,\n })),\n };\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,MAAM,oBAAoB,yBAAyB;;;ACCrD,SAAS,aAAa,QAgB3B;AACA,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,OAAO,OAAO;AAAA,IACd,WAAW,OAAO;AAAA,IAClB,uBAAuB,OAAO;AAAA,IAC9B,UAAU;AAAA,MACR,SAAS,OAAO,SAAS;AAAA,MACzB,WAAW,OAAO,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AAM,GAAG;AAChC,cAAQ,OAAO,MAAM,wDAAwD,KAAK,CAAC,CAAC;AAAA,CAAK;AACzF,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,oBAAgB,MAAM;AAAA,EACxB,WAAW,QAAQ,YAAY,QAAQ,MAAM;AAC3C,YAAQ,OAAO;AAAA,MACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAUF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,YAAY,EAAE,UAAU,YAAY,cAAc,CAAC,EAAE,MAAM,CAAC,UAAmB;AAC7E,UAAQ,OAAO,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AACzF,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["repoPath","cacheTtlMs","scanTimeoutMs"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { ScanResult } from '@prontiq/ariscan-schema';
|
|
3
|
+
import { TokenBudgetResult } from '@prontiq/ariscan-engine';
|
|
4
|
+
|
|
5
|
+
/** Configuration for the MCP server. */
|
|
6
|
+
interface McpServerConfig {
|
|
7
|
+
/** Path to the repository to scan. */
|
|
8
|
+
repoPath: string;
|
|
9
|
+
/** Cache TTL in milliseconds. Default: 300_000 (5 minutes). */
|
|
10
|
+
cacheTtlMs?: number;
|
|
11
|
+
/** Scan timeout in milliseconds. Default: 60_000 (60 seconds). */
|
|
12
|
+
scanTimeoutMs?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create and configure an MCP server exposing read-only ARI readiness data.
|
|
16
|
+
*
|
|
17
|
+
* Resources:
|
|
18
|
+
* - readiness://score — composite score and maturity level
|
|
19
|
+
* - readiness://pillars — per-pillar scores and findings
|
|
20
|
+
* - readiness://recommendations — prioritized action items
|
|
21
|
+
* - readiness://context-files — discovered context file inventory
|
|
22
|
+
* - readiness://budget — token budget analysis
|
|
23
|
+
*/
|
|
24
|
+
declare function createMcpServer(config: McpServerConfig): McpServer;
|
|
25
|
+
/** Start the MCP server with stdio transport. */
|
|
26
|
+
declare function startServer(config: McpServerConfig): Promise<void>;
|
|
27
|
+
|
|
28
|
+
/** Extract composite score, maturity level, and metadata from a scan result. */
|
|
29
|
+
declare function extractScore(result: ScanResult): {
|
|
30
|
+
score: number;
|
|
31
|
+
level: string;
|
|
32
|
+
levelMeta: {
|
|
33
|
+
level: string;
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
securityGateTriggered: boolean;
|
|
38
|
+
metadata: {
|
|
39
|
+
version: string;
|
|
40
|
+
timestamp: string;
|
|
41
|
+
duration: number;
|
|
42
|
+
repoPath: string;
|
|
43
|
+
};
|
|
44
|
+
scoreBreakdown?: {
|
|
45
|
+
activePillars: number;
|
|
46
|
+
insufficientPillars: number;
|
|
47
|
+
effectiveWeightSum: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Per-pillar summary without raw file content. Finding messages are metadata, not content. */
|
|
52
|
+
declare function extractPillars(result: ScanResult): {
|
|
53
|
+
pillars: Array<{
|
|
54
|
+
pillar: string;
|
|
55
|
+
name: string;
|
|
56
|
+
score: number;
|
|
57
|
+
weight: number;
|
|
58
|
+
confidence: string;
|
|
59
|
+
status?: string;
|
|
60
|
+
summary: string;
|
|
61
|
+
dataStatus?: string;
|
|
62
|
+
findingCount: number;
|
|
63
|
+
findings: Array<{
|
|
64
|
+
code: string;
|
|
65
|
+
severity: string;
|
|
66
|
+
message: string;
|
|
67
|
+
confidence?: string;
|
|
68
|
+
applicability?: string;
|
|
69
|
+
scoreImpact?: {
|
|
70
|
+
pillarDelta: number;
|
|
71
|
+
compositeDelta: number;
|
|
72
|
+
};
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Prioritized action items sorted by composite score impact. */
|
|
78
|
+
declare function extractRecommendations(result: ScanResult): {
|
|
79
|
+
recommendations: Array<{
|
|
80
|
+
code: string;
|
|
81
|
+
pillar: string;
|
|
82
|
+
severity: string;
|
|
83
|
+
message: string;
|
|
84
|
+
remediation?: {
|
|
85
|
+
action: string;
|
|
86
|
+
description: string;
|
|
87
|
+
estimatedImpact?: string;
|
|
88
|
+
confidence: string;
|
|
89
|
+
};
|
|
90
|
+
scoreImpact?: {
|
|
91
|
+
pillarDelta: number;
|
|
92
|
+
compositeDelta: number;
|
|
93
|
+
};
|
|
94
|
+
}>;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** Inventory of discovered context files — metadata only, no content. */
|
|
98
|
+
declare function extractContextFiles(result: ScanResult): {
|
|
99
|
+
contextFiles: Array<{
|
|
100
|
+
path: string;
|
|
101
|
+
type: string;
|
|
102
|
+
size?: number;
|
|
103
|
+
lineCount?: number;
|
|
104
|
+
lastModified?: string;
|
|
105
|
+
parseStatus?: string;
|
|
106
|
+
}>;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** Token budget analysis — category totals, hotspots, compression recommendations. */
|
|
110
|
+
declare function extractBudget(budget: TokenBudgetResult): {
|
|
111
|
+
totalTokens: number;
|
|
112
|
+
totalFiles: number;
|
|
113
|
+
totalBytes: number;
|
|
114
|
+
categories: Array<{
|
|
115
|
+
category: string;
|
|
116
|
+
fileCount: number;
|
|
117
|
+
totalBytes: number;
|
|
118
|
+
totalTokens: number;
|
|
119
|
+
percentage: number;
|
|
120
|
+
}>;
|
|
121
|
+
hotspots: Array<{
|
|
122
|
+
path: string;
|
|
123
|
+
category: string;
|
|
124
|
+
estimatedTokens: number;
|
|
125
|
+
}>;
|
|
126
|
+
recommendations: Array<{
|
|
127
|
+
description: string;
|
|
128
|
+
targetFiles: string[];
|
|
129
|
+
estimatedSavingsTokens: number;
|
|
130
|
+
priority: string;
|
|
131
|
+
}>;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export { type McpServerConfig, createMcpServer, extractBudget, extractContextFiles, extractPillars, extractRecommendations, extractScore, startServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { scan, analyzeTokenBudget, createRepoContext } from "@prontiq/ariscan-engine";
|
|
5
|
+
|
|
6
|
+
// src/resources/score.ts
|
|
7
|
+
function extractScore(result) {
|
|
8
|
+
return {
|
|
9
|
+
score: result.score,
|
|
10
|
+
level: result.level,
|
|
11
|
+
levelMeta: result.levelMeta,
|
|
12
|
+
securityGateTriggered: result.securityGateTriggered,
|
|
13
|
+
metadata: {
|
|
14
|
+
version: result.metadata.version,
|
|
15
|
+
timestamp: result.metadata.timestamp,
|
|
16
|
+
duration: result.metadata.duration,
|
|
17
|
+
repoPath: result.metadata.repoPath
|
|
18
|
+
},
|
|
19
|
+
...result.scoreBreakdown ? { scoreBreakdown: result.scoreBreakdown } : {}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/resources/pillars.ts
|
|
24
|
+
function extractPillars(result) {
|
|
25
|
+
return {
|
|
26
|
+
pillars: result.pillars.map((p) => ({
|
|
27
|
+
pillar: p.pillar,
|
|
28
|
+
name: p.name,
|
|
29
|
+
score: p.score,
|
|
30
|
+
weight: p.weight,
|
|
31
|
+
confidence: p.confidence,
|
|
32
|
+
...p.status ? { status: p.status } : {},
|
|
33
|
+
summary: p.summary,
|
|
34
|
+
...p.dataStatus ? { dataStatus: p.dataStatus } : {},
|
|
35
|
+
findingCount: p.findings.length,
|
|
36
|
+
findings: p.findings.map((f) => ({
|
|
37
|
+
code: f.code,
|
|
38
|
+
severity: f.severity,
|
|
39
|
+
message: f.message,
|
|
40
|
+
...f.confidence ? { confidence: f.confidence } : {},
|
|
41
|
+
...f.applicability ? { applicability: f.applicability } : {},
|
|
42
|
+
...f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}
|
|
43
|
+
}))
|
|
44
|
+
}))
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/resources/recommendations.ts
|
|
49
|
+
function extractRecommendations(result) {
|
|
50
|
+
const actionable = result.findings.filter((f) => f.remediation && !f.suppressed).sort((a, b) => {
|
|
51
|
+
const deltaA = a.scoreImpact?.compositeDelta ?? 0;
|
|
52
|
+
const deltaB = b.scoreImpact?.compositeDelta ?? 0;
|
|
53
|
+
return deltaB - deltaA;
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
recommendations: actionable.map((f) => ({
|
|
57
|
+
code: f.code,
|
|
58
|
+
pillar: f.pillar,
|
|
59
|
+
severity: f.severity,
|
|
60
|
+
message: f.message,
|
|
61
|
+
...f.remediation ? {
|
|
62
|
+
remediation: {
|
|
63
|
+
action: f.remediation.action,
|
|
64
|
+
description: f.remediation.description,
|
|
65
|
+
...f.remediation.estimatedImpact ? { estimatedImpact: f.remediation.estimatedImpact } : {},
|
|
66
|
+
confidence: f.remediation.confidence
|
|
67
|
+
}
|
|
68
|
+
} : {},
|
|
69
|
+
...f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}
|
|
70
|
+
}))
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/resources/context-files.ts
|
|
75
|
+
function extractContextFiles(result) {
|
|
76
|
+
return {
|
|
77
|
+
contextFiles: (result.contextFiles ?? []).map((cf) => ({
|
|
78
|
+
path: cf.path,
|
|
79
|
+
type: cf.type,
|
|
80
|
+
...cf.size != null ? { size: cf.size } : {},
|
|
81
|
+
...cf.lineCount != null ? { lineCount: cf.lineCount } : {},
|
|
82
|
+
...cf.lastModified ? { lastModified: cf.lastModified } : {},
|
|
83
|
+
...cf.parseStatus ? { parseStatus: cf.parseStatus } : {}
|
|
84
|
+
}))
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/resources/budget.ts
|
|
89
|
+
function extractBudget(budget) {
|
|
90
|
+
return {
|
|
91
|
+
totalTokens: budget.totalTokens,
|
|
92
|
+
totalFiles: budget.totalFiles,
|
|
93
|
+
totalBytes: budget.totalBytes,
|
|
94
|
+
categories: budget.byCategory.map((c) => ({
|
|
95
|
+
category: c.category,
|
|
96
|
+
fileCount: c.fileCount,
|
|
97
|
+
totalBytes: c.totalBytes,
|
|
98
|
+
totalTokens: c.totalTokens,
|
|
99
|
+
percentage: c.percentage
|
|
100
|
+
})),
|
|
101
|
+
hotspots: budget.hotspots.map((h) => ({
|
|
102
|
+
path: h.path,
|
|
103
|
+
category: h.category,
|
|
104
|
+
estimatedTokens: h.estimatedTokens
|
|
105
|
+
})),
|
|
106
|
+
recommendations: budget.recommendations.map((r) => ({
|
|
107
|
+
description: r.description,
|
|
108
|
+
targetFiles: r.targetFiles,
|
|
109
|
+
estimatedSavingsTokens: r.estimatedSavingsTokens,
|
|
110
|
+
priority: r.priority
|
|
111
|
+
}))
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/server.ts
|
|
116
|
+
function createMcpServer(config) {
|
|
117
|
+
const { repoPath, cacheTtlMs = 3e5, scanTimeoutMs = 6e4 } = config;
|
|
118
|
+
const server = new McpServer(
|
|
119
|
+
{
|
|
120
|
+
name: "ariscan",
|
|
121
|
+
version: "0.35.0"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
capabilities: {
|
|
125
|
+
resources: {}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
let cached = null;
|
|
130
|
+
async function getScanResult() {
|
|
131
|
+
const now = Date.now();
|
|
132
|
+
if (cached && now - cached.timestamp < cacheTtlMs) {
|
|
133
|
+
return cached;
|
|
134
|
+
}
|
|
135
|
+
const doScan = async () => {
|
|
136
|
+
const result = await scan(repoPath);
|
|
137
|
+
const context = await createRepoContext(repoPath);
|
|
138
|
+
const budget = await analyzeTokenBudget(context);
|
|
139
|
+
return { result, budget, timestamp: Date.now() };
|
|
140
|
+
};
|
|
141
|
+
let timer;
|
|
142
|
+
cached = await Promise.race([
|
|
143
|
+
doScan(),
|
|
144
|
+
new Promise((_, reject) => {
|
|
145
|
+
timer = setTimeout(
|
|
146
|
+
() => reject(new Error(`Scan timed out after ${scanTimeoutMs}ms`)),
|
|
147
|
+
scanTimeoutMs
|
|
148
|
+
);
|
|
149
|
+
})
|
|
150
|
+
]).finally(() => {
|
|
151
|
+
if (timer) clearTimeout(timer);
|
|
152
|
+
});
|
|
153
|
+
return cached;
|
|
154
|
+
}
|
|
155
|
+
server.resource(
|
|
156
|
+
"readiness-score",
|
|
157
|
+
"readiness://score",
|
|
158
|
+
{ description: "Composite ARI score and maturity level" },
|
|
159
|
+
async () => {
|
|
160
|
+
const { result } = await getScanResult();
|
|
161
|
+
return {
|
|
162
|
+
contents: [
|
|
163
|
+
{
|
|
164
|
+
uri: "readiness://score",
|
|
165
|
+
mimeType: "application/json",
|
|
166
|
+
text: JSON.stringify(extractScore(result), null, 2)
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
server.resource(
|
|
173
|
+
"readiness-pillars",
|
|
174
|
+
"readiness://pillars",
|
|
175
|
+
{ description: "Per-pillar scores, findings, and summaries" },
|
|
176
|
+
async () => {
|
|
177
|
+
const { result } = await getScanResult();
|
|
178
|
+
return {
|
|
179
|
+
contents: [
|
|
180
|
+
{
|
|
181
|
+
uri: "readiness://pillars",
|
|
182
|
+
mimeType: "application/json",
|
|
183
|
+
text: JSON.stringify(extractPillars(result), null, 2)
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
server.resource(
|
|
190
|
+
"readiness-recommendations",
|
|
191
|
+
"readiness://recommendations",
|
|
192
|
+
{ description: "Prioritized action items sorted by score impact" },
|
|
193
|
+
async () => {
|
|
194
|
+
const { result } = await getScanResult();
|
|
195
|
+
return {
|
|
196
|
+
contents: [
|
|
197
|
+
{
|
|
198
|
+
uri: "readiness://recommendations",
|
|
199
|
+
mimeType: "application/json",
|
|
200
|
+
text: JSON.stringify(extractRecommendations(result), null, 2)
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
server.resource(
|
|
207
|
+
"readiness-context-files",
|
|
208
|
+
"readiness://context-files",
|
|
209
|
+
{ description: "Inventory of discovered context files (metadata only)" },
|
|
210
|
+
async () => {
|
|
211
|
+
const { result } = await getScanResult();
|
|
212
|
+
return {
|
|
213
|
+
contents: [
|
|
214
|
+
{
|
|
215
|
+
uri: "readiness://context-files",
|
|
216
|
+
mimeType: "application/json",
|
|
217
|
+
text: JSON.stringify(extractContextFiles(result), null, 2)
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
server.resource(
|
|
224
|
+
"readiness-budget",
|
|
225
|
+
"readiness://budget",
|
|
226
|
+
{ description: "Token budget analysis with hotspots and compression recommendations" },
|
|
227
|
+
async () => {
|
|
228
|
+
const { budget } = await getScanResult();
|
|
229
|
+
return {
|
|
230
|
+
contents: [
|
|
231
|
+
{
|
|
232
|
+
uri: "readiness://budget",
|
|
233
|
+
mimeType: "application/json",
|
|
234
|
+
text: JSON.stringify(extractBudget(budget), null, 2)
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
return server;
|
|
241
|
+
}
|
|
242
|
+
async function startServer(config) {
|
|
243
|
+
const server = createMcpServer(config);
|
|
244
|
+
const transport = new StdioServerTransport();
|
|
245
|
+
await server.connect(transport);
|
|
246
|
+
}
|
|
247
|
+
export {
|
|
248
|
+
createMcpServer,
|
|
249
|
+
extractBudget,
|
|
250
|
+
extractContextFiles,
|
|
251
|
+
extractPillars,
|
|
252
|
+
extractRecommendations,
|
|
253
|
+
extractScore,
|
|
254
|
+
startServer
|
|
255
|
+
};
|
|
256
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/resources/score.ts","../src/resources/pillars.ts","../src/resources/recommendations.ts","../src/resources/context-files.ts","../src/resources/budget.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { scan, analyzeTokenBudget, createRepoContext } from \"@prontiq/ariscan-engine\";\nimport type { ScanResult } from \"@prontiq/ariscan-schema\";\nimport type { TokenBudgetResult } from \"@prontiq/ariscan-engine\";\nimport {\n extractScore,\n extractPillars,\n extractRecommendations,\n extractContextFiles,\n extractBudget,\n} from \"./resources/index.js\";\n\n/** Configuration for the MCP server. */\nexport interface McpServerConfig {\n /** Path to the repository to scan. */\n repoPath: string;\n /** Cache TTL in milliseconds. Default: 300_000 (5 minutes). */\n cacheTtlMs?: number;\n /** Scan timeout in milliseconds. Default: 60_000 (60 seconds). */\n scanTimeoutMs?: number;\n}\n\n/** Cached scan state. */\ninterface CachedScan {\n result: ScanResult;\n budget: TokenBudgetResult;\n timestamp: number;\n}\n\n/**\n * Create and configure an MCP server exposing read-only ARI readiness data.\n *\n * Resources:\n * - readiness://score — composite score and maturity level\n * - readiness://pillars — per-pillar scores and findings\n * - readiness://recommendations — prioritized action items\n * - readiness://context-files — discovered context file inventory\n * - readiness://budget — token budget analysis\n */\nexport function createMcpServer(config: McpServerConfig): McpServer {\n const { repoPath, cacheTtlMs = 300_000, scanTimeoutMs = 60_000 } = config;\n\n const server = new McpServer(\n {\n name: \"ariscan\",\n version: \"0.35.0\",\n },\n {\n capabilities: {\n resources: {},\n },\n },\n );\n\n let cached: CachedScan | null = null;\n\n async function getScanResult(): Promise<CachedScan> {\n const now = Date.now();\n if (cached && now - cached.timestamp < cacheTtlMs) {\n return cached;\n }\n\n const doScan = async () => {\n const result = await scan(repoPath);\n const context = await createRepoContext(repoPath);\n const budget = await analyzeTokenBudget(context);\n return { result, budget, timestamp: Date.now() };\n };\n\n let timer: ReturnType<typeof setTimeout> | undefined;\n cached = await Promise.race([\n doScan(),\n new Promise<never>((_, reject) => {\n timer = setTimeout(\n () => reject(new Error(`Scan timed out after ${scanTimeoutMs}ms`)),\n scanTimeoutMs,\n );\n }),\n ]).finally(() => {\n if (timer) clearTimeout(timer);\n });\n return cached;\n }\n\n // readiness://score\n server.resource(\n \"readiness-score\",\n \"readiness://score\",\n { description: \"Composite ARI score and maturity level\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://score\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractScore(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://pillars\n server.resource(\n \"readiness-pillars\",\n \"readiness://pillars\",\n { description: \"Per-pillar scores, findings, and summaries\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://pillars\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractPillars(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://recommendations\n server.resource(\n \"readiness-recommendations\",\n \"readiness://recommendations\",\n { description: \"Prioritized action items sorted by score impact\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://recommendations\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractRecommendations(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://context-files\n server.resource(\n \"readiness-context-files\",\n \"readiness://context-files\",\n { description: \"Inventory of discovered context files (metadata only)\" },\n async () => {\n const { result } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://context-files\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractContextFiles(result), null, 2),\n },\n ],\n };\n },\n );\n\n // readiness://budget\n server.resource(\n \"readiness-budget\",\n \"readiness://budget\",\n { description: \"Token budget analysis with hotspots and compression recommendations\" },\n async () => {\n const { budget } = await getScanResult();\n return {\n contents: [\n {\n uri: \"readiness://budget\",\n mimeType: \"application/json\",\n text: JSON.stringify(extractBudget(budget), null, 2),\n },\n ],\n };\n },\n );\n\n return server;\n}\n\n/** Start the MCP server with stdio transport. */\nexport async function startServer(config: McpServerConfig): Promise<void> {\n const server = createMcpServer(config);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Extract composite score, maturity level, and metadata from a scan result. */\nexport function extractScore(result: ScanResult): {\n score: number;\n level: string;\n levelMeta: { level: string; name: string; description: string };\n securityGateTriggered: boolean;\n metadata: {\n version: string;\n timestamp: string;\n duration: number;\n repoPath: string;\n };\n scoreBreakdown?: {\n activePillars: number;\n insufficientPillars: number;\n effectiveWeightSum: number;\n };\n} {\n return {\n score: result.score,\n level: result.level,\n levelMeta: result.levelMeta,\n securityGateTriggered: result.securityGateTriggered,\n metadata: {\n version: result.metadata.version,\n timestamp: result.metadata.timestamp,\n duration: result.metadata.duration,\n repoPath: result.metadata.repoPath,\n },\n ...(result.scoreBreakdown ? { scoreBreakdown: result.scoreBreakdown } : {}),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Per-pillar summary without raw file content. Finding messages are metadata, not content. */\nexport function extractPillars(result: ScanResult): {\n pillars: Array<{\n pillar: string;\n name: string;\n score: number;\n weight: number;\n confidence: string;\n status?: string;\n summary: string;\n dataStatus?: string;\n findingCount: number;\n findings: Array<{\n code: string;\n severity: string;\n message: string;\n confidence?: string;\n applicability?: string;\n scoreImpact?: { pillarDelta: number; compositeDelta: number };\n }>;\n }>;\n} {\n return {\n pillars: result.pillars.map((p) => ({\n pillar: p.pillar,\n name: p.name,\n score: p.score,\n weight: p.weight,\n confidence: p.confidence,\n ...(p.status ? { status: p.status } : {}),\n summary: p.summary,\n ...(p.dataStatus ? { dataStatus: p.dataStatus } : {}),\n findingCount: p.findings.length,\n findings: p.findings.map((f) => ({\n code: f.code,\n severity: f.severity,\n message: f.message,\n ...(f.confidence ? { confidence: f.confidence } : {}),\n ...(f.applicability ? { applicability: f.applicability } : {}),\n ...(f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}),\n })),\n })),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Prioritized action items sorted by composite score impact. */\nexport function extractRecommendations(result: ScanResult): {\n recommendations: Array<{\n code: string;\n pillar: string;\n severity: string;\n message: string;\n remediation?: {\n action: string;\n description: string;\n estimatedImpact?: string;\n confidence: string;\n };\n scoreImpact?: { pillarDelta: number; compositeDelta: number };\n }>;\n} {\n // Collect all findings with remediation, sorted by composite delta (descending)\n const actionable = result.findings\n .filter((f) => f.remediation && !f.suppressed)\n .sort((a, b) => {\n const deltaA = a.scoreImpact?.compositeDelta ?? 0;\n const deltaB = b.scoreImpact?.compositeDelta ?? 0;\n return deltaB - deltaA;\n });\n\n return {\n recommendations: actionable.map((f) => ({\n code: f.code,\n pillar: f.pillar,\n severity: f.severity,\n message: f.message,\n ...(f.remediation\n ? {\n remediation: {\n action: f.remediation.action,\n description: f.remediation.description,\n ...(f.remediation.estimatedImpact\n ? { estimatedImpact: f.remediation.estimatedImpact }\n : {}),\n confidence: f.remediation.confidence,\n },\n }\n : {}),\n ...(f.scoreImpact ? { scoreImpact: f.scoreImpact } : {}),\n })),\n };\n}\n","import type { ScanResult } from \"@prontiq/ariscan-schema\";\n\n/** Inventory of discovered context files — metadata only, no content. */\nexport function extractContextFiles(result: ScanResult): {\n contextFiles: Array<{\n path: string;\n type: string;\n size?: number;\n lineCount?: number;\n lastModified?: string;\n parseStatus?: string;\n }>;\n} {\n return {\n contextFiles: (result.contextFiles ?? []).map((cf) => ({\n path: cf.path,\n type: cf.type,\n ...(cf.size != null ? { size: cf.size } : {}),\n ...(cf.lineCount != null ? { lineCount: cf.lineCount } : {}),\n ...(cf.lastModified ? { lastModified: cf.lastModified } : {}),\n ...(cf.parseStatus ? { parseStatus: cf.parseStatus } : {}),\n })),\n };\n}\n","import type { TokenBudgetResult } from \"@prontiq/ariscan-engine\";\n\n/** Token budget analysis — category totals, hotspots, compression recommendations. */\nexport function extractBudget(budget: TokenBudgetResult): {\n totalTokens: number;\n totalFiles: number;\n totalBytes: number;\n categories: Array<{\n category: string;\n fileCount: number;\n totalBytes: number;\n totalTokens: number;\n percentage: number;\n }>;\n hotspots: Array<{\n path: string;\n category: string;\n estimatedTokens: number;\n }>;\n recommendations: Array<{\n description: string;\n targetFiles: string[];\n estimatedSavingsTokens: number;\n priority: string;\n }>;\n} {\n return {\n totalTokens: budget.totalTokens,\n totalFiles: budget.totalFiles,\n totalBytes: budget.totalBytes,\n categories: budget.byCategory.map((c) => ({\n category: c.category,\n fileCount: c.fileCount,\n totalBytes: c.totalBytes,\n totalTokens: c.totalTokens,\n percentage: c.percentage,\n })),\n hotspots: budget.hotspots.map((h) => ({\n path: h.path,\n category: h.category,\n estimatedTokens: h.estimatedTokens,\n })),\n recommendations: budget.recommendations.map((r) => ({\n description: r.description,\n targetFiles: r.targetFiles,\n estimatedSavingsTokens: r.estimatedSavingsTokens,\n priority: r.priority,\n })),\n };\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,MAAM,oBAAoB,yBAAyB;;;ACCrD,SAAS,aAAa,QAgB3B;AACA,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,IACd,OAAO,OAAO;AAAA,IACd,WAAW,OAAO;AAAA,IAClB,uBAAuB,OAAO;AAAA,IAC9B,UAAU;AAAA,MACR,SAAS,OAAO,SAAS;AAAA,MACzB,WAAW,OAAO,SAAS;AAAA,MAC3B,UAAU,OAAO,SAAS;AAAA,MAC1B,UAAU,OAAO,SAAS;AAAA,IAC5B;AAAA,IACA,GAAI,OAAO,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AY;AACV,YAAM,EAAE,OAAO,IAAI,MAAM,cAAc;AACvC,aAAO;AAAA,QACL,UAAU;AAAA,UACR;AAAA,YACE,KAAK;AAAA,YACL,UAAU;AAAA,YACV,MAAM,KAAK,UAAU,cAAc,MAAM,GAAG,MAAM,CAAC;AAAA,UACrD;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAGA,eAAsB,YAAY,QAAwC;AACxE,QAAM,SAAS,gBAAgB,MAAM;AACrC,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prontiq/ariscan-mcp",
|
|
3
|
+
"version": "0.35.1",
|
|
4
|
+
"description": "MCP server exposing read-only ARI readiness data",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Elastic-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/jbejenar/prontiq-ariscan.git",
|
|
10
|
+
"directory": "packages/mcp"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"ariscan-mcp": "./dist/cli.js"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.28.0",
|
|
32
|
+
"@prontiq/ariscan-schema": "0.37.0",
|
|
33
|
+
"@prontiq/ariscan-engine": "0.37.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^25.5.0",
|
|
37
|
+
"tsup": "^8.3.0",
|
|
38
|
+
"typescript": "^5.7.0",
|
|
39
|
+
"vitest": "^4.1.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"lint": "eslint src/",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"clean": "rm -rf dist"
|
|
47
|
+
}
|
|
48
|
+
}
|