@codacy/codacy-mcp 0.0.3-trytofixnpmpublish.3.8e344f8 → 0.0.5-fixpublishstep.1.6c065b4
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 +143 -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 } from './src/api/client/index.js';
|
|
5
|
+
import { OpenAPI, OrganizationService, RepositoryService } 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 || '',
|
|
@@ -42,14 +42,137 @@ const listOrganizationRepositoriesTool = {
|
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
|
+
//File endpoints
|
|
46
|
+
const listFilesTool = {
|
|
47
|
+
name: 'codacy_list_files',
|
|
48
|
+
description: 'List files in a repository with pagination',
|
|
49
|
+
inputSchema: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
provider: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
55
|
+
},
|
|
56
|
+
organization: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Organization name on the Git provider',
|
|
59
|
+
},
|
|
60
|
+
repository: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'Repository name on the Git provider organization',
|
|
63
|
+
},
|
|
64
|
+
branch: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Name of a repository branch enabled on Codacy',
|
|
67
|
+
},
|
|
68
|
+
search: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'Filter files that include this string anywhere in their relative path',
|
|
71
|
+
},
|
|
72
|
+
sort: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: "Field used to sort the list of files. The allowed values are 'filename', 'issues', 'grade', 'duplication', 'complexity', and 'coverage'.",
|
|
75
|
+
},
|
|
76
|
+
direction: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: "Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending).",
|
|
79
|
+
},
|
|
80
|
+
cursor: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description: 'Pagination cursor for next page of results',
|
|
83
|
+
},
|
|
84
|
+
limit: {
|
|
85
|
+
type: 'number',
|
|
86
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
87
|
+
default: 100,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
const getFileIssuesTool = {
|
|
93
|
+
name: 'codacy_get_file_issues',
|
|
94
|
+
description: 'Get the issue list for a file in a repository',
|
|
95
|
+
inputSchema: {
|
|
96
|
+
type: 'object',
|
|
97
|
+
properties: {
|
|
98
|
+
provider: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
101
|
+
},
|
|
102
|
+
organization: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Organization name on the Git provider',
|
|
105
|
+
},
|
|
106
|
+
repository: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Repository name on the Git provider organization',
|
|
109
|
+
},
|
|
110
|
+
fileId: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Identifier of a file in a specific commit',
|
|
113
|
+
},
|
|
114
|
+
cursor: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
description: 'Pagination cursor for next page of results',
|
|
117
|
+
},
|
|
118
|
+
limit: {
|
|
119
|
+
type: 'number',
|
|
120
|
+
description: 'Maximum number of results to return (default 100, max 100)',
|
|
121
|
+
default: 100,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
const getFileCoverageTool = {
|
|
127
|
+
name: 'codacy_get_file_coverage',
|
|
128
|
+
description: 'Get coverage information for a file in the head commit of a repository branch.',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
provider: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
|
|
135
|
+
},
|
|
136
|
+
organization: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Organization name on the Git provider',
|
|
139
|
+
},
|
|
140
|
+
repository: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Repository name on the Git provider organization',
|
|
143
|
+
},
|
|
144
|
+
fileId: {
|
|
145
|
+
type: 'string',
|
|
146
|
+
description: 'Identifier of a file in a specific commit',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
};
|
|
45
151
|
const listOrganizationRepositoriesHandler = async (args) => {
|
|
46
152
|
const { provider, organization, limit, cursor } = args;
|
|
47
153
|
return await OrganizationService.listOrganizationRepositories(provider, organization, cursor, limit);
|
|
48
154
|
};
|
|
155
|
+
const listFilesHandler = async (args) => {
|
|
156
|
+
const { provider, organization, repository, branch, search, sort, direction, cursor, limit } = args;
|
|
157
|
+
return await RepositoryService.listFiles(provider, organization, repository, branch, search, sort, direction, cursor, limit);
|
|
158
|
+
};
|
|
159
|
+
const getFileIssuesHandler = async (args) => {
|
|
160
|
+
const { provider, organization, repository, fileId, limit, cursor } = args;
|
|
161
|
+
return await RepositoryService.getFileIssues(provider, organization, repository, fileId, limit, cursor);
|
|
162
|
+
};
|
|
163
|
+
const getFileCoverageHandler = async (args) => {
|
|
164
|
+
const { provider, organization, repository, fileId } = args;
|
|
165
|
+
return await RepositoryService.getFileCoverage(provider, organization, repository, fileId);
|
|
166
|
+
};
|
|
49
167
|
// Register tools
|
|
50
168
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
51
169
|
return {
|
|
52
|
-
tools: [
|
|
170
|
+
tools: [
|
|
171
|
+
listOrganizationRepositoriesTool,
|
|
172
|
+
listFilesTool,
|
|
173
|
+
getFileIssuesTool,
|
|
174
|
+
getFileCoverageTool,
|
|
175
|
+
],
|
|
53
176
|
};
|
|
54
177
|
});
|
|
55
178
|
// Register request handlers
|
|
@@ -65,6 +188,24 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
65
188
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
66
189
|
};
|
|
67
190
|
}
|
|
191
|
+
case 'codacy_list_files': {
|
|
192
|
+
const result = await listFilesHandler(request.params.arguments);
|
|
193
|
+
return {
|
|
194
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
case 'codacy_get_file_issues': {
|
|
198
|
+
const result = await getFileIssuesHandler(request.params.arguments);
|
|
199
|
+
return {
|
|
200
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
case 'codacy_get_file_coverage': {
|
|
204
|
+
const result = await getFileCoverageHandler(request.params.arguments);
|
|
205
|
+
return {
|
|
206
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
68
209
|
default:
|
|
69
210
|
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
70
211
|
}
|