@inkog-io/mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +265 -0
- package/dist/api/client.d.ts +108 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +288 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/types.d.ts +286 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +21 -0
- package/dist/api/types.js.map +1 -0
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +130 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +203 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/audit-a2a.d.ts +20 -0
- package/dist/tools/audit-a2a.d.ts.map +1 -0
- package/dist/tools/audit-a2a.js +382 -0
- package/dist/tools/audit-a2a.js.map +1 -0
- package/dist/tools/audit-mcp.d.ts +16 -0
- package/dist/tools/audit-mcp.d.ts.map +1 -0
- package/dist/tools/audit-mcp.js +259 -0
- package/dist/tools/audit-mcp.js.map +1 -0
- package/dist/tools/compliance.d.ts +14 -0
- package/dist/tools/compliance.d.ts.map +1 -0
- package/dist/tools/compliance.js +255 -0
- package/dist/tools/compliance.js.map +1 -0
- package/dist/tools/explain.d.ts +14 -0
- package/dist/tools/explain.d.ts.map +1 -0
- package/dist/tools/explain.js +202 -0
- package/dist/tools/explain.js.map +1 -0
- package/dist/tools/governance.d.ts +16 -0
- package/dist/tools/governance.d.ts.map +1 -0
- package/dist/tools/governance.js +200 -0
- package/dist/tools/governance.js.map +1 -0
- package/dist/tools/index.d.ts +50 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +94 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/mlbom.d.ts +18 -0
- package/dist/tools/mlbom.d.ts.map +1 -0
- package/dist/tools/mlbom.js +344 -0
- package/dist/tools/mlbom.js.map +1 -0
- package/dist/tools/scan.d.ts +15 -0
- package/dist/tools/scan.d.ts.map +1 -0
- package/dist/tools/scan.js +270 -0
- package/dist/tools/scan.js.map +1 -0
- package/dist/utils/file-reader.d.ts +55 -0
- package/dist/utils/file-reader.d.ts.map +1 -0
- package/dist/utils/file-reader.js +269 -0
- package/dist/utils/file-reader.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkog_explain_finding Tool
|
|
3
|
+
*
|
|
4
|
+
* P1 - Finding Explanation and Remediation Guidance
|
|
5
|
+
*
|
|
6
|
+
* Provides detailed explanations for security findings including:
|
|
7
|
+
* - What the vulnerability is
|
|
8
|
+
* - Why it's dangerous
|
|
9
|
+
* - How to fix it
|
|
10
|
+
* - Code examples (vulnerable vs secure)
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { getClient, InkogAuthError, InkogNetworkError } from '../api/client.js';
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Schema
|
|
16
|
+
// =============================================================================
|
|
17
|
+
const ExplainArgsSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
finding_id: z
|
|
20
|
+
.string()
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Finding ID from scan results (e.g., "f8a3b2c1")'),
|
|
23
|
+
pattern: z
|
|
24
|
+
.string()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe('Pattern name: prompt-injection, infinite-loop, sql-injection-llm, token-bombing, hardcoded-credentials, missing-rate-limits, recursive-delegation, etc.'),
|
|
27
|
+
})
|
|
28
|
+
.refine((data) => data.finding_id !== undefined || data.pattern !== undefined, {
|
|
29
|
+
message: 'Either finding_id or pattern must be provided',
|
|
30
|
+
});
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Helpers
|
|
33
|
+
// =============================================================================
|
|
34
|
+
function formatSeverityBadge(severity) {
|
|
35
|
+
switch (severity) {
|
|
36
|
+
case 'CRITICAL':
|
|
37
|
+
return '🔴 CRITICAL';
|
|
38
|
+
case 'HIGH':
|
|
39
|
+
return '🟠 HIGH';
|
|
40
|
+
case 'MEDIUM':
|
|
41
|
+
return '🟡 MEDIUM';
|
|
42
|
+
case 'LOW':
|
|
43
|
+
return '🟢 LOW';
|
|
44
|
+
default:
|
|
45
|
+
return severity;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function formatRiskTier(tier) {
|
|
49
|
+
switch (tier) {
|
|
50
|
+
case 'vulnerability':
|
|
51
|
+
return '🔴 Exploitable Vulnerability';
|
|
52
|
+
case 'risk_pattern':
|
|
53
|
+
return '🟠 Risk Pattern';
|
|
54
|
+
case 'hardening':
|
|
55
|
+
return '🟡 Hardening Recommendation';
|
|
56
|
+
default:
|
|
57
|
+
return tier;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// =============================================================================
|
|
61
|
+
// Handler
|
|
62
|
+
// =============================================================================
|
|
63
|
+
async function explainHandler(rawArgs) {
|
|
64
|
+
// Validate arguments
|
|
65
|
+
const parseResult = ExplainArgsSchema.safeParse(rawArgs);
|
|
66
|
+
if (!parseResult.success) {
|
|
67
|
+
return {
|
|
68
|
+
content: [
|
|
69
|
+
{
|
|
70
|
+
type: 'text',
|
|
71
|
+
text: `Invalid arguments: ${parseResult.error.message}\n\nProvide either finding_id (from scan results) or pattern name.`,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
isError: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const args = parseResult.data;
|
|
78
|
+
try {
|
|
79
|
+
// Call Inkog API
|
|
80
|
+
const client = getClient();
|
|
81
|
+
const explainOptions = {};
|
|
82
|
+
if (args.finding_id !== undefined) {
|
|
83
|
+
explainOptions.findingId = args.finding_id;
|
|
84
|
+
}
|
|
85
|
+
if (args.pattern !== undefined) {
|
|
86
|
+
explainOptions.pattern = args.pattern;
|
|
87
|
+
}
|
|
88
|
+
const response = await client.explainFinding(explainOptions);
|
|
89
|
+
// Build formatted output
|
|
90
|
+
let output = '╔══════════════════════════════════════════════════════╗\n';
|
|
91
|
+
output += '║ 📖 Security Finding Explanation ║\n';
|
|
92
|
+
output += '╚══════════════════════════════════════════════════════╝\n\n';
|
|
93
|
+
// Title and metadata
|
|
94
|
+
output += `🔍 ${response.title}\n`;
|
|
95
|
+
output += ` Pattern: ${response.pattern}\n`;
|
|
96
|
+
output += ` Severity: ${formatSeverityBadge(response.severity)}\n`;
|
|
97
|
+
output += ` Category: ${formatRiskTier(response.riskTier)}\n`;
|
|
98
|
+
if (response.cwe !== undefined) {
|
|
99
|
+
output += ` CWE: ${response.cwe}\n`;
|
|
100
|
+
}
|
|
101
|
+
if (response.owaspLlm !== undefined) {
|
|
102
|
+
output += ` OWASP LLM: ${response.owaspLlm}\n`;
|
|
103
|
+
}
|
|
104
|
+
output += '\n';
|
|
105
|
+
// Description
|
|
106
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
107
|
+
output += '📝 DESCRIPTION\n\n';
|
|
108
|
+
output += response.description + '\n\n';
|
|
109
|
+
// Explanation
|
|
110
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
111
|
+
output += '🔬 WHY THIS IS DANGEROUS\n\n';
|
|
112
|
+
output += response.explanation + '\n\n';
|
|
113
|
+
// Impact
|
|
114
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
115
|
+
output += '💥 POTENTIAL IMPACT\n\n';
|
|
116
|
+
output += response.impact + '\n\n';
|
|
117
|
+
// Remediation steps
|
|
118
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
119
|
+
output += '🔧 HOW TO FIX\n\n';
|
|
120
|
+
for (const step of response.remediationSteps) {
|
|
121
|
+
output += `${step.order}. ${step.description}\n`;
|
|
122
|
+
if (step.codeExample !== undefined) {
|
|
123
|
+
const lang = step.language ?? '';
|
|
124
|
+
output += `\n\`\`\`${lang}\n${step.codeExample}\n\`\`\`\n\n`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Code examples
|
|
128
|
+
if (response.codeExamples !== undefined) {
|
|
129
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
130
|
+
output += '📝 CODE EXAMPLES\n\n';
|
|
131
|
+
output += '❌ Vulnerable:\n';
|
|
132
|
+
output += `\`\`\`${response.codeExamples.language}\n${response.codeExamples.vulnerable}\n\`\`\`\n\n`;
|
|
133
|
+
output += '✅ Secure:\n';
|
|
134
|
+
output += `\`\`\`${response.codeExamples.language}\n${response.codeExamples.secure}\n\`\`\`\n\n`;
|
|
135
|
+
}
|
|
136
|
+
// References
|
|
137
|
+
if (response.references.length > 0) {
|
|
138
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
139
|
+
output += '📚 REFERENCES\n\n';
|
|
140
|
+
for (const ref of response.references) {
|
|
141
|
+
output += `• ${ref}\n`;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
content: [
|
|
146
|
+
{
|
|
147
|
+
type: 'text',
|
|
148
|
+
text: output,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
if (error instanceof InkogAuthError) {
|
|
155
|
+
return {
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: 'text',
|
|
159
|
+
text: '🔐 API Key Required\n\nGet your free key at https://app.inkog.io',
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
isError: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (error instanceof InkogNetworkError) {
|
|
166
|
+
return {
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
type: 'text',
|
|
170
|
+
text: `Network error: ${error.message}`,
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
isError: true,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// =============================================================================
|
|
180
|
+
// Tool Definition
|
|
181
|
+
// =============================================================================
|
|
182
|
+
export const explainTool = {
|
|
183
|
+
tool: {
|
|
184
|
+
name: 'inkog_explain_finding',
|
|
185
|
+
description: 'Get detailed explanation and remediation guidance for a security finding or pattern. Includes what the issue is, why it\'s dangerous, step-by-step fixes, and code examples.',
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: 'object',
|
|
188
|
+
properties: {
|
|
189
|
+
finding_id: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: 'Finding ID from scan results (e.g., "f8a3b2c1")',
|
|
192
|
+
},
|
|
193
|
+
pattern: {
|
|
194
|
+
type: 'string',
|
|
195
|
+
description: 'Pattern name: prompt-injection, infinite-loop, sql-injection-llm, token-bombing, hardcoded-credentials, missing-rate-limits, recursive-delegation, etc.',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
handler: explainHandler,
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../../src/tools/explain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,UAAU,EAAE,CAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,C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,cAAc;CACxB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkog_verify_governance Tool
|
|
3
|
+
*
|
|
4
|
+
* P0 - AGENTS.md Governance Verification (THE MOAT)
|
|
5
|
+
*
|
|
6
|
+
* Validates that AGENTS.md declarations match actual code behavior.
|
|
7
|
+
* Detects governance mismatches like:
|
|
8
|
+
* - "Read-only" declared but code writes data
|
|
9
|
+
* - "No external API" declared but code makes HTTP requests
|
|
10
|
+
* - "Human approval required" declared but no approval gates in code
|
|
11
|
+
*
|
|
12
|
+
* This is Inkog's unique differentiator - no other tool does this.
|
|
13
|
+
*/
|
|
14
|
+
import type { ToolDefinition } from './index.js';
|
|
15
|
+
export declare const governanceTool: ToolDefinition;
|
|
16
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/tools/governance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAqM7D,eAAO,MAAM,cAAc,EAAE,cAiB5B,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkog_verify_governance Tool
|
|
3
|
+
*
|
|
4
|
+
* P0 - AGENTS.md Governance Verification (THE MOAT)
|
|
5
|
+
*
|
|
6
|
+
* Validates that AGENTS.md declarations match actual code behavior.
|
|
7
|
+
* Detects governance mismatches like:
|
|
8
|
+
* - "Read-only" declared but code writes data
|
|
9
|
+
* - "No external API" declared but code makes HTTP requests
|
|
10
|
+
* - "Human approval required" declared but no approval gates in code
|
|
11
|
+
*
|
|
12
|
+
* This is Inkog's unique differentiator - no other tool does this.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { getClient, InkogAuthError, InkogNetworkError } from '../api/client.js';
|
|
16
|
+
import { findAgentsMd, getRelativePaths, readDirectory } from '../utils/file-reader.js';
|
|
17
|
+
// =============================================================================
|
|
18
|
+
// Schema
|
|
19
|
+
// =============================================================================
|
|
20
|
+
const GovernanceArgsSchema = z.object({
|
|
21
|
+
path: z.string().describe('Path to directory containing AGENTS.md and agent code'),
|
|
22
|
+
});
|
|
23
|
+
// =============================================================================
|
|
24
|
+
// Helpers
|
|
25
|
+
// =============================================================================
|
|
26
|
+
function formatMismatch(mismatch) {
|
|
27
|
+
const icon = mismatch.severity === 'CRITICAL'
|
|
28
|
+
? '🔴'
|
|
29
|
+
: mismatch.severity === 'HIGH'
|
|
30
|
+
? '🟠'
|
|
31
|
+
: mismatch.severity === 'MEDIUM'
|
|
32
|
+
? '🟡'
|
|
33
|
+
: '🟢';
|
|
34
|
+
let output = `${icon} GOVERNANCE MISMATCH\n`;
|
|
35
|
+
output += ` 📍 ${mismatch.file}:${mismatch.line}\n`;
|
|
36
|
+
output += ` 📜 Declared: "${mismatch.declared}"\n`;
|
|
37
|
+
output += ` ⚠️ Actual: "${mismatch.actual}"\n`;
|
|
38
|
+
output += ` 💬 ${mismatch.description}`;
|
|
39
|
+
return output;
|
|
40
|
+
}
|
|
41
|
+
function formatCapabilityList(items, title, icon) {
|
|
42
|
+
if (items.length === 0) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
let output = `${icon} ${title}:\n`;
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
output += ` • ${item}\n`;
|
|
48
|
+
}
|
|
49
|
+
return output + '\n';
|
|
50
|
+
}
|
|
51
|
+
// =============================================================================
|
|
52
|
+
// Handler
|
|
53
|
+
// =============================================================================
|
|
54
|
+
async function governanceHandler(rawArgs) {
|
|
55
|
+
// Validate arguments
|
|
56
|
+
const parseResult = GovernanceArgsSchema.safeParse(rawArgs);
|
|
57
|
+
if (!parseResult.success) {
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'text',
|
|
62
|
+
text: `Invalid arguments: ${parseResult.error.message}`,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
isError: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const args = parseResult.data;
|
|
69
|
+
try {
|
|
70
|
+
// Check for AGENTS.md
|
|
71
|
+
const agentsMdPath = findAgentsMd(args.path);
|
|
72
|
+
// Read files from path
|
|
73
|
+
const readResult = readDirectory(args.path);
|
|
74
|
+
if (readResult.files.length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
content: [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: `No files found in: ${args.path}`,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
isError: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Get relative paths for cleaner output
|
|
86
|
+
const files = getRelativePaths(readResult.files, args.path);
|
|
87
|
+
// Call Inkog API
|
|
88
|
+
const client = getClient();
|
|
89
|
+
const response = await client.verifyGovernance(files);
|
|
90
|
+
// Build output
|
|
91
|
+
let output = '╔══════════════════════════════════════════════════════╗\n';
|
|
92
|
+
output += '║ 🏛️ AGENTS.md Governance Verification ║\n';
|
|
93
|
+
output += '╚══════════════════════════════════════════════════════╝\n\n';
|
|
94
|
+
// AGENTS.md status
|
|
95
|
+
if (response.hasAgentsMd) {
|
|
96
|
+
output += `✅ AGENTS.md found: ${response.agentsMdPath ?? agentsMdPath ?? 'AGENTS.md'}\n\n`;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
output += '⚠️ No AGENTS.md file found\n\n';
|
|
100
|
+
output +=
|
|
101
|
+
'AGENTS.md is a governance declaration file that describes what your agent\n';
|
|
102
|
+
output += 'can and cannot do. It helps ensure your agent behaves as documented.\n\n';
|
|
103
|
+
output += 'To create one, add an AGENTS.md file to your project root with:\n';
|
|
104
|
+
output += '- Capabilities: What the agent can do\n';
|
|
105
|
+
output += '- Limitations: What the agent cannot do\n';
|
|
106
|
+
output += '- Tools: What tools the agent has access to\n';
|
|
107
|
+
output += '- Security: Required security controls\n\n';
|
|
108
|
+
output +=
|
|
109
|
+
'Learn more: https://docs.inkog.io/governance/agents-md\n\n';
|
|
110
|
+
}
|
|
111
|
+
// Compliance score
|
|
112
|
+
output += `📊 Governance Score: ${response.complianceScore}/100\n\n`;
|
|
113
|
+
// Declared capabilities, limitations, tools
|
|
114
|
+
if (response.hasAgentsMd) {
|
|
115
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
116
|
+
output += '📜 DECLARED GOVERNANCE\n\n';
|
|
117
|
+
output += formatCapabilityList(response.declaredCapabilities, 'Capabilities', '✅');
|
|
118
|
+
output += formatCapabilityList(response.declaredLimitations, 'Limitations', '🚫');
|
|
119
|
+
output += formatCapabilityList(response.declaredTools, 'Tools', '🔧');
|
|
120
|
+
}
|
|
121
|
+
// Mismatches
|
|
122
|
+
if (response.mismatches.length > 0) {
|
|
123
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
124
|
+
output += `⚠️ GOVERNANCE MISMATCHES (${response.mismatches.length})\n\n`;
|
|
125
|
+
output += 'The following code behaviors do not match AGENTS.md declarations:\n\n';
|
|
126
|
+
for (const mismatch of response.mismatches) {
|
|
127
|
+
output += formatMismatch(mismatch) + '\n\n';
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else if (response.hasAgentsMd) {
|
|
131
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
132
|
+
output += '✅ No governance mismatches detected!\n\n';
|
|
133
|
+
output += 'Your agent code aligns with its AGENTS.md declarations.\n\n';
|
|
134
|
+
}
|
|
135
|
+
// Recommendations
|
|
136
|
+
if (response.recommendation !== undefined) {
|
|
137
|
+
output += '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n';
|
|
138
|
+
output += '💡 RECOMMENDATION\n\n';
|
|
139
|
+
output += response.recommendation + '\n';
|
|
140
|
+
}
|
|
141
|
+
// Footer
|
|
142
|
+
output += '\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
|
|
143
|
+
output += 'AGENTS.md verification powered by Inkog AI Security Platform\n';
|
|
144
|
+
output += 'Learn more: https://inkog.io/governance\n';
|
|
145
|
+
return {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: 'text',
|
|
149
|
+
text: output,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (error instanceof InkogAuthError) {
|
|
156
|
+
return {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: 'text',
|
|
160
|
+
text: '🔐 API Key Required\n\nTo use Inkog, you need an API key.\n\n1. Sign up for free at https://app.inkog.io\n2. Set your API key: export INKOG_API_KEY=sk_live_...\n3. Try again!',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
isError: true,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (error instanceof InkogNetworkError) {
|
|
167
|
+
return {
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: 'text',
|
|
171
|
+
text: `Network error: ${error.message}\n\nPlease check your internet connection and try again.`,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
isError: true,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// =============================================================================
|
|
181
|
+
// Tool Definition
|
|
182
|
+
// =============================================================================
|
|
183
|
+
export const governanceTool = {
|
|
184
|
+
tool: {
|
|
185
|
+
name: 'inkog_verify_governance',
|
|
186
|
+
description: "Validate that AGENTS.md declarations match actual code behavior. Detects governance mismatches like 'read-only declared but code writes data' or 'human approval required but no approval gates in code'. Essential for EU AI Act Article 14 compliance.",
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
properties: {
|
|
190
|
+
path: {
|
|
191
|
+
type: 'string',
|
|
192
|
+
description: 'Path to directory containing AGENTS.md and agent code',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
required: ['path'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
handler: governanceHandler,
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=governance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.js","sourceRoot":"","sources":["../../src/tools/governance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxF,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uDAAuD,CAAC;CACnF,CAAC,CAAC;AAIH,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,SAAS,cAAc,CAAC,QAA4B;IAClD,MAAM,IAAI,GACR,QAAQ,CAAC,QAAQ,KAAK,UAAU;QAC9B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,QAAQ,CAAC,QAAQ,KAAK,MAAM;YAC5B,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,QAAQ,CAAC,QAAQ,KAAK,QAAQ;gBAC9B,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,IAAI,CAAC;IAEf,IAAI,MAAM,GAAG,GAAG,IAAI,wBAAwB,CAAC;IAC7C,MAAM,IAAI,SAAS,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAA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C;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;YACpC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,gLAAgL;qBACvL;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;YACvC,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,kBAAkB,KAAK,CAAC,OAAO,0DAA0D;qBAChG;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,IAAI,EAAE;QACJ,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EACT,0PAA0P;QAC5P,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uDAAuD;iBACrE;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,CAAC;SACnB;KACF;IACD,OAAO,EAAE,iBAAiB;CAC3B,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all Inkog MCP tools.
|
|
5
|
+
* Each tool is a self-contained module that registers itself here.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - Tools are lazy-loaded to improve startup time
|
|
9
|
+
* - Each tool defines its own schema and handler
|
|
10
|
+
* - Registry provides a unified interface for the MCP server
|
|
11
|
+
*/
|
|
12
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
export interface ToolDefinition {
|
|
14
|
+
/** Tool metadata for MCP */
|
|
15
|
+
tool: Tool;
|
|
16
|
+
/** Handler function that processes tool calls */
|
|
17
|
+
handler: ToolHandler;
|
|
18
|
+
}
|
|
19
|
+
export type ToolHandler = (args: Record<string, unknown>) => Promise<ToolResult>;
|
|
20
|
+
export interface ToolResult {
|
|
21
|
+
content: {
|
|
22
|
+
type: 'text' | 'image' | 'resource';
|
|
23
|
+
text?: string;
|
|
24
|
+
data?: string;
|
|
25
|
+
mimeType?: string;
|
|
26
|
+
}[];
|
|
27
|
+
isError?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Register a tool with the registry
|
|
31
|
+
*/
|
|
32
|
+
export declare function registerTool(definition: ToolDefinition): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get a tool by name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTool(name: string): ToolDefinition | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Get all registered tools
|
|
39
|
+
*/
|
|
40
|
+
export declare function getAllTools(): ToolDefinition[];
|
|
41
|
+
/**
|
|
42
|
+
* Get tool metadata for MCP ListTools
|
|
43
|
+
*/
|
|
44
|
+
export declare function getToolList(): Tool[];
|
|
45
|
+
/**
|
|
46
|
+
* Call a tool by name
|
|
47
|
+
*/
|
|
48
|
+
export declare function callTool(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
49
|
+
export declare const registeredToolCount: number;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAM/D,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,iDAAiD;IACjD,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEjF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;IACJ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAQD;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,cAAc,GAAG,IAAI,CAE7D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAEhE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,cAAc,EAAE,CAE9C;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,EAAE,CAEpC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CA6B/F;AA2BD,eAAO,MAAM,mBAAmB,QAAoB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all Inkog MCP tools.
|
|
5
|
+
* Each tool is a self-contained module that registers itself here.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* - Tools are lazy-loaded to improve startup time
|
|
9
|
+
* - Each tool defines its own schema and handler
|
|
10
|
+
* - Registry provides a unified interface for the MCP server
|
|
11
|
+
*/
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Registry
|
|
14
|
+
// =============================================================================
|
|
15
|
+
const toolRegistry = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* Register a tool with the registry
|
|
18
|
+
*/
|
|
19
|
+
export function registerTool(definition) {
|
|
20
|
+
toolRegistry.set(definition.tool.name, definition);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get a tool by name
|
|
24
|
+
*/
|
|
25
|
+
export function getTool(name) {
|
|
26
|
+
return toolRegistry.get(name);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get all registered tools
|
|
30
|
+
*/
|
|
31
|
+
export function getAllTools() {
|
|
32
|
+
return Array.from(toolRegistry.values());
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get tool metadata for MCP ListTools
|
|
36
|
+
*/
|
|
37
|
+
export function getToolList() {
|
|
38
|
+
return getAllTools().map((def) => def.tool);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Call a tool by name
|
|
42
|
+
*/
|
|
43
|
+
export async function callTool(name, args) {
|
|
44
|
+
const tool = getTool(name);
|
|
45
|
+
if (tool === undefined) {
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
text: `Error: Unknown tool "${name}"`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return await tool.handler(args);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
type: 'text',
|
|
65
|
+
text: `Error: ${message}`,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
isError: true,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// =============================================================================
|
|
73
|
+
// Tool Registration
|
|
74
|
+
// =============================================================================
|
|
75
|
+
// Import and register all tools
|
|
76
|
+
// This is done at module load time to ensure all tools are available
|
|
77
|
+
import { scanTool } from './scan.js';
|
|
78
|
+
import { governanceTool } from './governance.js';
|
|
79
|
+
import { complianceTool } from './compliance.js';
|
|
80
|
+
import { explainTool } from './explain.js';
|
|
81
|
+
import { auditMcpTool } from './audit-mcp.js';
|
|
82
|
+
import { mlbomTool } from './mlbom.js';
|
|
83
|
+
import { auditA2aTool } from './audit-a2a.js';
|
|
84
|
+
// Register all tools
|
|
85
|
+
registerTool(scanTool);
|
|
86
|
+
registerTool(governanceTool);
|
|
87
|
+
registerTool(complianceTool);
|
|
88
|
+
registerTool(explainTool);
|
|
89
|
+
registerTool(auditMcpTool);
|
|
90
|
+
registerTool(mlbomTool);
|
|
91
|
+
registerTool(auditA2aTool);
|
|
92
|
+
// Export tool count for debugging
|
|
93
|
+
export const registeredToolCount = toolRegistry.size;
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2BH,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF,MAAM,YAAY,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAA0B;IACrD,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,WAAW,EAAE,CAAC,GAAG,CAAC,C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AE9C,qBAAqB;AACrB,YAAY,CAAC,QAAQ,CAAC,CAAC;AACvB,YAAY,CAAC,cAAc,CAAC,CAAC;AAC7B,YAAY,CAAC,cAAc,CAAC,CAAC;AAC7B,YAAY,CAAC,WAAW,CAAC,CAAC;AAC1B,YAAY,CAAC,YAAY,CAAC,CAAC;AAC3B,YAAY,CAAC,SAAS,CAAC,CAAC;AACxB,YAAY,CAAC,YAAY,CAAC,CAAC;AAE3B,kCAAkC;AAClC,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkog_generate_mlbom Tool
|
|
3
|
+
*
|
|
4
|
+
* P1 - Machine Learning Bill of Materials (MLBOM) Generation
|
|
5
|
+
*
|
|
6
|
+
* Generates a comprehensive inventory of all ML/AI components in an agent system:
|
|
7
|
+
* - Models (OpenAI, Anthropic, local models, etc.)
|
|
8
|
+
* - Tools (function calls, APIs, integrations)
|
|
9
|
+
* - Data sources (databases, vector stores, file systems)
|
|
10
|
+
* - Frameworks (LangChain, CrewAI, LangGraph, etc.)
|
|
11
|
+
* - Dependencies (pip, npm packages)
|
|
12
|
+
*
|
|
13
|
+
* Output formats: CycloneDX (recommended), SPDX, JSON
|
|
14
|
+
* Gartner-recommended capability for AI supply chain visibility.
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolDefinition } from './index.js';
|
|
17
|
+
export declare const mlbomTool: ToolDefinition;
|
|
18
|
+
//# sourceMappingURL=mlbom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mlbom.d.ts","sourceRoot":"","sources":["../../src/tools/mlbom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,YAAY,CAAC;AAyV7D,eAAO,MAAM,SAAS,EAAE,cA4BvB,CAAC"}
|