@codacy/codacy-mcp 0.1.0 → 0.2.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/dist/index.js +128 -2
- package/package.json +2 -4
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
-
import { OpenAPI, OrganizationService, RepositoryService, AnalysisService, } from './src/api/client/index.js';
|
|
5
|
+
import { OpenAPI, OrganizationService, RepositoryService, AnalysisService, SecurityService, } from './src/api/client/index.js';
|
|
6
6
|
OpenAPI.BASE = 'https://app.codacy.com/api/v3';
|
|
7
7
|
OpenAPI.HEADERS = {
|
|
8
8
|
'api-token': process.env.CODACY_ACCOUNT_TOKEN || '',
|
|
@@ -101,7 +101,7 @@ const listOrganizationRepositoriesTool = {
|
|
|
101
101
|
};
|
|
102
102
|
const searchRepositoryIssuesTool = {
|
|
103
103
|
name: 'codacy_list_repository_issues',
|
|
104
|
-
description: '
|
|
104
|
+
description: 'Lists and filters code quality issues in a repository. This is the primary tool for investigating general code quality concerns (e.g. best practices, performance, complexity, style) but NOT security issues. For security-related issues, use the SRM items tool instead. Features include:\n\n- Pagination support for handling large result sets\n- Filtering by multiple criteria including severity, category, and language\n- Author-based filtering for accountability\n- Branch-specific analysis\n- Pattern-based searching\n\nCommon use cases:\n- Code quality audits\n- Technical debt assessment\n- Style guide compliance checks\n- Performance issue investigation\n- Complexity analysis',
|
|
105
105
|
inputSchema: {
|
|
106
106
|
type: 'object',
|
|
107
107
|
properties: {
|
|
@@ -264,6 +264,121 @@ const getFileCoverageTool = {
|
|
|
264
264
|
},
|
|
265
265
|
},
|
|
266
266
|
};
|
|
267
|
+
const securityStatuses = {
|
|
268
|
+
Open: ['OnTrack', 'DueSoon', 'Overdue'],
|
|
269
|
+
Closed: ['ClosedOnTime', 'ClosedLate', 'Ignored'],
|
|
270
|
+
};
|
|
271
|
+
const securityCategories = [
|
|
272
|
+
'Auth',
|
|
273
|
+
'CommandInjection',
|
|
274
|
+
'Cookies',
|
|
275
|
+
'Cryptography',
|
|
276
|
+
'CSRF',
|
|
277
|
+
'DoS',
|
|
278
|
+
'FileAccess',
|
|
279
|
+
'HTTP',
|
|
280
|
+
'InputValidation',
|
|
281
|
+
'InsecureModulesLibraries',
|
|
282
|
+
'InsecureStorage',
|
|
283
|
+
'Other',
|
|
284
|
+
'Regex',
|
|
285
|
+
'SQLInjection',
|
|
286
|
+
'UnexpectedBehaviour',
|
|
287
|
+
'Visibility',
|
|
288
|
+
'XSS',
|
|
289
|
+
'_other_',
|
|
290
|
+
];
|
|
291
|
+
const securityScanTypes = {
|
|
292
|
+
SAST: 'Code scanning',
|
|
293
|
+
Secrets: 'Secret scanning',
|
|
294
|
+
SCA: 'Dependency scanning',
|
|
295
|
+
IaC: 'Infrastructure-as-code scanning',
|
|
296
|
+
CICD: 'CI/CD scanning',
|
|
297
|
+
DAST: 'Dynamic Application Security Testing',
|
|
298
|
+
PenTesting: 'Penetration testing',
|
|
299
|
+
};
|
|
300
|
+
const searchSecurityItemsTool = {
|
|
301
|
+
name: 'codacy_list_srm_items',
|
|
302
|
+
description: `Primary tool to list security items/issues/vulnerabilities/findings, results are related to the organization security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(securityScanTypes).join(', ')} security issues. Provides advanced filtering by security categories, priorities, and scan types. Use this as the first tool when investigating security or compliance concerns. Map the results statuses as open issues: ${securityStatuses.Open.join(', ')}; and closed issues: ${securityStatuses.Closed.join(', ')}. Prioritize the open issues as the most important ones in the results.`,
|
|
303
|
+
inputSchema: {
|
|
304
|
+
type: 'object',
|
|
305
|
+
properties: {
|
|
306
|
+
provider: {
|
|
307
|
+
type: 'string',
|
|
308
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
309
|
+
},
|
|
310
|
+
organization: {
|
|
311
|
+
type: 'string',
|
|
312
|
+
description: 'Organization name',
|
|
313
|
+
},
|
|
314
|
+
cursor: {
|
|
315
|
+
type: 'string',
|
|
316
|
+
description: 'Pagination cursor for next page of results',
|
|
317
|
+
},
|
|
318
|
+
limit: {
|
|
319
|
+
type: 'number',
|
|
320
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
321
|
+
default: 100,
|
|
322
|
+
},
|
|
323
|
+
sort: {
|
|
324
|
+
type: 'string',
|
|
325
|
+
description: 'Sort SRM items by. Accepted values: Status, DetectedAt',
|
|
326
|
+
},
|
|
327
|
+
direction: {
|
|
328
|
+
type: 'string',
|
|
329
|
+
description: 'Sort direction (ascending or descending). Accepted values: asc, desc',
|
|
330
|
+
},
|
|
331
|
+
body: {
|
|
332
|
+
type: 'object',
|
|
333
|
+
description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
|
|
334
|
+
properties: {
|
|
335
|
+
repositories: {
|
|
336
|
+
type: 'array',
|
|
337
|
+
description: 'Repository names',
|
|
338
|
+
},
|
|
339
|
+
priorities: {
|
|
340
|
+
description: 'Array of security issue priorities/severities to filter by.',
|
|
341
|
+
type: 'array',
|
|
342
|
+
items: {
|
|
343
|
+
type: 'string',
|
|
344
|
+
enum: ['Low', 'Medium', 'High', 'Critical'],
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
statuses: {
|
|
348
|
+
type: 'array',
|
|
349
|
+
description: 'Array of security issue statuses to filter by. Must be one or more of the following values:\n\nOpen issues:\n- OnTrack\n- DueSoon\n- Overdue\n\nClosed issues:\n- ClosedOnTime\n- ClosedLate\n- Ignored',
|
|
350
|
+
items: {
|
|
351
|
+
type: 'string',
|
|
352
|
+
enum: ['OnTrack', 'DueSoon', 'Overdue', 'ClosedOnTime', 'ClosedLate', 'Ignored'],
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
categories: {
|
|
356
|
+
description: 'Array of security categories to filter by.',
|
|
357
|
+
type: 'array',
|
|
358
|
+
items: {
|
|
359
|
+
type: 'string',
|
|
360
|
+
enum: securityCategories,
|
|
361
|
+
},
|
|
362
|
+
note: "_other_ can be used to search for issues that don't have a security category",
|
|
363
|
+
},
|
|
364
|
+
scanTypes: {
|
|
365
|
+
description: 'Array of security scan types to filter by.',
|
|
366
|
+
type: 'array',
|
|
367
|
+
items: {
|
|
368
|
+
type: 'string',
|
|
369
|
+
enum: Object.keys(securityScanTypes),
|
|
370
|
+
},
|
|
371
|
+
mapping: securityScanTypes,
|
|
372
|
+
},
|
|
373
|
+
segments: {
|
|
374
|
+
type: 'array',
|
|
375
|
+
description: 'Set of segments ids (type number). Segment is a Codacy concept that groups repositories by different criteria',
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
};
|
|
267
382
|
// Handlers
|
|
268
383
|
const listOrganizationRepositoriesHandler = async (args) => {
|
|
269
384
|
const { provider, organization, limit, cursor } = args;
|
|
@@ -285,6 +400,10 @@ const searchRepositoryIssuesHandler = async (args) => {
|
|
|
285
400
|
const { provider, organization, repository, limit, cursor, body } = args;
|
|
286
401
|
return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
|
|
287
402
|
};
|
|
403
|
+
const searchSecurityItemsHandler = async (args) => {
|
|
404
|
+
const { provider, organization, cursor, limit, sort, direction, body } = args;
|
|
405
|
+
return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, body);
|
|
406
|
+
};
|
|
288
407
|
// Register tools
|
|
289
408
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
290
409
|
return {
|
|
@@ -294,6 +413,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
294
413
|
listFilesTool,
|
|
295
414
|
getFileIssuesTool,
|
|
296
415
|
getFileCoverageTool,
|
|
416
|
+
searchSecurityItemsTool,
|
|
297
417
|
],
|
|
298
418
|
};
|
|
299
419
|
});
|
|
@@ -334,6 +454,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
334
454
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
335
455
|
};
|
|
336
456
|
}
|
|
457
|
+
case 'codacy_list_srm_items': {
|
|
458
|
+
const result = await searchSecurityItemsHandler(request.params.arguments);
|
|
459
|
+
return {
|
|
460
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
461
|
+
};
|
|
462
|
+
}
|
|
337
463
|
default:
|
|
338
464
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
339
465
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/codacy-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Codacy MCP server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Codacy",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc && shx chmod +x dist/*.js",
|
|
23
|
-
"prepare": "npm run build && husky install",
|
|
24
23
|
"watch": "tsc --watch",
|
|
25
24
|
"fetch-api": "curl https://artifacts.codacy.com/api/codacy-api/42.0.0/apiv3.yaml -o ./api-v3/api-swagger.yaml --create-dirs",
|
|
26
25
|
"generate-api": "rm -rf ./src/api/client && openapi --input ./api-v3/api-swagger.yaml --output ./src/api/client --useUnionTypes --indent 2 --client fetch --importExtension",
|
|
@@ -28,8 +27,7 @@
|
|
|
28
27
|
"lint": "eslint . --ext .ts",
|
|
29
28
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
30
29
|
"format": "prettier --write \"**/*.{ts,json,md}\"",
|
|
31
|
-
"format:check": "prettier --check \"**/*.{ts,json,md}\""
|
|
32
|
-
"postinstall": "npm run update-api"
|
|
30
|
+
"format:check": "prettier --check \"**/*.{ts,json,md}\""
|
|
33
31
|
},
|
|
34
32
|
"dependencies": {
|
|
35
33
|
"@modelcontextprotocol/sdk": "1.0.1",
|