@codacy/codacy-mcp 0.5.0 → 0.5.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/README.md CHANGED
@@ -55,7 +55,7 @@ The following tools are available through the Codacy MCP Server:
55
55
 
56
56
  - `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.
57
57
  - `codacy_list_pull_request_issues`: Returns a list of issues found in a pull request. We can request either new or fixed issues.
58
- - `codacy_get_repository_pull_request_files_coverage`: Get coverage information for all files in a pull request.
58
+ - `codacy_get_pull_request_files_coverage`: Get diff coverage information for all files in a pull request.
59
59
  - `codacy_get_pull_request_git_diff`: Returns the human-readable Git diff of a pull request.
60
60
 
61
61
  ### CLI Analysis
package/dist/index.js CHANGED
@@ -59,7 +59,7 @@ const toolDefinitions = {
59
59
  handler: Handlers.listOrganizationRepositoriesHandler,
60
60
  },
61
61
  codacy_search_organization_srm_items: {
62
- tool: Tools.searchSecurityItemsTool,
62
+ tool: Tools.searchOrganizationSecurityItemsTool,
63
63
  handler: Handlers.searchSecurityItemsHandler,
64
64
  },
65
65
  codacy_search_repository_srm_items: {
@@ -83,7 +83,7 @@ const toolDefinitions = {
83
83
  tool: Tools.getFileCoverageTool,
84
84
  handler: Handlers.getFileCoverageHandler,
85
85
  },
86
- codacy_get_repository_pull_request_files_coverage: {
86
+ codacy_get_pull_request_files_coverage: {
87
87
  tool: Tools.getRepositoryPullRequestFilesCoverageTool,
88
88
  handler: Handlers.getRepositoryPullRequestFilesCoverageHandler,
89
89
  },
@@ -4,6 +4,7 @@ import fs from 'fs';
4
4
  import path from 'path';
5
5
  const exec = util.promisify(execChildProcess);
6
6
  const CODACY_ACCOUNT_TOKEN = process.env.CODACY_ACCOUNT_TOKEN;
7
+ const CODACY_CLI_COMMAND = 'CODACY_CLI_V2_VERSION=1.0.0-main.232.a6a6368 codacy-cli';
7
8
  // Safeguard: Validate and sanitize command inputs
8
9
  const sanitizeCommand = (command) => {
9
10
  // Remove any shell metacharacters
@@ -34,10 +35,10 @@ const ensureCodacyConfig = async (rootPath, provider, organization, repository)
34
35
  return true;
35
36
  }
36
37
  try {
37
- const command = `codacy-cli init --api-token ${CODACY_ACCOUNT_TOKEN} --provider ${provider} --organization ${organization} --repository ${repository}`;
38
+ const command = `${CODACY_CLI_COMMAND} init --api-token ${CODACY_ACCOUNT_TOKEN} --provider ${provider} --organization ${organization} --repository ${repository}`;
38
39
  const options = { cwd: rootPath };
39
40
  await exec(command, options);
40
- await exec('codacy-cli install', options);
41
+ await exec(`${CODACY_CLI_COMMAND} install`, options);
41
42
  return true;
42
43
  }
43
44
  catch (error) {
@@ -52,7 +53,8 @@ const falseSuccess = (stdout, stderr) => stderr && (!stdout || /error|fail|excep
52
53
  // Run analysis with potential retry after installation
53
54
  const runAnalysis = async (args) => {
54
55
  const safeFile = sanitizeCommand(args.file);
55
- const command = `codacy-cli analyze --format sarif ${safeFile}`;
56
+ const tool = args.tool ? `--tool ${args.tool}` : '';
57
+ const command = `${CODACY_CLI_COMMAND} analyze ${tool} --format sarif ${safeFile}`;
56
58
  // Add options object with cwd and increased maxBuffer
57
59
  const options = {
58
60
  cwd: args.rootPath,
@@ -67,7 +69,7 @@ const runAnalysis = async (args) => {
67
69
  }
68
70
  catch (error) {
69
71
  // If first attempt fails, try installing and retry
70
- await exec('codacy-cli install', options);
72
+ await exec(`${CODACY_CLI_COMMAND} install`, options);
71
73
  return await exec(command, options);
72
74
  }
73
75
  };
@@ -11,7 +11,7 @@ export const toolNames = {
11
11
  CODACY_LIST_ORGANIZATIONS: 'codacy_list_organizations',
12
12
  CODACY_GET_FILE_ISSUES: 'codacy_get_file_issues',
13
13
  CODACY_GET_FILE_COVERAGE: 'codacy_get_file_coverage',
14
- CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE: 'codacy_get_repository_pull_request_files_coverage',
14
+ CODACY_GET_PULL_REQUEST_FILES_COVERAGE: 'codacy_get_pull_request_files_coverage',
15
15
  CODACY_GET_PULL_REQUEST_GIT_DIFF: 'codacy_get_pull_request_git_diff',
16
16
  CODACY_LIST_PULL_REQUEST_ISSUES: 'codacy_list_pull_request_issues',
17
17
  CODACY_GET_REPOSITORY_WITH_ANALYSIS: 'codacy_get_repository_with_analysis',
@@ -1,10 +1,12 @@
1
1
  import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
2
2
  import { repositorySchema, toolNames } from '../schemas.js';
3
+ const availableCliTools = ['eslint', 'pmd', 'trivy', 'pylint', 'dartanalyzer'];
3
4
  const rules = `
