@codacy/codacy-mcp 0.4.3 → 0.4.5
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 +31 -0
- package/dist/index.js +1 -0
- package/dist/src/middleware/validation.js +1 -1
- package/dist/src/rules.js +11 -0
- package/dist/src/{tools/utils.js → schemas.js} +21 -104
- package/dist/src/tools/cliAnalyzeTool.js +2 -1
- package/dist/src/tools/getFileCoverageTool.js +2 -2
- package/dist/src/tools/getFileWithAnalysisTool.js +2 -2
- package/dist/src/tools/getIssueTool.js +2 -2
- package/dist/src/tools/getPatternTool.js +3 -1
- package/dist/src/tools/getPullRequestGitDiffTool.js +2 -2
- package/dist/src/tools/getRepositoryPullRequestFilesCoverageTool.js +2 -2
- package/dist/src/tools/getRepositoryPullRequestTool.js +2 -2
- package/dist/src/tools/getRepositoryWithAnalysisTool.js +2 -2
- package/dist/src/tools/listFileIssuesTool.js +19 -3
- package/dist/src/tools/listFilesTool.js +2 -2
- package/dist/src/tools/listOrganizationRepositoriesTool.js +10 -3
- package/dist/src/tools/listOrganizationsTool.js +4 -3
- package/dist/src/tools/listPullRequestIssuesTool.js +18 -3
- package/dist/src/tools/listRepositoryPullRequestsTool.js +2 -2
- package/dist/src/tools/listRepositoryToolPatternsTool.js +2 -2
- package/dist/src/tools/listRepositoryToolsTool.js +2 -2
- package/dist/src/tools/listToolsTool.js +2 -2
- package/dist/src/tools/searchRepositoryIssuesTool.js +36 -3
- package/dist/src/tools/searchSecurityItemsTool.js +23 -3
- package/dist/src/utils.js +128 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,37 @@ Depending on what are you connecting the MCP Server to, you can use the followin
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
### VSCode with Copilot
|
|
96
|
+
|
|
97
|
+
For connecting the MCP Server to Copilot in VS Code, add the following to the global config of the IDE:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"mcp": {
|
|
102
|
+
"inputs": [],
|
|
103
|
+
"servers": {
|
|
104
|
+
"codacy": {
|
|
105
|
+
"command": "npx",
|
|
106
|
+
"args": [
|
|
107
|
+
"-y",
|
|
108
|
+
"@codacy/codacy-mcp"
|
|
109
|
+
],
|
|
110
|
+
"env": {
|
|
111
|
+
"CODACY_ACCOUNT_TOKEN": "<YOUR_TOKEN>"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
You can find the global settings.json file in the following places, according to your OS:
|
|
119
|
+
|
|
120
|
+
- for macOS: `~/Library/Application Support/Code/User/settings.json`
|
|
121
|
+
- for Windows: `%APPDATA%\Code\User\settings.json`
|
|
122
|
+
- for Linux: `~/.config/Code/User/settings.json`
|
|
123
|
+
|
|
124
|
+
Make sure you have Agent mode enabled: [vscode://settings/chat.agent.enabled](vscode://settings/chat.agent.enabled)
|
|
125
|
+
|
|
95
126
|
### Node (when using NVM)
|
|
96
127
|
|
|
97
128
|
When using NVM with Claude Desktop, NPX won't work. You should first install the MCP Server globally, and then use Node directly:
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { toolNames } from './schemas.js';
|
|
2
|
+
// General rules pertaining to the accuracy of the arguments passed to the tools
|
|
3
|
+
export const generalOrganizationMistakes = `
|
|
4
|
+
- Using this tool for a organization other than the current one
|
|
5
|
+
- Using this tool with the wrong organization name (if you are not sure, use the ${toolNames.CODACY_LIST_ORGANIZATIONS} tool to validate the organization name)
|
|
6
|
+
`;
|
|
7
|
+
export const generalRepositoryMistakes = `
|
|
8
|
+
- Using this tool without specifying the repository name
|
|
9
|
+
- Using this tool for a repository other than the current one
|
|
10
|
+
- Using this tool with the wrong repository name (if you are not sure, use the ${toolNames.CODACY_LIST_ORGANIZATION_REPOSITORIES} tool to validate the repository name)
|
|
11
|
+
`;
|
|
@@ -1,92 +1,24 @@
|
|
|
1
|
-
export const
|
|
2
|
-
'
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'Crystal',
|
|
23
|
-
'Haskell',
|
|
24
|
-
'Elixir',
|
|
25
|
-
'Groovy',
|
|
26
|
-
'Apex',
|
|
27
|
-
'VisualForce',
|
|
28
|
-
'Velocity',
|
|
29
|
-
'CSS',
|
|
30
|
-
'HTML',
|
|
31
|
-
'LESS',
|
|
32
|
-
'SASS',
|
|
33
|
-
'Dockerfile',
|
|
34
|
-
'Terraform',
|
|
35
|
-
'Shell',
|
|
36
|
-
'Powershell',
|
|
37
|
-
'JSON',
|
|
38
|
-
'XML',
|
|
39
|
-
'YAML',
|
|
40
|
-
'Markdown',
|
|
41
|
-
'Cobol',
|
|
42
|
-
'ABAP',
|
|
43
|
-
'ObjectiveC',
|
|
44
|
-
'Rust',
|
|
45
|
-
];
|
|
46
|
-
export const issueCategories = [
|
|
47
|
-
'security',
|
|
48
|
-
'errorprone',
|
|
49
|
-
'performance',
|
|
50
|
-
'complexity',
|
|
51
|
-
'unusedcode',
|
|
52
|
-
'comprehensibility',
|
|
53
|
-
'compatibility',
|
|
54
|
-
'bestpractice',
|
|
55
|
-
'codestyle',
|
|
56
|
-
'documentation',
|
|
57
|
-
];
|
|
58
|
-
export const securityStatuses = {
|
|
59
|
-
Open: ['OnTrack', 'DueSoon', 'Overdue'],
|
|
60
|
-
Closed: ['ClosedOnTime', 'ClosedLate', 'Ignored'],
|
|
61
|
-
};
|
|
62
|
-
export const securityCategories = [
|
|
63
|
-
'Auth',
|
|
64
|
-
'CommandInjection',
|
|
65
|
-
'Cookies',
|
|
66
|
-
'Cryptography',
|
|
67
|
-
'CSRF',
|
|
68
|
-
'DoS',
|
|
69
|
-
'FileAccess',
|
|
70
|
-
'HTTP',
|
|
71
|
-
'InputValidation',
|
|
72
|
-
'InsecureModulesLibraries',
|
|
73
|
-
'InsecureStorage',
|
|
74
|
-
'Other',
|
|
75
|
-
'Regex',
|
|
76
|
-
'SQLInjection',
|
|
77
|
-
'UnexpectedBehaviour',
|
|
78
|
-
'Visibility',
|
|
79
|
-
'XSS',
|
|
80
|
-
'_other_',
|
|
81
|
-
];
|
|
82
|
-
export const securityScanTypes = {
|
|
83
|
-
SAST: 'Code scanning',
|
|
84
|
-
Secrets: 'Secret scanning',
|
|
85
|
-
SCA: 'Dependency scanning',
|
|
86
|
-
IaC: 'Infrastructure-as-code scanning',
|
|
87
|
-
CICD: 'CI/CD scanning',
|
|
88
|
-
DAST: 'Dynamic Application Security Testing',
|
|
89
|
-
PenTesting: 'Penetration testing',
|
|
1
|
+
export const toolNames = {
|
|
2
|
+
CODACY_LIST_ORGANIZATION_REPOSITORIES: 'codacy_list_organization_repositories',
|
|
3
|
+
CODACY_LIST_SRM_ITEMS: 'codacy_list_srm_items',
|
|
4
|
+
CODACY_LIST_REPOSITORY_ISSUES: 'codacy_list_repository_issues',
|
|
5
|
+
CODACY_LIST_REPOSITORY_PULL_REQUESTS: 'codacy_list_repository_pull_requests',
|
|
6
|
+
CODACY_LIST_FILES: 'codacy_list_files',
|
|
7
|
+
CODACY_LIST_REPOSITORY_TOOL_PATTERNS: 'codacy_list_repository_tool_patterns',
|
|
8
|
+
CODACY_LIST_REPOSITORY_TOOLS: 'codacy_list_repository_tools',
|
|
9
|
+
CODACY_LIST_TOOLS: 'codacy_list_tools',
|
|
10
|
+
CODACY_LIST_ORGANIZATIONS: 'codacy_list_organizations',
|
|
11
|
+
CODACY_GET_FILE_ISSUES: 'codacy_get_file_issues',
|
|
12
|
+
CODACY_GET_FILE_COVERAGE: 'codacy_get_file_coverage',
|
|
13
|
+
CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE: 'codacy_get_repository_pull_request_files_coverage',
|
|
14
|
+
CODACY_GET_PULL_REQUEST_GIT_DIFF: 'codacy_get_pull_request_git_diff',
|
|
15
|
+
CODACY_LIST_PULL_REQUEST_ISSUES: 'codacy_list_pull_request_issues',
|
|
16
|
+
CODACY_GET_REPOSITORY_WITH_ANALYSIS: 'codacy_get_repository_with_analysis',
|
|
17
|
+
CODACY_GET_FILE_WITH_ANALYSIS: 'codacy_get_file_with_analysis',
|
|
18
|
+
CODACY_GET_REPOSITORY_PULL_REQUEST: 'codacy_get_repository_pull_request',
|
|
19
|
+
CODACY_GET_ISSUE: 'codacy_get_issue',
|
|
20
|
+
CODACY_GET_PATTERN: 'codacy_get_pattern',
|
|
21
|
+
CODACY_CLI_ANALYZE: 'codacy_cli_analyze',
|
|
90
22
|
};
|
|
91
23
|
export const organizationSchema = {
|
|
92
24
|
gitUrl: {
|
|
@@ -149,18 +81,3 @@ export const fileSchema = {
|
|
|
149
81
|
description: "Codacy's identifier of a file in a specific commit",
|
|
150
82
|
},
|
|
151
83
|
};
|
|
152
|
-
export const extractOrganizationFromUrl = (url) => {
|
|
153
|
-
const patterns = [
|
|
154
|
-
/git@github\.com:([^/]+)\/[^/]+\.git$/,
|
|
155
|
-
/https:\/\/github\.com\/([^/]+)\/[^/]+\.git$/,
|
|
156
|
-
/https:\/\/gitlab\.com\/([^/]+)\/[^/]+\.git$/,
|
|
157
|
-
/https:\/\/bitbucket\.org\/([^/]+)\/[^/]+\.git$/,
|
|
158
|
-
];
|
|
159
|
-
for (const pattern of patterns) {
|
|
160
|
-
const match = pattern.exec(url);
|
|
161
|
-
if (match?.[1]) {
|
|
162
|
-
return match[1];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { toolNames } from '../schemas.js';
|
|
1
2
|
export const allowedTools = ['eslint'];
|
|
2
3
|
export const cliAnalyzeTool = {
|
|
3
|
-
name:
|
|
4
|
+
name: toolNames.CODACY_CLI_ANALYZE,
|
|
4
5
|
description: 'Run quality analysis using Codacy CLI. Requires the Codacy CLI to be installed and configured.',
|
|
5
6
|
inputSchema: {
|
|
6
7
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fileSchema } from '
|
|
1
|
+
import { fileSchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getFileCoverageTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_FILE_COVERAGE,
|
|
4
4
|
description: 'Get coverage information for a file in the head commit of a repository branch.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { fileSchema } from '
|
|
1
|
+
import { fileSchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getFileWithAnalysisTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_FILE_WITH_ANALYSIS,
|
|
4
4
|
description: "Get file information and it's analysis information and coverage metrics. A file that is ignored is not analyzed by Codacy. Here you will find results for five metrics: Grade, Issues, Duplication, Complexity and Coverage.",
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repositorySchema } from '
|
|
1
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getIssueTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_ISSUE,
|
|
4
4
|
description: 'Returns information about an open issue that Codacy found in a repository.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { toolNames } from '../schemas.js';
|
|
1
2
|
export const getPatternTool = {
|
|
2
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_PATTERN,
|
|
3
4
|
description: 'Get the definition of a specific pattern.',
|
|
4
5
|
inputSchema: {
|
|
5
6
|
type: 'object',
|
|
@@ -13,5 +14,6 @@ export const getPatternTool = {
|
|
|
13
14
|
description: 'Pattern identifier',
|
|
14
15
|
},
|
|
15
16
|
},
|
|
17
|
+
required: ['toolUuid', 'patternId'],
|
|
16
18
|
},
|
|
17
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repositorySchema } from '
|
|
1
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getPullRequestGitDiffTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_PULL_REQUEST_GIT_DIFF,
|
|
4
4
|
description: 'Returns the human-readable Git diff of a pull request',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repositorySchema } from '
|
|
1
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getRepositoryPullRequestFilesCoverageTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_REPOSITORY_PULL_REQUEST_FILES_COVERAGE,
|
|
4
4
|
description: 'Get coverage information for all files in a pull request.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repositorySchema } from '
|
|
1
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getRepositoryPullRequestTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_REPOSITORY_PULL_REQUEST,
|
|
4
4
|
description: 'Get the pull request information for a repository. The response contains the analysis of the pull request.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { branchSchema, repositorySchema } from '
|
|
1
|
+
import { branchSchema, repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const getRepositoryWithAnalysisTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_GET_REPOSITORY_WITH_ANALYSIS,
|
|
4
4
|
description: 'Get repository with analysis information. Here you will find results for five metrics: Grade, Issues, Duplication, Complexity and Coverage. LoC stands for Lines of Code, and Codacy prefers to show the Issues metric as /kLoC (issues per thousand lines of code).',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
|
|
2
|
+
import { listFilesTool } from './listFilesTool.js';
|
|
3
|
+
import { defaultPagination, fileSchema, toolNames } from '../schemas.js';
|
|
4
|
+
const rules = `
|
|
5
|
+
Use this tool to list the issues for specific files in a repository.
|
|
6
|
+
|
|
7
|
+
Common use cases:
|
|
8
|
+
- When the user asks for the issues for a specific file
|
|
9
|
+
- When the user is in a file context and asks for the issues
|
|
10
|
+
|
|
11
|
+
Common mistakes:
|
|
12
|
+
- Using this tool for listing the issues for specific pull requests
|
|
13
|
+
- Using this tool for listing the issues for an entire repository
|
|
14
|
+
- Using this with a wrong fileId (validate the fileId with the ${listFilesTool.name} tool)
|
|
15
|
+
${generalOrganizationMistakes}
|
|
16
|
+
${generalRepositoryMistakes}
|
|
17
|
+
`;
|
|
2
18
|
export const listFileIssuesTool = {
|
|
3
|
-
name:
|
|
4
|
-
description:
|
|
19
|
+
name: toolNames.CODACY_GET_FILE_ISSUES,
|
|
20
|
+
description: `Get the issue list for a file in a repository. \n ${rules}`,
|
|
5
21
|
inputSchema: {
|
|
6
22
|
type: 'object',
|
|
7
23
|
properties: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getPaginationWithSorting, repositorySchema } from '
|
|
1
|
+
import { getPaginationWithSorting, repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const listFilesTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_LIST_FILES,
|
|
4
4
|
description: "List files in a repository with pagination. Supports sorting by various metrics (coverage, grade, issues, etc.) and filtering. Use sort='coverage' and direction='desc' to efficiently find files with high coverage, or sort='grade' for code quality analysis. Use search to filter files by name. ",
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { defaultPagination, organizationSchema } from '
|
|
1
|
+
import { defaultPagination, organizationSchema, toolNames } from '../schemas.js';
|
|
2
|
+
import { generalOrganizationMistakes } from '../rules.js';
|
|
3
|
+
const rules = `
|
|
4
|
+
Common mistakes:
|
|
5
|
+
- Using this tool without the provider
|
|
6
|
+
${generalOrganizationMistakes}
|
|
7
|
+
`;
|
|
2
8
|
export const listOrganizationRepositoriesTool = {
|
|
3
|
-
name:
|
|
4
|
-
description:
|
|
9
|
+
name: toolNames.CODACY_LIST_ORGANIZATION_REPOSITORIES,
|
|
10
|
+
description: `List repositories in an organization with pagination.
|
|
11
|
+
${rules}`,
|
|
5
12
|
inputSchema: {
|
|
6
13
|
type: 'object',
|
|
7
14
|
properties: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { defaultPagination, organizationSchema } from '
|
|
1
|
+
import { defaultPagination, organizationSchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const listOrganizationsTool = {
|
|
3
|
-
name:
|
|
4
|
-
description: 'List organizations with pagination',
|
|
3
|
+
name: toolNames.CODACY_LIST_ORGANIZATIONS,
|
|
4
|
+
description: 'List organizations with pagination. \n Common mistakes: \n - Using this tool without the provider',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
provider: organizationSchema.provider,
|
|
9
9
|
...defaultPagination,
|
|
10
10
|
},
|
|
11
|
+
required: ['provider'],
|
|
11
12
|
},
|
|
12
13
|
};
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
|
|
2
|
+
import { defaultPagination, repositorySchema, toolNames } from '../schemas.js';
|
|
3
|
+
const rules = `
|
|
4
|
+
Use this tool to list the issues for specific pull requests.
|
|
5
|
+
|
|
6
|
+
Common use cases:
|
|
7
|
+
- When the user asks for the issues for a specific pull request
|
|
8
|
+
- When the user is in a pull request context and asks for the issues
|
|
9
|
+
|
|
10
|
+
Common mistakes:
|
|
11
|
+
- Using this tool for listing the issues for specific files
|
|
12
|
+
- Using this tool for listing the issues for an entire repository
|
|
13
|
+
${generalOrganizationMistakes}
|
|
14
|
+
${generalRepositoryMistakes}
|
|
15
|
+
`;
|
|
2
16
|
export const listPullRequestIssuesTool = {
|
|
3
|
-
name:
|
|
4
|
-
description:
|
|
17
|
+
name: toolNames.CODACY_LIST_PULL_REQUEST_ISSUES,
|
|
18
|
+
description: `Returns a list of issues found in a pull request. We can request either new or fixed issues. \n ${rules}`,
|
|
5
19
|
inputSchema: {
|
|
6
20
|
type: 'object',
|
|
7
21
|
properties: {
|
|
@@ -14,6 +28,7 @@ export const listPullRequestIssuesTool = {
|
|
|
14
28
|
status: {
|
|
15
29
|
type: 'string',
|
|
16
30
|
description: 'Filter issues by status. Accepted values: all, new, fixed.',
|
|
31
|
+
enum: ['all', 'new', 'fixed'],
|
|
17
32
|
},
|
|
18
33
|
onlyPotential: {
|
|
19
34
|
type: 'boolean',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defaultPagination, repositorySchema } from '
|
|
1
|
+
import { defaultPagination, repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const listRepositoryPullRequestsTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_LIST_REPOSITORY_PULL_REQUESTS,
|
|
4
4
|
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',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getPaginationWithSorting, repositorySchema } from '
|
|
1
|
+
import { getPaginationWithSorting, repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const listRepositoryToolPatternsTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_LIST_REPOSITORY_TOOL_PATTERNS,
|
|
4
4
|
description: 'List the patterns of a tool available for a repository in Codacy.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { repositorySchema } from '
|
|
1
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
2
2
|
export const listRepositoryToolsTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_LIST_REPOSITORY_TOOLS,
|
|
4
4
|
description: 'Get analysis tools settings of a repository. This endpoint returns the analysis tools available in Codacy for a repository.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defaultPagination } from '
|
|
1
|
+
import { defaultPagination, toolNames } from '../schemas.js';
|
|
2
2
|
export const listToolsTool = {
|
|
3
|
-
name:
|
|
3
|
+
name: toolNames.CODACY_LIST_TOOLS,
|
|
4
4
|
description: 'List all code analysis tools available in Codacy.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -1,7 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { codacyLanguages, issueCategories } from '../utils.js';
|
|
2
|
+
import { searchSecurityItemsTool } from './searchSecurityItemsTool.js';
|
|
3
|
+
import { listFileIssuesTool } from './listFileIssuesTool.js';
|
|
4
|
+
import { listPullRequestIssuesTool } from './listPullRequestIssuesTool.js';
|
|
5
|
+
import { repositorySchema, branchSchema, defaultPagination, toolNames, } from '../schemas.js';
|
|
6
|
+
import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
|
|
7
|
+
const rules = `
|
|
8
|
+
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.
|
|
10
|
+
For listing the issues for specific files, use the ${listFileIssuesTool.name} tool instead.
|
|
11
|
+
For listing the issues for specific pull requests, use the ${listPullRequestIssuesTool.name} tool instead.
|
|
12
|
+
|
|
13
|
+
Features include:
|
|
14
|
+
- Pagination support for handling large result sets
|
|
15
|
+
- Filtering by multiple criteria including severity, category, and language
|
|
16
|
+
- Author-based filtering for accountability
|
|
17
|
+
- Branch-specific analysis
|
|
18
|
+
- Pattern-based searching
|
|
19
|
+
|
|
20
|
+
Common use cases:
|
|
21
|
+
- When the user asks for code quality audits
|
|
22
|
+
- When the user asks for technical debt assessment
|
|
23
|
+
- When the user asks for style guide compliance checks
|
|
24
|
+
- When the user asks for performance issue investigation
|
|
25
|
+
- When the user asks for complexity analysis
|
|
26
|
+
- When the user asks for code quality issues
|
|
27
|
+
|
|
28
|
+
Common mistakes:
|
|
29
|
+
- Using this tool for security-related issues
|
|
30
|
+
- Using this tool for listing the issues for specific files
|
|
31
|
+
${generalOrganizationMistakes}
|
|
32
|
+
${generalRepositoryMistakes}
|
|
33
|
+
`;
|
|
2
34
|
export const searchRepositoryIssuesTool = {
|
|
3
|
-
name:
|
|
4
|
-
description:
|
|
35
|
+
name: toolNames.CODACY_LIST_REPOSITORY_ISSUES,
|
|
36
|
+
description: `Lists and filters code quality issues in a repository.
|
|
37
|
+
\n ${rules}`,
|
|
5
38
|
inputSchema: {
|
|
6
39
|
type: 'object',
|
|
7
40
|
properties: {
|
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { securityCategories, securityScanTypes, securityStatuses } from '../utils.js';
|
|
2
|
+
import { getPaginationWithSorting, organizationSchema, toolNames } from '../schemas.js';
|
|
3
|
+
import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
|
|
4
|
+
const rules = `
|
|
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.
|
|
6
|
+
Always add the current repository name in the repositories filter, unless specified otherwise.
|
|
7
|
+
|
|
8
|
+
How to format the response of this tool:
|
|
9
|
+
- Map the results statuses as open issues: ${securityStatuses.Open.join(', ')}; and closed issues: ${securityStatuses.Closed.join(', ')}.
|
|
10
|
+
- Prioritize the open issues as the most important ones in the results.
|
|
11
|
+
|
|
12
|
+
Common use cases:
|
|
13
|
+
- When the user asks for security issues
|
|
14
|
+
- When the user asks form compliance concerns
|
|
15
|
+
|
|
16
|
+
Common mistakes:
|
|
17
|
+
- Using this tool for quality issues
|
|
18
|
+
${generalOrganizationMistakes}
|
|
19
|
+
${generalRepositoryMistakes}
|
|
20
|
+
`;
|
|
2
21
|
export const searchSecurityItemsTool = {
|
|
3
|
-
name:
|
|
4
|
-
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.
|
|
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.
|
|
24
|
+
\n ${rules}`,
|
|
5
25
|
inputSchema: {
|
|
6
26
|
type: 'object',
|
|
7
27
|
properties: {
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export const codacyLanguages = [
|
|
2
|
+
'C',
|
|
3
|
+
'CPP',
|
|
4
|
+
'CSharp',
|
|
5
|
+
'Java',
|
|
6
|
+
'Go',
|
|
7
|
+
'Kotlin',
|
|
8
|
+
'Ruby',
|
|
9
|
+
'Scala',
|
|
10
|
+
'Dart',
|
|
11
|
+
'Python',
|
|
12
|
+
'TypeScript',
|
|
13
|
+
'Javascript',
|
|
14
|
+
'CoffeeScript',
|
|
15
|
+
'Swift',
|
|
16
|
+
'JSP',
|
|
17
|
+
'VisualBasic',
|
|
18
|
+
'PHP',
|
|
19
|
+
'PLSQL',
|
|
20
|
+
'SQL',
|
|
21
|
+
'TSQL',
|
|
22
|
+
'Crystal',
|
|
23
|
+
'Haskell',
|
|
24
|
+
'Elixir',
|
|
25
|
+
'Groovy',
|
|
26
|
+
'Apex',
|
|
27
|
+
'VisualForce',
|
|
28
|
+
'Velocity',
|
|
29
|
+
'CSS',
|
|
30
|
+
'HTML',
|
|
31
|
+
'LESS',
|
|
32
|
+
'SASS',
|
|
33
|
+
'Dockerfile',
|
|
34
|
+
'Terraform',
|
|
35
|
+
'Shell',
|
|
36
|
+
'Powershell',
|
|
37
|
+
'JSON',
|
|
38
|
+
'XML',
|
|
39
|
+
'YAML',
|
|
40
|
+
'Markdown',
|
|
41
|
+
'Cobol',
|
|
42
|
+
'ABAP',
|
|
43
|
+
'ObjectiveC',
|
|
44
|
+
'Rust',
|
|
45
|
+
];
|
|
46
|
+
export const issueCategories = [
|
|
47
|
+
'security',
|
|
48
|
+
'errorprone',
|
|
49
|
+
'performance',
|
|
50
|
+
'complexity',
|
|
51
|
+
'unusedcode',
|
|
52
|
+
'comprehensibility',
|
|
53
|
+
'compatibility',
|
|
54
|
+
'bestpractice',
|
|
55
|
+
'codestyle',
|
|
56
|
+
'documentation',
|
|
57
|
+
];
|
|
58
|
+
export const securityStatuses = {
|
|
59
|
+
Open: ['OnTrack', 'DueSoon', 'Overdue'],
|
|
60
|
+
Closed: ['ClosedOnTime', 'ClosedLate', 'Ignored'],
|
|
61
|
+
};
|
|
62
|
+
export const securityCategories = [
|
|
63
|
+
'Auth',
|
|
64
|
+
'CommandInjection',
|
|
65
|
+
'Cookies',
|
|
66
|
+
'Cryptography',
|
|
67
|
+
'CSRF',
|
|
68
|
+
'DoS',
|
|
69
|
+
'FileAccess',
|
|
70
|
+
'HTTP',
|
|
71
|
+
'InputValidation',
|
|
72
|
+
'InsecureModulesLibraries',
|
|
73
|
+
'InsecureStorage',
|
|
74
|
+
'Other',
|
|
75
|
+
'Regex',
|
|
76
|
+
'SQLInjection',
|
|
77
|
+
'UnexpectedBehaviour',
|
|
78
|
+
'Visibility',
|
|
79
|
+
'XSS',
|
|
80
|
+
'_other_',
|
|
81
|
+
];
|
|
82
|
+
export const securityScanTypes = {
|
|
83
|
+
SAST: 'Code scanning',
|
|
84
|
+
Secrets: 'Secret scanning',
|
|
85
|
+
SCA: 'Dependency scanning',
|
|
86
|
+
IaC: 'Infrastructure-as-code scanning',
|
|
87
|
+
CICD: 'CI/CD scanning',
|
|
88
|
+
DAST: 'Dynamic Application Security Testing',
|
|
89
|
+
PenTesting: 'Penetration testing',
|
|
90
|
+
};
|
|
91
|
+
export const extractOrganizationFromUrl = (url) => {
|
|
92
|
+
const patterns = [
|
|
93
|
+
/git@github\.com:([^/]+)\/[^/]+\.git$/,
|
|
94
|
+
/https:\/\/github\.com\/([^/]+)\/[^/]+\.git$/,
|
|
95
|
+
/https:\/\/gitlab\.com\/([^/]+)\/[^/]+\.git$/,
|
|
96
|
+
/https:\/\/bitbucket\.org\/([^/]+)\/[^/]+\.git$/,
|
|
97
|
+
];
|
|
98
|
+
for (const pattern of patterns) {
|
|
99
|
+
const match = pattern.exec(url);
|
|
100
|
+
if (match?.[1]) {
|
|
101
|
+
return match[1];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
};
|
|
106
|
+
// Helper function to parse URI based on template
|
|
107
|
+
export const parseUri = (uri, template) => {
|
|
108
|
+
const templateParts = template.split('/');
|
|
109
|
+
const uriParts = uri.split('/');
|
|
110
|
+
if (templateParts.length !== uriParts.length) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const params = {};
|
|
114
|
+
for (let i = 0; i < templateParts.length; i++) {
|
|
115
|
+
const templatePart = templateParts[i];
|
|
116
|
+
const uriPart = uriParts[i];
|
|
117
|
+
if (templatePart.startsWith('{') && templatePart.endsWith('}')) {
|
|
118
|
+
// This is a parameter
|
|
119
|
+
const paramName = templatePart.slice(1, -1);
|
|
120
|
+
params[paramName] = uriPart;
|
|
121
|
+
}
|
|
122
|
+
else if (templatePart !== uriPart) {
|
|
123
|
+
// Static parts must match exactly
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return params;
|
|
128
|
+
};
|