@codacy/codacy-mcp 0.4.5 → 0.4.7

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
@@ -70,14 +70,18 @@ Get your Codacy's Account API Token from your [Codacy Account](https://app.codac
70
70
 
71
71
  ### Usage
72
72
 
73
- Depending on what are you connecting the MCP Server to, you can use the following methods:
73
+ In supported IDEs like VS Code, Cursor, and Windsurf, the easiest way to install Codacy's MCP Server is to do it from the Codacy extension. If you haven't yet, install the extension from within your IDE, or from any of the available marketplaces ([Microsoft](https://marketplace.visualstudio.com/items?itemName=codacy-app.codacy), [OpenVSX](https://open-vsx.org/extension/codacy-app/codacy)). From the extension panel, just click on Add Codacy MCP Server. Restart your IDE afterwards.
74
+
75
+ Without the extension, you can still use and install the MCP Server:
76
+
77
+ ### Cursor, Windsurf, and others
78
+
79
+ Depending on what you are connecting the MCP Server to, you can use the following methods:
74
80
 
75
81
  - Cursor: edit the `.cursor/mcp.json` file to add the following
76
82
  - Windsurf: edit the `.codeium/windsurf/mcp_config.json` file to add the following
77
83
  - Claude Desktop: edit the `claude_desktop_config.json` file to add the following
78
-
79
- ### NPX
80
-
84
+
81
85
  ```json
82
86
  {
83
87
  "mcpServers": {
@@ -92,7 +96,7 @@ Depending on what are you connecting the MCP Server to, you can use the followin
92
96
  }
93
97
  ```
94
98
 
95
- ### VSCode with Copilot
99
+ ### VS Code with Copilot
96
100
 
97
101
  For connecting the MCP Server to Copilot in VS Code, add the following to the global config of the IDE:
98
102
 
@@ -115,6 +119,7 @@ For connecting the MCP Server to Copilot in VS Code, add the following to the gl
115
119
  }
116
120
  }
117
121
  ```
122
+
118
123
  You can find the global settings.json file in the following places, according to your OS:
119
124
 
120
125
  - for macOS: `~/Library/Application Support/Code/User/settings.json`
@@ -123,9 +128,10 @@ You can find the global settings.json file in the following places, according to
123
128
 
124
129
  Make sure you have Agent mode enabled: [vscode://settings/chat.agent.enabled](vscode://settings/chat.agent.enabled)
125
130
 
126
- ### Node (when using NVM)
127
131
 
128
- When using NVM with Claude Desktop, NPX won't work. You should first install the MCP Server globally, and then use Node directly:
132
+ ### Node Troubleshooting
133
+
134
+ When using NVM with Claude Desktop, NPX may not work. You should first install the MCP Server globally, and then use Node directly:
129
135
 
130
136
  ```bash
131
137
  npm install -g @codacy/codacy-mcp
package/dist/index.js CHANGED
@@ -58,10 +58,14 @@ const toolDefinitions = {
58
58
  tool: Tools.listOrganizationRepositoriesTool,
59
59
  handler: Handlers.listOrganizationRepositoriesHandler,
60
60
  },