4
5
  Use this tool to analyze the quality of a repository using Codacy command line.
5
6
 
6
7
  Common use cases:
7
8
  - When the user asks for an analysis of a repository
9
+ - When the user asks to scan the code
8
10
  - When the user wants to analyze based on Codacy configuration
9
11
  - When the user wants to apply fixes based on Codacy configuration and analysis
10
12
  - When the user wants Codacy results immediately without waiting for the next scheduled analysis
@@ -13,12 +15,13 @@ const rules = `
13
15
  - Using this tool to know the status of a repository
14
16
  - Using this tool without specifying the rootPath
15
17
  - Using this tool to know current results from Codacy. Use ${toolNames.CODACY_GET_REPOSITORY_WITH_ANALYSIS} instead.
18
+ - Filling the tool parameter when not asked specifically for it.
16
19
  ${generalOrganizationMistakes}
17
20
  ${generalRepositoryMistakes}
18
21
  `;
19
22
  export const cliAnalyzeTool = {
20
23
  name: toolNames.CODACY_CLI_ANALYZE,
21
- description: `Run quality analysis using Codacy CLI. \n ${rules}`,
24
+ description: `Run quality analysis locally using Codacy CLI. \n ${rules}`,
22
25
  inputSchema: {
23
26
  type: 'object',
24
27
  properties: {
@@ -29,7 +32,12 @@ export const cliAnalyzeTool = {
29
32
  },
30
33
  file: {
31
34
  type: 'string',
32
- description: 'Optional. Absolute path to the file to analyze, or pattern to match files (e.g., "src/**/*.js"). If left empty, the analysis will be executed for the whole project.',
35
+ description: 'Optional. Absolute path to the file to analyze, or directory to analyze (e.g., "src/"). If left empty, the analysis will be executed for the whole project.',
36
+ default: '',
37
+ },
38
+ tool: {
39
+ type: 'string',
40
+ description: `Optional. Tool to use for the analysis. If left empty, it will use all available tools. Possible values: ${availableCliTools.join(', ')}`,
33
41
  default: '',
34
42
  },
35
43
  },
@@ -10,8 +10,8 @@ const rules = `
10
10
  ${generalRepositoryMistakes}
11
11
  `;
12
12
  export const getRepositoryPullRequestFilesCoverageTool = {
13
- name: toolNames.CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE,
14
- description: `Use this tool to get coverage information for all files in a pull request. \n ${rules}`,
13
+ name: toolNames.CODACY_GET_PULL_REQUEST_FILES_COVERAGE,
14
+ description: `Use this tool to get the diff coverage information for all files in a pull request. \n ${rules}`,
15
15
  inputSchema: {
16
16
  type: 'object',
17
17
  properties: {
@@ -1,12 +1,11 @@
1
1
  import { codacyLanguages, issueCategories } from '../utils.js';
2
- import { searchSecurityItemsTool } from './searchSecurityItemsTool.js';
3
2
  import { listFileIssuesTool } from './listFileIssuesTool.js';
4
3
  import { listPullRequestIssuesTool } from './listPullRequestIssuesTool.js';
5
4
  import { repositorySchema, branchSchema, defaultPagination, toolNames, } from '../schemas.js';
6
5
  import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
7
6
  const rules = `
8
7
  This is the primary tool for investigating general code quality concerns (e.g. best practices, performance, complexity, style) but NOT security issues.
9
- For security-related issues, use the ${searchSecurityItemsTool.name} tool instead.
8
+ For security-related issues, use the SRM tools instead.
10
9
  For listing the issues for specific files, use the ${listFileIssuesTool.name} tool instead.
11
10
  For listing the issues for specific pull requests, use the ${listPullRequestIssuesTool.name} tool instead.
12
11
 
@@ -1,4 +1,4 @@
1
- import { securityCategories, securityScanTypes, securityStatuses } from '../utils.js';
1
+ import { organizationSecurityScanTypes, repositorySecurityScanTypes, securityCategories, securityStatuses, } from '../utils.js';
2
2
  import { getPaginationWithSorting, organizationSchema, repositorySchema, toolNames, } from '../schemas.js';
3
3
  import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
4
4
  const rules = `
@@ -15,6 +15,7 @@ const rules = `
15
15
 
16
16
  Common mistakes:
17
17
  - Using this tool for quality issues
18
+ - Calling this tool after editing files to check for new results; changes need to be committed to the repository first.
18
19
  ${generalOrganizationMistakes}
19
20
  ${generalRepositoryMistakes}
20
21
  `;
@@ -44,27 +45,10 @@ const commonSrmProperties = {
44
45
  },
45
46
  note: "_other_ can be used to search for issues that don't have a security category",
46
47
  },
47
- scanTypes: {
48
- description: 'Array of security scan types to filter by.',
49
- type: 'array',
50
- items: {
51
- type: 'string',
52
- enum: Object.keys(securityScanTypes),
53
- },
54
- mapping: securityScanTypes,
55
- },
56
- segments: {
57
- type: 'array',
58
- description: 'Set of segments ids (type number). Segment is a Codacy concept that groups repositories by different criteria',
59
- items: {
60
- type: 'number',
61
- description: 'Segment id',
62
- },
63
- },
64
48
  };
65
- export const searchSecurityItemsTool = {
49
+ export const searchOrganizationSecurityItemsTool = {
66
50
  name: toolNames.CODACY_LIST_ORGANIZATION_SRM_ITEMS,
67
- description: `Primary tool to list security items/issues/vulnerabilities/findings, results are related to the organization's security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(securityScanTypes).join(', ')} security issues.
51
+ description: `Primary tool to list security items/issues/vulnerabilities/findings, results are related to the organization's security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(organizationSecurityScanTypes).join(', ')} security issues.
68
52
  \n ${rules}`,
69
53
  inputSchema: {
70
54
  type: 'object',
@@ -75,15 +59,15 @@ export const searchSecurityItemsTool = {
75
59
  type: 'object',
76
60
  description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
77
61
  properties: {
78
- repositories: {
62
+ ...commonSrmProperties,
63
+ scanTypes: {
64
+ description: 'Array of security scan types to filter by.',
79
65
  type: 'array',
80
- description: 'Use this to filter by repository name.',
81
66
  items: {
82
67
  type: 'string',
83
- description: 'Repository name',
68
+ enum: Object.keys(organizationSecurityScanTypes),
84
69
  },
85
70
  },
86
- ...commonSrmProperties,
87
71
  },
88
72
  },
89
73
  },
@@ -92,8 +76,9 @@ export const searchSecurityItemsTool = {
92
76
  };
93
77
  export const searchRepositorySecurityItemsTool = {
94
78
  name: toolNames.CODACY_LIST_REPOSITORY_SRM_ITEMS,
95
- description: `Tool to list security items/issues/vulnerabilities/findings, results are related to a repository's security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(securityScanTypes).join(', ')} security issues.
96
- \n ${rules}`,
79
+ description: `Tool to list security items/issues/vulnerabilities/findings, results are related to a repository's security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(repositorySecurityScanTypes).join(', ')} security issues.
80
+ \n ${rules}
81
+ - Using this tool for DAST and PenTesting scan types; use the codacy_search_organization_srm_items tool instead.`,
97
82
  inputSchema: {
98
83
  type: 'object',
99
84
  properties: {
@@ -104,6 +89,14 @@ export const searchRepositorySecurityItemsTool = {
104
89
  description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
105
90
  properties: {
106
91
  ...commonSrmProperties,
92
+ scanTypes: {
93
+ description: 'Array of security scan types to filter by.',
94
+ type: 'array',
95
+ items: {
96
+ type: 'string',
97
+ enum: Object.keys(repositorySecurityScanTypes),
98
+ },
99
+ },
107
100
  },
108
101
  },
109
102
  },
package/dist/src/utils.js CHANGED
@@ -79,12 +79,15 @@ export const securityCategories = [
79
79
  'XSS',
80
80
  '_other_',
81
81
  ];
82
- export const securityScanTypes = {
82
+ export const repositorySecurityScanTypes = {
83
83
  SAST: 'Code scanning',
84
84
  Secrets: 'Secret scanning',
85
85
  SCA: 'Dependency scanning',
86
86
  IaC: 'Infrastructure-as-code scanning',
87
87
  CICD: 'CI/CD scanning',
88
+ };
89
+ export const organizationSecurityScanTypes = {
90
+ ...repositorySecurityScanTypes,
88
91
  DAST: 'Dynamic Application Security Testing',
89
92
  PenTesting: 'Penetration testing',
90
93
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",