@codacy/codacy-mcp 0.1.1 → 0.2.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/dist/index.js +300 -4
- package/package.json +1 -1
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, CoverageService, } 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,7 +264,248 @@ const getFileCoverageTool = {
|
|
|
264
264
|
},
|
|
265
265
|
},
|
|
266
266
|
};
|
|
267
|
-
|
|
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
|
+
//PR endpoints
|
|
301
|
+
const listRepositoryPullRequestsTool = {
|
|
302
|
+
name: 'codacy_list_repository_pull_requests',
|
|
303
|
+
description: 'List pull requests from a repository that the user has access to. You can search this endpoint for either last-updated (default), impact or merged',
|
|
304
|
+
inputSchema: {
|
|
305
|
+
type: 'object',
|
|
306
|
+
properties: {
|
|
307
|
+
provider: {
|
|
308
|
+
type: 'string',
|
|
309
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
310
|
+
},
|
|
311
|
+
organization: {
|
|
312
|
+
type: 'string',
|
|
313
|
+
description: 'Organization name on the Git provider',
|
|
314
|
+
},
|
|
315
|
+
repository: {
|
|
316
|
+
type: 'string',
|
|
317
|
+
description: 'Repository name on the Git provider organization',
|
|
318
|
+
},
|
|
319
|
+
includeNotAnalyzed: {
|
|
320
|
+
type: 'boolean',
|
|
321
|
+
description: 'If true, includes pull requests that have not been analyzed',
|
|
322
|
+
},
|
|
323
|
+
cursor: {
|
|
324
|
+
type: 'string',
|
|
325
|
+
description: 'Pagination cursor for next page of results',
|
|
326
|
+
},
|
|
327
|
+
limit: {
|
|
328
|
+
type: 'number',
|
|
329
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
330
|
+
default: 100,
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
const listPullRequestIssuesTool = {
|
|
336
|
+
name: 'codacy_list_pull_request_issues',
|
|
337
|
+
description: 'Returns a list of issues found in a pull request. We can request either new or fixed issues.',
|
|
338
|
+
inputSchema: {
|
|
339
|
+
type: 'object',
|
|
340
|
+
properties: {
|
|
341
|
+
provider: {
|
|
342
|
+
type: 'string',
|
|
343
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
344
|
+
},
|
|
345
|
+
organization: {
|
|
346
|
+
type: 'string',
|
|
347
|
+
description: 'Organization name on the Git provider',
|
|
348
|
+
},
|
|
349
|
+
repository: {
|
|
350
|
+
type: 'string',
|
|
351
|
+
description: 'Repository name on the Git provider organization',
|
|
352
|
+
},
|
|
353
|
+
pullRequestNumber: {
|
|
354
|
+
type: 'number',
|
|
355
|
+
description: 'Pull request number',
|
|
356
|
+
},
|
|
357
|
+
status: {
|
|
358
|
+
type: 'string',
|
|
359
|
+
description: 'Filter issues by status. Accepted values: all, new, fixed.',
|
|
360
|
+
},
|
|
361
|
+
onlyPotential: {
|
|
362
|
+
type: 'boolean',
|
|
363
|
+
description: 'If true, retrieves only potential issues',
|
|
364
|
+
},
|
|
365
|
+
cursor: {
|
|
366
|
+
type: 'string',
|
|
367
|
+
description: 'Pagination cursor for next page of results',
|
|
368
|
+
},
|
|
369
|
+
limit: {
|
|
370
|
+
type: 'number',
|
|
371
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
372
|
+
default: 100,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
const getRepositoryPullRequestFilesCoverageTool = {
|
|
378
|
+
name: 'codacy_get_repository_pull_request_files_coverage',
|
|
379
|
+
description: 'Get coverage information for all files in a pull request.',
|
|
380
|
+
inputSchema: {
|
|
381
|
+
type: 'object',
|
|
382
|
+
properties: {
|
|
383
|
+
provider: {
|
|
384
|
+
type: 'string',
|
|
385
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
386
|
+
},
|
|
387
|
+
organization: {
|
|
388
|
+
type: 'string',
|
|
389
|
+
description: 'Organization name on the Git provider',
|
|
390
|
+
},
|
|
391
|
+
repository: {
|
|
392
|
+
type: 'string',
|
|
393
|
+
description: 'Repository name on the Git provider organization',
|
|
394
|
+
},
|
|
395
|
+
pullRequestNumber: {
|
|
396
|
+
type: 'number',
|
|
397
|
+
description: 'Pull request number',
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
const searchSecurityItemsTool = {
|
|
403
|
+
name: 'codacy_list_srm_items',
|
|
404
|
+
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.`,
|
|
405
|
+
inputSchema: {
|
|
406
|
+
type: 'object',
|
|
407
|
+
properties: {
|
|
408
|
+
provider: {
|
|
409
|
+
type: 'string',
|
|
410
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
411
|
+
},
|
|
412
|
+
organization: {
|
|
413
|
+
type: 'string',
|
|
414
|
+
description: 'Organization name',
|
|
415
|
+
},
|
|
416
|
+
cursor: {
|
|
417
|
+
type: 'string',
|
|
418
|
+
description: 'Pagination cursor for next page of results',
|
|
419
|
+
},
|
|
420
|
+
limit: {
|
|
421
|
+
type: 'number',
|
|
422
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
423
|
+
default: 100,
|
|
424
|
+
},
|
|
425
|
+
sort: {
|
|
426
|
+
type: 'string',
|
|
427
|
+
description: 'Sort SRM items by. Accepted values: Status, DetectedAt',
|
|
428
|
+
},
|
|
429
|
+
direction: {
|
|
430
|
+
type: 'string',
|
|
431
|
+
description: 'Sort direction (ascending or descending). Accepted values: asc, desc',
|
|
432
|
+
},
|
|
433
|
+
body: {
|
|
434
|
+
type: 'object',
|
|
435
|
+
description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
|
|
436
|
+
properties: {
|
|
437
|
+
repositories: {
|
|
438
|
+
type: 'array',
|
|
439
|
+
description: 'Repository names',
|
|
440
|
+
},
|
|
441
|
+
priorities: {
|
|
442
|
+
description: 'Array of security issue priorities/severities to filter by.',
|
|
443
|
+
type: 'array',
|
|
444
|
+
items: {
|
|
445
|
+
type: 'string',
|
|
446
|
+
enum: ['Low', 'Medium', 'High', 'Critical'],
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
statuses: {
|
|
450
|
+
type: 'array',
|
|
451
|
+
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',
|
|
452
|
+
items: {
|
|
453
|
+
type: 'string',
|
|
454
|
+
enum: ['OnTrack', 'DueSoon', 'Overdue', 'ClosedOnTime', 'ClosedLate', 'Ignored'],
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
categories: {
|
|
458
|
+
description: 'Array of security categories to filter by.',
|
|
459
|
+
type: 'array',
|
|
460
|
+
items: {
|
|
461
|
+
type: 'string',
|
|
462
|
+
enum: securityCategories,
|
|
463
|
+
},
|
|
464
|
+
note: "_other_ can be used to search for issues that don't have a security category",
|
|
465
|
+
},
|
|
466
|
+
scanTypes: {
|
|
467
|
+
description: 'Array of security scan types to filter by.',
|
|
468
|
+
type: 'array',
|
|
469
|
+
items: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
enum: Object.keys(securityScanTypes),
|
|
472
|
+
},
|
|
473
|
+
mapping: securityScanTypes,
|
|
474
|
+
},
|
|
475
|
+
segments: {
|
|
476
|
+
type: 'array',
|
|
477
|
+
description: 'Set of segments ids (type number). Segment is a Codacy concept that groups repositories by different criteria',
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
const getPullRequestGitDiffTool = {
|
|
485
|
+
name: 'codacy_get_pull_request_git_diff',
|
|
486
|
+
description: 'Returns the human-readable Git diff of a pull request',
|
|
487
|
+
inputSchema: {
|
|
488
|
+
type: 'object',
|
|
489
|
+
properties: {
|
|
490
|
+
provider: {
|
|
491
|
+
type: 'string',
|
|
492
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
493
|
+
},
|
|
494
|
+
organization: {
|
|
495
|
+
type: 'string',
|
|
496
|
+
description: 'Organization name on the Git provider',
|
|
497
|
+
},
|
|
498
|
+
repository: {
|
|
499
|
+
type: 'string',
|
|
500
|
+
description: 'Repository name on the Git provider organization',
|
|
501
|
+
},
|
|
502
|
+
pullRequestNumber: {
|
|
503
|
+
type: 'number',
|
|
504
|
+
description: 'Pull request number',
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
};
|
|
268
509
|
const listOrganizationRepositoriesHandler = async (args) => {
|
|
269
510
|
const { provider, organization, limit, cursor } = args;
|
|
270
511
|
return await OrganizationService.listOrganizationRepositories(provider, organization, cursor, limit);
|
|
@@ -275,7 +516,7 @@ const listFilesHandler = async (args) => {
|
|
|
275
516
|
};
|
|
276
517
|
const getFileIssuesHandler = async (args) => {
|
|
277
518
|
const { provider, organization, repository, fileId, limit, cursor } = args;
|
|
278
|
-
return await RepositoryService.getFileIssues(provider, organization, repository, fileId,
|
|
519
|
+
return await RepositoryService.getFileIssues(provider, organization, repository, fileId, cursor, limit);
|
|
279
520
|
};
|
|
280
521
|
const getFileCoverageHandler = async (args) => {
|
|
281
522
|
const { provider, organization, repository, fileId } = args;
|
|
@@ -285,6 +526,26 @@ const searchRepositoryIssuesHandler = async (args) => {
|
|
|
285
526
|
const { provider, organization, repository, limit, cursor, body } = args;
|
|
286
527
|
return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
|
|
287
528
|
};
|
|
529
|
+
const listRepositoryPullRequestsHandler = async (args) => {
|
|
530
|
+
const { provider, organization, repository, search, includeNotAnalyzed, cursor, limit } = args;
|
|
531
|
+
return await AnalysisService.listRepositoryPullRequests(provider, organization, repository, limit, cursor, search, includeNotAnalyzed);
|
|
532
|
+
};
|
|
533
|
+
const searchSecurityItemsHandler = async (args) => {
|
|
534
|
+
const { provider, organization, cursor, limit, sort, direction, body } = args;
|
|
535
|
+
return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, body);
|
|
536
|
+
};
|
|
537
|
+
const listPullRequestIssuesHandler = async (args) => {
|
|
538
|
+
const { provider, organization, repository, pullRequestNumber, status, onlyPotential, cursor, limit, } = args;
|
|
539
|
+
return await AnalysisService.listPullRequestIssues(provider, organization, repository, pullRequestNumber, status, onlyPotential, cursor, limit);
|
|
540
|
+
};
|
|
541
|
+
const getRepositoryPullRequestFilesCoverageHandler = async (args) => {
|
|
542
|
+
const { provider, organization, repository, pullRequestNumber } = args;
|
|
543
|
+
return await CoverageService.getRepositoryPullRequestFilesCoverage(provider, organization, repository, pullRequestNumber);
|
|
544
|
+
};
|
|
545
|
+
const getPullRequestGitDiffHandler = async (args) => {
|
|
546
|
+
const { provider, organization, repository, pullRequestNumber } = args;
|
|
547
|
+
return await CoverageService.getPullRequestGitDiff(provider, organization, repository, pullRequestNumber);
|
|
548
|
+
};
|
|
288
549
|
// Register tools
|
|
289
550
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
290
551
|
return {
|
|
@@ -294,6 +555,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
294
555
|
listFilesTool,
|
|
295
556
|
getFileIssuesTool,
|
|
296
557
|
getFileCoverageTool,
|
|
558
|
+
searchSecurityItemsTool,
|
|
559
|
+
listRepositoryPullRequestsTool,
|
|
560
|
+
listPullRequestIssuesTool,
|
|
561
|
+
getRepositoryPullRequestFilesCoverageTool,
|
|
562
|
+
getPullRequestGitDiffTool,
|
|
297
563
|
],
|
|
298
564
|
};
|
|
299
565
|
});
|
|
@@ -334,6 +600,36 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
334
600
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
335
601
|
};
|
|
336
602
|
}
|
|
603
|
+
case 'codacy_list_repository_pull_requests': {
|
|
604
|
+
const result = await listRepositoryPullRequestsHandler(request.params.arguments);
|
|
605
|
+
return {
|
|
606
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
case 'codacy_list_srm_items': {
|
|
610
|
+
const result = await searchSecurityItemsHandler(request.params.arguments);
|
|
611
|
+
return {
|
|
612
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
case 'codacy_list_pull_request_issues': {
|
|
616
|
+
const result = await listPullRequestIssuesHandler(request.params.arguments);
|
|
617
|
+
return {
|
|
618
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
case 'codacy_get_repository_pull_request_files_coverage': {
|
|
622
|
+
const result = await getRepositoryPullRequestFilesCoverageHandler(request.params.arguments);
|
|
623
|
+
return {
|
|
624
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
case 'codacy_get_pull_request_git_diff': {
|
|
628
|
+
const result = await getPullRequestGitDiffHandler(request.params.arguments);
|
|
629
|
+
return {
|
|
630
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
631
|
+
};
|
|
632
|
+
}
|
|
337
633
|
default:
|
|
338
634
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
339
635
|
}
|