openkrak-mcp 1.0.4 → 1.0.6
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 +43 -29
- package/package.json +31 -30
package/dist/index.js
CHANGED
|
@@ -244914,46 +244914,60 @@ async function handleGetMahadata(args) {
|
|
|
244914
244914
|
const repo = m.repository;
|
|
244915
244915
|
const hotspots = m.hotspots ?? [];
|
|
244916
244916
|
const blastRadius = m.blast_radius ?? [];
|
|
244917
|
+
const findings = m.findings ?? [];
|
|
244917
244918
|
if (!brief) {
|
|
244918
244919
|
return {
|
|
244919
244920
|
content: [{ type: "text", text: "OpenKrak: no execution_brief generated." }],
|
|
244920
244921
|
isError: true
|
|
244921
244922
|
};
|
|
244922
244923
|
}
|
|
244924
|
+
const totalFiles = Number(repo?.total_files ?? 0);
|
|
244925
|
+
const hotspotLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : totalFiles < 500 ? 8 : 12;
|
|
244926
|
+
const blastLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : 8;
|
|
244927
|
+
const findingLimit = totalFiles < 50 ? 3 : totalFiles < 200 ? 5 : 10;
|
|
244923
244928
|
const ctx = brief.critical_context ?? [];
|
|
244924
|
-
const ph = brief.priority_hotspots ?? [];
|
|
244925
244929
|
const ep = brief.recommended_entry_points ?? [];
|
|
244926
244930
|
const constraints = brief.constraints ?? [];
|
|
244927
|
-
const blockers =
|
|
244928
|
-
const warnings =
|
|
244929
|
-
const topHotspots = hotspots.slice(0, 3).map((h) => {
|
|
244930
|
-
const hs = h;
|
|
244931
|
-
return `${hs.path}[${hs.risk_level},${Number(hs.score).toFixed(2)}]`;
|
|
244932
|
-
});
|
|
244933
|
-
const topBlast = blastRadius.slice(0, 3).map((b) => {
|
|
244934
|
-
const br = b;
|
|
244935
|
-
return `${br.trigger_file}\u2192${br.total_affected_files}files`;
|
|
244936
|
-
});
|
|
244931
|
+
const blockers = threat?.blockers ?? [];
|
|
244932
|
+
const warnings = threat?.warnings ?? [];
|
|
244937
244933
|
const lines = [
|
|
244938
|
-
`[MAHADATA
|
|
244939
|
-
`
|
|
244940
|
-
`objective
|
|
244941
|
-
`summary
|
|
244934
|
+
`[MAHADATA] repo:${repo?.name ?? args.path}`,
|
|
244935
|
+
`lang:${repo?.primary_language ?? "?"} | files:${repo?.total_files ?? "?"} | loc:${repo?.total_loc ?? "?"} | framework:${repo?.framework ?? "none"}`,
|
|
244936
|
+
`objective: ${brief.objective}`,
|
|
244937
|
+
`summary: ${brief.repository_summary}`,
|
|
244942
244938
|
``,
|
|
244943
|
-
`
|
|
244939
|
+
`CONTEXT:`,
|
|
244940
|
+
...ctx.map((c) => ` ${c.key}: ${c.value}`),
|
|
244944
244941
|
``,
|
|
244945
|
-
`HOTSPOTS(
|
|
244946
|
-
|
|
244942
|
+
`HOTSPOTS (${hotspots.length} total, top ${Math.min(hotspotLimit, hotspots.length)}):`,
|
|
244943
|
+
...hotspots.slice(0, hotspotLimit).map((h) => {
|
|
244944
|
+
const hs = h;
|
|
244945
|
+
const reasons = hs.reasons ?? [];
|
|
244946
|
+
return ` [${hs.risk_level}] ${hs.path} score:${Number(hs.score).toFixed(2)} changes:${hs.change_frequency} \u2014 ${reasons.map((r) => r.type).join(", ")}`;
|
|
244947
|
+
}),
|
|
244947
244948
|
``,
|
|
244948
|
-
`
|
|
244949
|
-
...
|
|
244949
|
+
`BLAST RADIUS (top ${Math.min(blastLimit, blastRadius.length)}):`,
|
|
244950
|
+
...blastRadius.slice(0, blastLimit).map((b) => {
|
|
244951
|
+
const br = b;
|
|
244952
|
+
return ` ${br.trigger_file} \u2192 affects ${br.total_affected_files} files, ${br.total_affected_modules} modules (risk:${Number(br.risk_score).toFixed(2)})`;
|
|
244953
|
+
}),
|
|
244950
244954
|
``,
|
|
244951
|
-
`
|
|
244952
|
-
|
|
244955
|
+
`ENTRY POINTS:`,
|
|
244956
|
+
...ep.map((e) => ` ${e.path}${e.symbol ? `::${e.symbol}` : ""} \u2014 ${e.reason}`),
|
|
244953
244957
|
``,
|
|
244954
|
-
`
|
|
244955
|
-
|
|
244956
|
-
|
|
244958
|
+
`CONSTRAINTS: ${constraints.join(" | ")}`,
|
|
244959
|
+
``,
|
|
244960
|
+
`THREAT: overall_risk=${Number(threat?.overall_risk_score ?? 0).toFixed(2)} | ${threat?.risk_summary ?? ""}`,
|
|
244961
|
+
blockers.length > 0 ? `BLOCKERS (${blockers.length}): ${blockers.slice(0, 3).map((b) => b.description ?? b).join(" | ")}` : `BLOCKERS: none`,
|
|
244962
|
+
warnings.length > 0 ? `WARNINGS (${warnings.length}): ${warnings.slice(0, 5).map((w) => w.description ?? w).join(" | ")}` : `WARNINGS: none`,
|
|
244963
|
+
``,
|
|
244964
|
+
findings.length > 0 ? `FINDINGS (${findings.length} total, top ${Math.min(findingLimit, findings.length)}):` : null,
|
|
244965
|
+
...findings.slice(0, findingLimit).map((f) => {
|
|
244966
|
+
const fi = f;
|
|
244967
|
+
return ` [${fi.severity ?? fi.type}] ${fi.file ?? fi.path} \u2014 ${fi.message ?? fi.description ?? ""}`;
|
|
244968
|
+
})
|
|
244969
|
+
].filter((l) => l !== null);
|
|
244970
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
244957
244971
|
}
|
|
244958
244972
|
|
|
244959
244973
|
// src/license/check.ts
|
|
@@ -244966,7 +244980,7 @@ function getFingerprint() {
|
|
|
244966
244980
|
const raw = `${(0, import_node_os.hostname)()}:${(0, import_node_os.userInfo)().username}`;
|
|
244967
244981
|
return (0, import_node_crypto.createHash)("sha256").update(raw).digest("hex").slice(0, 32);
|
|
244968
244982
|
}
|
|
244969
|
-
async function checkLicense() {
|
|
244983
|
+
async function checkLicense(tool = "unknown") {
|
|
244970
244984
|
if (PRO_KEY) {
|
|
244971
244985
|
try {
|
|
244972
244986
|
const res = await fetch(`${WORKER_URL}/v3/validate`, {
|
|
@@ -244990,14 +245004,14 @@ async function checkLicense() {
|
|
|
244990
245004
|
const res = await fetch(`${WORKER_URL}/v3/free-query`, {
|
|
244991
245005
|
method: "POST",
|
|
244992
245006
|
headers: { "Content-Type": "application/json" },
|
|
244993
|
-
body: JSON.stringify({ fingerprint: fp })
|
|
245007
|
+
body: JSON.stringify({ fingerprint: fp, tool })
|
|
244994
245008
|
});
|
|
244995
245009
|
const data = await res.json();
|
|
244996
245010
|
if (data.allowed) return { allowed: true, tier: "free", remaining: data.remaining };
|
|
244997
245011
|
return {
|
|
244998
245012
|
allowed: false,
|
|
244999
245013
|
tier: "blocked",
|
|
245000
|
-
reason: `Free tier limit reached (15 calls/24h). Upgrade at openkrak-web.vercel.app \
|
|
245014
|
+
reason: `Free tier limit reached (15 calls/24h). Upgrade at openkrak-web.vercel.app \xE2\u20AC\u201D $8/month unlimited.`
|
|
245001
245015
|
};
|
|
245002
245016
|
} catch {
|
|
245003
245017
|
return { allowed: true, tier: "free" };
|
|
@@ -245089,7 +245103,7 @@ server2.setRequestHandler(import_types.ListToolsRequestSchema, async () => ({
|
|
|
245089
245103
|
}));
|
|
245090
245104
|
server2.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
|
|
245091
245105
|
const { name, arguments: args } = request.params;
|
|
245092
|
-
const license = await checkLicense();
|
|
245106
|
+
const license = await checkLicense(name);
|
|
245093
245107
|
if (!license.allowed) {
|
|
245094
245108
|
return {
|
|
245095
245109
|
content: [{ type: "text", text: `OpenKrak: ${license.reason}` }],
|
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "openkrak-mcp",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "OpenKrak MCP Server - AI coding intelligence via Dorchester engine",
|
|
5
|
+
"bin": {
|
|
6
|
+
"openkrak-mcp": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup",
|
|
15
|
+
"dev": "tsx src/index.ts",
|
|
16
|
+
"start": "node dist/index.js",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^20.0.0",
|
|
24
|
+
"dorchester": "file:../engine-dorchester",
|
|
25
|
+
"tsup": "^8.0.0",
|
|
26
|
+
"tsx": "^4.0.0",
|
|
27
|
+
"typescript": "^5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
}
|
|
31
32
|
}
|