@codacy/codacy-mcp 0.0.5 → 0.1.0
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/dist/index.js +130 -2
- package/package.json +1 -1
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 } from './src/api/client/index.js';
|
|
5
|
+
import { OpenAPI, OrganizationService, RepositoryService, AnalysisService, } 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 || '',
|
|
@@ -15,6 +15,63 @@ const server = new Server({
|
|
|
15
15
|
tools: {},
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
|
+
const codacyLanguages = [
|
|
19
|
+
'C',
|
|
20
|
+
'CPP',
|
|
21
|
+
'CSharp',
|
|
22
|
+
'Java',
|
|
23
|
+
'Go',
|
|
24
|
+
'Kotlin',
|
|
25
|
+
'Ruby',
|
|
26
|
+
'Scala',
|
|
27
|
+
'Dart',
|
|
28
|
+
'Python',
|
|
29
|
+
'TypeScript',
|
|
30
|
+
'Javascript',
|
|
31
|
+
'CoffeeScript',
|
|
32
|
+
'Swift',
|
|
33
|
+
'JSP',
|
|
34
|
+
'VisualBasic',
|
|
35
|
+
'PHP',
|
|
36
|
+
'PLSQL',
|
|
37
|
+
'SQL',
|
|
38
|
+
'TSQL',
|
|
39
|
+
'Crystal',
|
|
40
|
+
'Haskell',
|
|
41
|
+
'Elixir',
|
|
42
|
+
'Groovy',
|
|
43
|
+
'Apex',
|
|
44
|
+
'VisualForce',
|
|
45
|
+
'Velocity',
|
|
46
|
+
'CSS',
|
|
47
|
+
'HTML',
|
|
48
|
+
'LESS',
|
|
49
|
+
'SASS',
|
|
50
|
+
'Dockerfile',
|
|
51
|
+
'Terraform',
|
|
52
|
+
'Shell',
|
|
53
|
+
'Powershell',
|
|
54
|
+
'JSON',
|
|
55
|
+
'XML',
|
|
56
|
+
'YAML',
|
|
57
|
+
'Markdown',
|
|
58
|
+
'Cobol',
|
|
59
|
+
'ABAP',
|
|
60
|
+
'ObjectiveC',
|
|
61
|
+
'Rust',
|
|
62
|
+
];
|
|
63
|
+
const issueCategories = [
|
|
64
|
+
'security',
|
|
65
|
+
'errorprone',
|
|
66
|
+
'performance',
|
|
67
|
+
'complexity',
|
|
68
|
+
'unusedcode',
|
|
69
|
+
'comprehensibility',
|
|
70
|
+
'compatibility',
|
|
71
|
+
'bestpractice',
|
|
72
|
+
'codestyle',
|
|
73
|
+
'documentation',
|
|
74
|
+
];
|
|
18
75
|
// Tool definitions
|
|
19
76
|
const listOrganizationRepositoriesTool = {
|
|
20
77
|
name: 'codacy_list_repositories',
|
|
@@ -42,7 +99,66 @@ const listOrganizationRepositoriesTool = {
|
|
|
42
99
|
},
|
|
43
100
|
},
|
|
44
101
|
};
|
|
45
|
-
|
|
102
|
+
const searchRepositoryIssuesTool = {
|
|
103
|
+
name: 'codacy_list_repository_issues',
|
|
104
|
+
description: 'List issues in a repository with pagination',
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
provider: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
111
|
+
},
|
|
112
|
+
organization: {
|
|
113
|
+
type: 'string',
|
|
114
|
+
description: 'Organization name on the Git provider',
|
|
115
|
+
},
|
|
116
|
+
repository: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
description: 'Repository name on the Git provider organization',
|
|
119
|
+
},
|
|
120
|
+
body: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
description: 'Search parameters to filter the list of issues in a repository',
|
|
123
|
+
properties: {
|
|
124
|
+
branchName: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
description: 'Branch name, by default the main branch defined on the Codacy repository settings is used',
|
|
127
|
+
},
|
|
128
|
+
patternIds: {
|
|
129
|
+
type: 'array',
|
|
130
|
+
description: 'Set of code pattern identifiers',
|
|
131
|
+
},
|
|
132
|
+
languages: {
|
|
133
|
+
type: 'array',
|
|
134
|
+
description: `Set of language names, without spaces. Accepted values: ${codacyLanguages.join(', ')}`,
|
|
135
|
+
},
|
|
136
|
+
categories: {
|
|
137
|
+
type: 'array',
|
|
138
|
+
description: `Set of issue categories. Accepted values: ${issueCategories.join(', ')}`,
|
|
139
|
+
},
|
|
140
|
+
levels: {
|
|
141
|
+
type: 'array',
|
|
142
|
+
description: 'Set of issue severity levels. Accepted values: Info, Warning and Error. Codacy maps these values as follows: Info->Minor, Warning->Medium, Error->Critical',
|
|
143
|
+
},
|
|
144
|
+
authorEmails: {
|
|
145
|
+
type: 'array',
|
|
146
|
+
description: 'Set of commit author email addresses',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
cursor: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
description: 'Pagination cursor for next page of results',
|
|
153
|
+
},
|
|
154
|
+
limit: {
|
|
155
|
+
type: 'number',
|
|
156
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
157
|
+
default: 100,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
};
|
|
46
162
|
const listFilesTool = {
|
|
47
163
|
name: 'codacy_list_files',
|
|
48
164
|
description: 'List files in a repository with pagination',
|
|
@@ -148,6 +264,7 @@ const getFileCoverageTool = {
|
|
|
148
264
|
},
|
|
149
265
|
},
|
|
150
266
|
};
|
|
267
|
+
// Handlers
|
|
151
268
|
const listOrganizationRepositoriesHandler = async (args) => {
|
|
152
269
|
const { provider, organization, limit, cursor } = args;
|
|
153
270
|
return await OrganizationService.listOrganizationRepositories(provider, organization, cursor, limit);
|
|
@@ -164,11 +281,16 @@ const getFileCoverageHandler = async (args) => {
|
|
|
164
281
|
const { provider, organization, repository, fileId } = args;
|
|
165
282
|
return await RepositoryService.getFileCoverage(provider, organization, repository, fileId);
|
|
166
283
|
};
|
|
284
|
+
const searchRepositoryIssuesHandler = async (args) => {
|
|
285
|
+
const { provider, organization, repository, limit, cursor, body } = args;
|
|
286
|
+
return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
|
|
287
|
+
};
|
|
167
288
|
// Register tools
|
|
168
289
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
169
290
|
return {
|
|
170
291
|
tools: [
|
|
171
292
|
listOrganizationRepositoriesTool,
|
|
293
|
+
searchRepositoryIssuesTool,
|
|
172
294
|
listFilesTool,
|
|
173
295
|
getFileIssuesTool,
|
|
174
296
|
getFileCoverageTool,
|
|
@@ -206,6 +328,12 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
206
328
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
207
329
|
};
|
|
208
330
|
}
|
|
331
|
+
case 'codacy_list_repository_issues': {
|
|
332
|
+
const result = await searchRepositoryIssuesHandler(request.params.arguments);
|
|
333
|
+
return {
|
|
334
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
335
|
+
};
|
|
336
|
+
}
|
|
209
337
|
default:
|
|
210
338
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
211
339
|
}
|