@codacy/codacy-mcp 0.5.7 → 0.5.9

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
@@ -6,9 +6,11 @@ MCP Server for the Codacy API, enabling access to repositories, files, quality,
6
6
 
7
7
  The following tools are available through the Codacy MCP Server:
8
8
 
9
- ### Repository Management
9
+ ### Organization and Repository Management
10
10
 
11
- - `codacy_list_repositories`: List repositories in an organization with pagination support.
11
+ - `codacy_list_organizations`: List organizations with pagination support.
12
+ - `codacy_list_organization_repositories`: List repositories in an organization with pagination support.
13
+ - `codacy_get_repository_with_analysis`: Get repository with analysis information, including metrics for Grade, Issues, Duplication, Complexity, and Coverage.
12
14
 
13
15
  ### Code Quality and Analysis
14
16
 
@@ -28,16 +30,20 @@ The following tools are available through the Codacy MCP Server:
28
30
  - Performance issue investigation
29
31
  - Complexity analysis
30
32
 
31
- ### File Management
33
+ ### File Management and Analysis
32
34
 
33
35
  - `codacy_list_files`: List files in a repository with pagination support.
34
36
  - `codacy_get_file_issues`: Get the issue list for a file in a repository.
35
37
  - `codacy_get_file_coverage`: Get coverage information for a file in the head commit of a repository branch.
36
- - `codacy_get_file_clones`: Get the list of duplication clones (identical or very similar code segments) for a file in a repository. Use this tool to identify potential refactoring opportunities and reduce code duplication.
38
+ - `codacy_get_file_clones`: Get the list of duplication clones (identical or very similar code segments) for a file in a repository.
39
+ - `codacy_get_file_with_analysis`: Get detailed analysis information for a file, including metrics for Grade, Issues, Duplication, Complexity, and Coverage.
37
40
 
38
41
  ### Security Analysis
39
42
 
40
- - `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:
43
+ - `codacy_search_organization_srm_items`: Primary tool to list security items/issues/vulnerabilities/findings across an organization. Results are related to the organization's security and risk management (SRM) dashboard on Codacy.
44
+ - `codacy_search_repository_srm_items`: List security items/issues/vulnerabilities/findings for a specific repository.
45
+
46
+ Both tools provide comprehensive security analysis including:
41
47
 
42
48
  - SAST (Code scanning)
43
49
  - Secrets (Secret scanning)
@@ -47,19 +53,29 @@ The following tools are available through the Codacy MCP Server:
47
53
  - DAST (Dynamic Application Security Testing)
48
54
  - PenTesting (Penetration testing)
49
55
 
50
- Use this as the first tool when investigating security or compliance concerns.
51
-
52
56
  ### Pull Request Analysis
53
57
 
54
- - `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.
55
- - `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_list_repository_pull_requests`: List pull requests from a repository that the user has access to.
59
+ - `codacy_get_repository_pull_request`: Get detailed information about a specific pull request.
60
+ - `codacy_list_pull_request_issues`: Returns a list of issues found in a pull request (new or fixed issues).
56
61
  - `codacy_get_pull_request_files_coverage`: Get diff coverage information for all files in a pull request.
57
62
  - `codacy_get_pull_request_git_diff`: Returns the human-readable Git diff of a pull request.
58
63
 
59
- ### CLI Analysis
64
+ ### Tool and Pattern Management
60
65
 
61
- - `codacy_cli_analyze`: Uses Codacy's command-line tool to analyze code.
66
+ - `codacy_list_tools`: List all code analysis tools available in Codacy.
67
+ - `codacy_list_repository_tools`: Get analysis tools settings and available tools for a repository.
68
+ - `codacy_get_pattern`: Get the definition of a specific pattern.
69
+ - `codacy_list_repository_tool_patterns`: List the patterns of a tool available for a repository.
70
+ - `codacy_get_issue`: Get detailed information about a specific issue.
71
+
72
+ ### CLI Analysis
62
73
 
74
+ - `codacy_cli_analyze`: Run quality analysis locally using Codacy CLI. Features include:
75
+ - Analyze specific files or entire directories
76
+ - Use specific tools or all available tools
77
+ - Get immediate results without waiting for scheduled analysis
78
+ - Apply fixes based on Codacy configuration
63
79
 
64
80
  ## Setup
65
81
 
package/dist/index.js CHANGED
@@ -139,6 +139,10 @@ const toolDefinitions = {
139
139
  tool: Tools.cliAnalyzeTool,
140
140
  handler: Handlers.cliAnalyzeHandler,
141
141
  },
142
+ codacy_setup_repository: {
143
+ tool: Tools.setupRepositoryTool,
144
+ handler: Handlers.setupRepositoryHandler,
145
+ },
142
146
  };
143
147
  // Register tools
144
148
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
@@ -6,3 +6,4 @@ export * from './security.js';
6
6
  export * from './tools.js';
7
7
  export * from './account.js';
8
8
  export * from './cliAnalyze.js';