61
- codacy_list_srm_items: {
61
+ codacy_search_organization_srm_items: {
62
62
  tool: Tools.searchSecurityItemsTool,
63
63
  handler: Handlers.searchSecurityItemsHandler,
64
64
  },
65
+ codacy_search_repository_srm_items: {
66
+ tool: Tools.searchRepositorySecurityItemsTool,
67
+ handler: Handlers.searchRepositorySecurityItemsHandler,
68
+ },
65
69
  codacy_list_repository_issues: {
66
70
  tool: Tools.searchRepositoryIssuesTool,
67
71
  handler: Handlers.searchRepositoryIssuesHandler,
@@ -8,8 +8,8 @@ export const listRepositoryPullRequestsHandler = async (args) => {
8
8
  return await AnalysisService.listRepositoryPullRequests(provider, organization, repository, limit, cursor, search, includeNotAnalyzed);
9
9
  };
10
10
  export const searchRepositoryIssuesHandler = async (args) => {
11
- const { provider, organization, repository, limit, cursor, body } = args;
12
- return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
11
+ const { provider, organization, repository, limit, cursor, options } = args;
12
+ return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, options);
13
13
  };
14
14
  export const getRepositoryWithAnalysisHandler = async (args) => {
15
15
  const { provider, organization, repository, branch } = args;
@@ -1,24 +1,15 @@
1
1
  import util from 'util';
2
2
  import { exec as execChildProcess } from 'child_process';
3
- import { allowedTools } from '../tools/cliAnalyzeTool.js';
4
3
  const exec = util.promisify(execChildProcess);
5
4
  // Safeguard: Validate and sanitize command inputs
6
5
  const sanitizeCommand = (command) => {
7
6
  // Remove any shell metacharacters
8
7
  return command?.replace(/[;&|`$]/g, '') || '';
9
8
  };
10
- // Safeguard: Validate tool name
11
- const validateTool = (tool) => {
12
- if (!allowedTools.includes(tool)) {
13
- throw new Error(`Invalid tool: ${tool}. Allowed tools are: ${allowedTools.join(', ')}`);
14
- }
15
- return tool;
16
- };
17
9
  export const cliAnalyzeHandler = async (args) => {
18
10
  try {
19
- const safeTool = validateTool(args.tool);
20
11
  const safeFile = sanitizeCommand(args.file);
21
- const command = `codacy-cli analyze --tool ${safeTool} --format sarif ${safeFile}`;
12
+ const command = `codacy-cli analyze --format sarif ${safeFile}`;
22
13
  // Add options object with cwd and increased maxBuffer
23
14
  const options = {
24
15
  cwd: args.rootPath,
@@ -1,5 +1,10 @@
1
1
  import { SecurityService } from '../api/client/index.js';
2
2
  export const searchSecurityItemsHandler = async (args) => {
3
- const { provider, organization, cursor, limit, sort, direction, body } = args;
4
- return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, body);
3
+ const { provider, organization, cursor, limit, sort, direction, options } = args;
4
+ return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, options);
5
+ };
6
+ export const searchRepositorySecurityItemsHandler = async (args) => {
7
+ const { provider, organization, repository, cursor, limit, sort, direction, options } = args;
8
+ options.repositories = [repository];
9
+ return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, options);
5
10
  };
@@ -1,6 +1,7 @@
1
1
  export const toolNames = {
2
2
  CODACY_LIST_ORGANIZATION_REPOSITORIES: 'codacy_list_organization_repositories',
3
- CODACY_LIST_SRM_ITEMS: 'codacy_list_srm_items',
3
+ CODACY_LIST_ORGANIZATION_SRM_ITEMS: 'codacy_search_organization_srm_items',
4
+ CODACY_LIST_REPOSITORY_SRM_ITEMS: 'codacy_search_repository_srm_items',
4
5
  CODACY_LIST_REPOSITORY_ISSUES: 'codacy_list_repository_issues',
5
6
  CODACY_LIST_REPOSITORY_PULL_REQUESTS: 'codacy_list_repository_pull_requests',
6
7
  CODACY_LIST_FILES: 'codacy_list_files',
@@ -21,17 +22,13 @@ export const toolNames = {
21
22
  CODACY_CLI_ANALYZE: 'codacy_cli_analyze',
22
23
  };
23
24
  export const organizationSchema = {
24
- gitUrl: {
25
- type: 'string',
26
- description: "Git URL of the repository. Get the git url using 'git remote -v'",
27
- },
28
25
  provider: {
29
26
  type: 'string',
30
- description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb. In case a repository is given, use that repository's Git provider. ",
27
+ description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb. Try to extract it from the repository's git remote URL using 'git remote -v'.",
31
28
  },
32
29
  organization: {
33
30
  type: 'string',
34
- description: "Organization name or username that owns the repository on the Git provider. This should only be extracted from the repository's git remote URL using these patterns:\n" +
31
+ description: "Organization name or username that owns the repository on the Git provider. Try to extract it from the repository's git remote URL using 'git remote -v' following these patterns:\n" +
35
32
  "- SSH format: 'git@github.com:{organization}/{repository}.git'\n" +
36
33
  "- HTTPS GitHub: 'https://github.com/{organization}/{repository}.git'\n" +
37
34
  "- HTTPS GitLab: 'https://gitlab.com/{organization}/{repository}.git'\n" +
@@ -43,7 +40,7 @@ export const repositorySchema = {
43
40
  ...organizationSchema,
44
41
  repository: {
45
42
  type: 'string',
46
- description: "Repository name on the Git provider. To find the repository name check the repository git url, it should be something like this for gh:'https://github.com/<owner>/<repository>.git' for gl:'https://gitlab.com/<owner>/<repository>.git' for bb:'https://bitbucket.org/<owner>/<repository>.git'.",
43
+ description: "Repository name on the Git provider. Try to extract it from the repository's git remote URL using 'git remote -v', it should be something like this for gh:'https://github.com/<owner>/<repository>.git' for gl:'https://gitlab.com/<owner>/<repository>.git' for bb:'https://bitbucket.org/<owner>/<repository>.git'.",
47
44
  },
48
45
  };
49
46
  export const defaultPagination = {
@@ -1,5 +1,4 @@
1
1
  import { toolNames } from '../schemas.js';
2
- export const allowedTools = ['eslint'];
3
2
  export const cliAnalyzeTool = {
4
3
  name: toolNames.CODACY_CLI_ANALYZE,
5
4
  description: 'Run quality analysis using Codacy CLI. Requires the Codacy CLI to be installed and configured.',
@@ -10,10 +9,6 @@ export const cliAnalyzeTool = {
10
9
  type: 'string',
11
10
  description: 'Required. Root path to the project or repository in the local filesystem. This must be filled to ensure permissions are met for the tool to run.',
12
11
  },
13
- tool: {
14
- type: 'string',
15
- description: `Required. Tool to use for analysis (e.g., eslint). Possible values: ${allowedTools.join(', ')}.`,
16
- },
17
12
  file: {
18
13
  type: 'string',
19
14
  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.',
@@ -40,7 +40,7 @@ export const searchRepositoryIssuesTool = {
40
40
  properties: {
41
41
  ...repositorySchema,
42
42
  ...defaultPagination,
43
- body: {
43
+ options: {
44
44
  type: 'object',
45
45
  description: 'Search parameters to filter the list of issues in a repository',
46
46
  properties: {
@@ -1,5 +1,5 @@
1
1
  import { securityCategories, securityScanTypes, securityStatuses } from '../utils.js';
2
- import { getPaginationWithSorting, organizationSchema, toolNames } from '../schemas.js';
2
+ import { getPaginationWithSorting, organizationSchema, repositorySchema, toolNames, } from '../schemas.js';
3
3
  import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
4
4
  const rules = `
5
5
  This tool provides advanced filtering by security categories, priorities, and scan types. Use this as the first tool when investigating security or compliance concerns.
@@ -18,16 +18,60 @@ const rules = `
18
18
  ${generalOrganizationMistakes}
19
19
  ${generalRepositoryMistakes}
20
20
  `;
21
+ const commonSrmProperties = {
22
+ priorities: {
23
+ description: 'Array of security issue priorities/severities to filter by.',
24
+ type: 'array',
25
+ items: {
26
+ type: 'string',
27
+ enum: ['Low', 'Medium', 'High', 'Critical'],
28
+ },
29
+ },
30
+ statuses: {
31
+ type: 'array',
32
+ 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',
33
+ items: {
34
+ type: 'string',
35
+ enum: ['OnTrack', 'DueSoon', 'Overdue', 'ClosedOnTime', 'ClosedLate', 'Ignored'],
36
+ },
37
+ },
38
+ categories: {
39
+ description: 'Array of security categories to filter by.',
40
+ type: 'array',
41
+ items: {
42
+ type: 'string',
43
+ enum: securityCategories,
44
+ },
45
+ note: "_other_ can be used to search for issues that don't have a security category",
46
+ },
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
+ };
21
65
  export const searchSecurityItemsTool = {
22
- name: toolNames.CODACY_LIST_SRM_ITEMS,
23
- 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.
66
+ 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.
24
68
  \n ${rules}`,
25
69
  inputSchema: {
26
70
  type: 'object',
27
71
  properties: {
28
72
  ...organizationSchema,
29
73
  ...getPaginationWithSorting('Sort SRM items by. Accepted values: Status, DetectedAt'),
30
- body: {
74
+ options: {
31
75
  type: 'object',
32
76
  description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
33
77
  properties: {
@@ -39,51 +83,30 @@ export const searchSecurityItemsTool = {
39
83
  description: 'Repository name',
40
84
  },
41
85
  },
42
- priorities: {
43
- description: 'Array of security issue priorities/severities to filter by.',
44
- type: 'array',
45
- items: {
46
- type: 'string',
47
- enum: ['Low', 'Medium', 'High', 'Critical'],
48
- },
49
- },
50
- statuses: {
51
- type: 'array',
52
- 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',
53
- items: {
54
- type: 'string',
55
- enum: ['OnTrack', 'DueSoon', 'Overdue', 'ClosedOnTime', 'ClosedLate', 'Ignored'],
56
- },
57
- },
58
- categories: {
59
- description: 'Array of security categories to filter by.',
60
- type: 'array',
61
- items: {
62
- type: 'string',
63
- enum: securityCategories,
64
- },
65
- note: "_other_ can be used to search for issues that don't have a security category",
66
- },
67
- scanTypes: {
68
- description: 'Array of security scan types to filter by.',
69
- type: 'array',
70
- items: {
71
- type: 'string',
72
- enum: Object.keys(securityScanTypes),
73
- },
74
- mapping: securityScanTypes,
75
- },
76
- segments: {
77
- type: 'array',
78
- description: 'Set of segments ids (type number). Segment is a Codacy concept that groups repositories by different criteria',
79
- items: {
80
- type: 'number',
81
- description: 'Segment id',
82
- },
83
- },
86
+ ...commonSrmProperties,
84
87
  },
85
88
  },
86
89
  },
87
90
  required: ['provider', 'organization'],
88
91
  },
89
92
  };
93
+ export const searchRepositorySecurityItemsTool = {
94
+ 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}`,
97
+ inputSchema: {
98
+ type: 'object',
99
+ properties: {
100
+ ...repositorySchema,
101
+ ...getPaginationWithSorting('Sort SRM items by. Accepted values: Status, DetectedAt'),
102
+ options: {
103
+ type: 'object',
104
+ description: 'Search parameters to filter the metrics of the security issues dashboard of an organization',
105
+ properties: {
106
+ ...commonSrmProperties,
107
+ },
108
+ },
109
+ },
110
+ required: ['provider', 'organization', 'repository'],
111
+ },
112
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",
@@ -27,7 +27,8 @@
27
27
  "lint": "eslint . --ext .ts",
28
28
  "lint:fix": "eslint . --ext .ts --fix",
29
29
  "format": "prettier --write \"**/*.{ts,json,md}\"",
30
- "format:check": "prettier --check \"**/*.{ts,json,md}\""
30
+ "format:check": "prettier --check \"**/*.{ts,json,md}\"",
31
+ "inspect": "npm run build && npx @modelcontextprotocol/inspector -e CODACY_ACCOUNT_TOKEN=123456 node dist/index.js"
31
32
  },
32
33
  "dependencies": {
33
34
  "@modelcontextprotocol/sdk": "1.0.1",