@codacy/codacy-mcp 0.2.0 → 0.2.2

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.
Files changed (3) hide show
  1. package/README.md +56 -25
  2. package/dist/index.js +173 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -6,31 +6,62 @@ MCP Server for the Codacy API, enabling access to repositories, files, quality,
6
6
 
7
7
  ## Tools
8
8
 
9
+ The following tools are available through the Codacy MCP Server:
10
+
11
+ ### Repository Management
12
+ - `codacy_list_repositories`: List repositories in an organization with pagination support.
13
+
14
+ ### Code Quality and Analysis
15
+ - `codacy_list_repository_issues`: 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:
16
+ - Pagination support for handling large result sets
17
+ - Filtering by multiple criteria including severity, category, and language
18
+ - Author-based filtering for accountability
19
+ - Branch-specific analysis
20
+ - Pattern-based searching
21
+
22
+ Common use cases:
23
+ - Code quality audits
24
+ - Technical debt assessment
25
+ - Style guide compliance checks
26
+ - Performance issue investigation
27
+ - Complexity analysis
28
+
29
+ ### File Management
30
+ - `codacy_list_files`: List files in a repository with pagination support.
31
+ - `codacy_get_file_issues`: Get the issue list for a file in a repository.
32
+ - `codacy_get_file_coverage`: Get coverage information for a file in the head commit of a repository branch.
33
+
34
+ ### Security Analysis
35
+ - `codacy_list_srm_items`: Primary tool to list security items/issues/vulnerabilities/findings. Results are related to the organization security and risk management (SRM) dashboard on Codacy. Provides comprehensive security analysis including:
36
+ - SAST (Code scanning)
37
+ - Secrets (Secret scanning)
38
+ - SCA (Dependency scanning)
39
+ - IaC (Infrastructure-as-code scanning)
40
+ - CICD (CI/CD scanning)
41
+ - DAST (Dynamic Application Security Testing)
42
+ - PenTesting (Penetration testing)
43
+
44
+ Use this as the first tool when investigating security or compliance concerns.
45
+
46
+ ### Pull Request Analysis
47
+ - `codacy_list_repository_pull_requests`: 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.
48
+ - `codacy_list_pull_request_issues`: Returns a list of issues found in a pull request. We can request either new or fixed issues.
49
+ - `codacy_get_repository_pull_request_files_coverage`: Get coverage information for all files in a pull request.
50
+ - `codacy_get_pull_request_git_diff`: Returns the human-readable Git diff of a pull request.
51
+
52
+ For detailed information about the parameters and filtering options available for each tool, please refer to the [Available Codacy API Actions](#available-codacy-api-actions) section below.
53
+
9
54
  ## Setup
10
55
 
11
56
  ### Personal API Access Token
12
57
 
13
58
  Get your Codacy's Account API Token from your [Codacy Account](https://app.codacy.com/account/access-management).
14
59
 
15
- ### Usage with Claude Desktop
16
-
17
- To use this with Claude Desktop, add the following to your `claude_desktop_config.json`:
60
+ ### Usage
18
61
 
19
- #### Docker
20
-
21
- ```json
22
- {
23
- "mcpServers": {
24
- "codacy": {
25
- "command": "docker",
26
- "args": ["run", "-i", "--rm", "-e", "CODACY_ACCOUNT_TOKEN", "mcp/codacy"],
27
- "env": {
28
- "CODACY_ACCOUNT_TOKEN": "<YOUR_TOKEN>"
29
- }
30
- }
31
- }
32
- }
33
- ```
62
+ Depending on what are you connecting the MCP Server to, you can use the following methods:
63
+ - Cursor: edit the `.cursor/mcp.json` file to add the following
64
+ - Claude Desktop: edit the `claude_desktop_config.json` file to add the following
34
65
 
35
66
  ### NPX
36
67
 
@@ -50,7 +81,11 @@ To use this with Claude Desktop, add the following to your `claude_desktop_confi
50
81
 
51
82
  ### Node (when using NVM)
52
83
 
53
- When using NVM, NPX won't work. You can use Node directly:
84
+ When using NVM with Claude Desktop, NPX won't work. You should first install the MCP Server globally, and thenuse Node directly:
85
+
86
+ ```bash
87
+ npm install -g @codacy/codacy-mcp
88
+ ```
54
89
 
55
90
  ```json
56
91
  {
@@ -71,15 +106,11 @@ When using NVM, NPX won't work. You can use Node directly:
71
106
  Local:
72
107
 
73
108
  ```bash
109
+ npm install
110
+ npm run update-api
74
111
  npm run build
75
112
  ```
76
113
 
77
- Docker build:
78
-
79
- ```bash
80
- docker build -t mcp/codacy -f src/codacy/Dockerfile .
81
- ```
82
-
83
114
  ## License
84
115
 
85
116
  This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.
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, SecurityService, } 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 || '',
@@ -297,6 +297,108 @@ const securityScanTypes = {
297
297
  DAST: 'Dynamic Application Security Testing',
298
298
  PenTesting: 'Penetration testing',
299
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
+ };
300
402
  const searchSecurityItemsTool = {
301
403
  name: 'codacy_list_srm_items',
302
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.`,
@@ -379,7 +481,31 @@ const searchSecurityItemsTool = {
379
481
  },
380
482
  },
381
483
  };
382
- // Handlers
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
+ };
383
509
  const listOrganizationRepositoriesHandler = async (args) => {
384
510
  const { provider, organization, limit, cursor } = args;
385
511
  return await OrganizationService.listOrganizationRepositories(provider, organization, cursor, limit);
@@ -390,7 +516,7 @@ const listFilesHandler = async (args) => {
390
516
  };
391
517
  const getFileIssuesHandler = async (args) => {
392
518
  const { provider, organization, repository, fileId, limit, cursor } = args;
393
- return await RepositoryService.getFileIssues(provider, organization, repository, fileId, limit, cursor);
519
+ return await RepositoryService.getFileIssues(provider, organization, repository, fileId, cursor, limit);
394
520
  };
395
521
  const getFileCoverageHandler = async (args) => {
396
522
  const { provider, organization, repository, fileId } = args;
@@ -400,10 +526,26 @@ const searchRepositoryIssuesHandler = async (args) => {
400
526
  const { provider, organization, repository, limit, cursor, body } = args;
401
527
  return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
402
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
+ };
403
533
  const searchSecurityItemsHandler = async (args) => {
404
534
  const { provider, organization, cursor, limit, sort, direction, body } = args;
405
535
  return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, body);
406
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
+ };
407
549
  // Register tools
408
550
  server.setRequestHandler(ListToolsRequestSchema, async () => {
409
551
  return {
@@ -414,6 +556,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
414
556
  getFileIssuesTool,
415
557
  getFileCoverageTool,
416
558
  searchSecurityItemsTool,
559
+ listRepositoryPullRequestsTool,
560
+ listPullRequestIssuesTool,
561
+ getRepositoryPullRequestFilesCoverageTool,
562
+ getPullRequestGitDiffTool,
417
563
  ],
418
564
  };
419
565
  });
@@ -454,12 +600,36 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
454
600
  content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
455
601
  };
456
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
+ }
457
609
  case 'codacy_list_srm_items': {
458
610
  const result = await searchSecurityItemsHandler(request.params.arguments);
459
611
  return {
460
612
  content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
461
613
  };
462
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
+ }
463
633
  default:
464
634
  throw new Error(`Unknown tool: ${request.params.name}`);
465
635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",