9
+ export * from './setupRepository.js';
@@ -0,0 +1,135 @@
1
+ import { AccountService, OrganizationService, RepositoryService } from '../api/client/index.js';
2
+ const findOrganization = async (provider, organization, cursor) => {
3
+ try {
4
+ const { data: orgs, pagination } = await AccountService.listOrganizations(provider, cursor, 100);
5
+ const existingOrg = orgs.find(org => org.name === organization && org.provider === provider);
6
+ if (!existingOrg) {
7
+ if (pagination?.cursor === null) {
8
+ return {
9
+ success: false,
10
+ message: 'Organization not found',
11
+ };
12
+ }
13
+ return findOrganization(provider, organization, pagination?.cursor);
14
+ }
15
+ return {
16
+ success: true,
17
+ organization: existingOrg,
18
+ };
19
+ }
20
+ catch (error) {
21
+ return {
22
+ success: false,
23
+ message: `Failed to find organization: ${error instanceof Error ? error.message : 'Unknown error'}`,
24
+ };
25
+ }
26
+ };
27
+ const addOrganization = async (args) => {
28
+ const { provider, organization } = args;
29
+ const findOrgResult = await findOrganization(provider, organization);
30
+ if (!findOrgResult.success) {
31
+ return findOrgResult;
32
+ }
33
+ const { organization: existingOrg } = findOrgResult;
34
+ if (existingOrg?.joinStatus === 'member') {
35
+ return {
36
+ success: true,
37
+ message: `Organization already added to Codacy: ${JSON.stringify(existingOrg)}`,
38
+ };
39
+ }
40
+ if (existingOrg?.joinStatus === 'pendingMember') {
41
+ return {
42
+ success: false,
43
+ message: 'Waiting for join request to be approved',
44
+ };
45
+ }
46
+ if (existingOrg?.joinStatus === 'remoteMember') {
47
+ if (existingOrg.identifier) {
48
+ try {
49
+ await OrganizationService.joinOrganization(provider, organization);
50
+ }
51
+ catch (error) {
52
+ return {
53
+ success: false,
54
+ message: `Failed to join organization: ${error instanceof Error ? error.message : 'Unknown error'}`,
55
+ };
56
+ }
57
+ }
58
+ else {
59
+ await OrganizationService.addOrganization({
60
+ provider,
61
+ remoteIdentifier: existingOrg.remoteIdentifier,
62
+ name: organization,
63
+ type: existingOrg.type,
64
+ });
65
+ return {
66
+ success: true,
67
+ message: 'Organization added to Codacy',
68
+ };
69
+ }
70
+ }
71
+ return {
72
+ success: false,
73
+ message: 'Organization not found',
74
+ };
75
+ };
76
+ export const setupRepositoryHandler = async (args) => {
77
+ const { provider, organization, repository } = args;
78
+ const repositoryFullPath = `${organization}/${repository}`;
79
+ const addOrgResult = await addOrganization({ provider, organization });
80
+ if (!addOrgResult.success) {
81
+ return addOrgResult;
82
+ }
83
+ const { data: orgData } = await OrganizationService.getOrganization(provider, organization);
84
+ const isAdmin = orgData.membership.userRole === 'admin';
85
+ const { data } = await OrganizationService.listOrganizationRepositories(provider, organization, undefined, 10, repository, 'NotSynced');
86
+ const remoteRepository = data.find(repo => repo.fullPath === repositoryFullPath);
87
+ if (!remoteRepository) {
88
+ return {
89
+ success: false,
90
+ message: `Repository not found`,
91
+ };
92
+ }
93
+ if (remoteRepository?.addedState === 'Added') {
94
+ if (!isAdmin) {
95
+ try {
96
+ await RepositoryService.followAddedRepository(provider, organization, repository);
97
+ return {
98
+ success: true,
99
+ message: 'Repository followed',
100
+ };
101
+ }
102
+ catch (error) {
103
+ return {
104
+ success: false,
105
+ error: error,
106
+ message: `Failed to follow repository: ${error instanceof Error ? error.message : 'Unknown error'}`,
107
+ };
108
+ }
109
+ }
110
+ return {
111
+ success: true,
112
+ message: 'Repository is already added to Codacy',
113
+ };
114
+ }
115
+ if (remoteRepository?.addedState === 'Following') {
116
+ return {
117
+ success: true,
118
+ message: 'Repository is already being followed',
119
+ };
120
+ }
121
+ try {
122
+ await RepositoryService.addRepository({ provider, repositoryFullPath });
123
+ return {
124
+ success: true,
125
+ message: 'Repository added to Codacy',
126
+ };
127
+ }
128
+ catch (error) {
129
+ return {
130
+ success: false,
131
+ error: error,
132
+ message: `Failed to add repository: ${error instanceof Error ? error.message : 'Unknown error'}`,
133
+ };
134
+ }
135
+ };
@@ -21,6 +21,7 @@ export const toolNames = {
21
21
  CODACY_GET_PATTERN: 'codacy_get_pattern',
22
22
  CODACY_CLI_ANALYZE: 'codacy_cli_analyze',
23
23
  CODACY_GET_FILE_CLONES: 'codacy_get_file_clones',
24
+ CODACY_SETUP_REPOSITORY: 'codacy_setup_repository',
24
25
  };
25
26
  export const organizationSchema = {
26
27
  provider: {
@@ -19,3 +19,4 @@ export * from './listToolsTool.js';
19
19
  export * from './listOrganizationsTool.js';
20
20
  export * from './cliAnalyzeTool.js';
21
21
  export * from './getFileClonesTool.js';
22
+ export * from './setupRepositoryTool.js';
@@ -0,0 +1,12 @@
1
+ import { repositorySchema, toolNames } from '../schemas.js';
2
+ export const setupRepositoryTool = {
3
+ name: toolNames.CODACY_SETUP_REPOSITORY,
4
+ description: 'Use this tool to setup a repository. If the organization the repository belongs to is not added, this tool will add the organization and then add the repository to the organization. If the repository is not added and the user is an admin, this tool will add the repository to the organization. If the repository is already added and the user is not an admin, this tool will follow the repository.',
5
+ inputSchema: {
6
+ type: 'object',
7
+ properties: {
8
+ ...repositorySchema,
9
+ },
10
+ required: ['provider', 'organization', 'repository'],
11
+ },
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",