@codacy/codacy-mcp 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
- import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
5
5
  import { OpenAPI } from './src/api/client/index.js';
6
6
  import { getFileCoverageTool, listFileIssuesTool, getPullRequestGitDiffTool, getRepositoryPullRequestFilesCoverageTool, listFilesTool, listOrganizationRepositoriesTool, listPullRequestIssuesTool, listRepositoryPullRequestsTool, searchRepositoryIssuesTool, searchSecurityItemsTool, } from './src/tools/index.js';
7
7
  import { getFileCoverageHandler, getFileIssuesHandler, getPullRequestGitDiffHandler, getRepositoryPullRequestFilesCoverageHandler, listFilesHandler, listPullRequestIssuesHandler, listRepositoryPullRequestsHandler, searchRepositoryIssuesHandler, searchSecurityItemsHandler, listOrganizationRepositoriesHandler, } from './src/handlers/index.js';
@@ -17,93 +17,53 @@ const server = new Server({
17
17
  tools: {},
18
18
  },
19
19
  });
20
+ const toolDefinitions = {
21
+ codacy_list_organization_repositories: {
22
+ tool: listOrganizationRepositoriesTool,
23
+ handler: listOrganizationRepositoriesHandler,
24
+ },
25
+ codacy_list_srm_items: { tool: searchSecurityItemsTool, handler: searchSecurityItemsHandler },
26
+ codacy_list_repository_issues: {
27
+ tool: searchRepositoryIssuesTool,
28
+ handler: searchRepositoryIssuesHandler,
29
+ },
30
+ codacy_list_repository_pull_requests: {
31
+ tool: listRepositoryPullRequestsTool,
32
+ handler: listRepositoryPullRequestsHandler,
33
+ },
34
+ codacy_list_files: { tool: listFilesTool, handler: listFilesHandler },
35
+ codacy_get_file_issues: { tool: listFileIssuesTool, handler: getFileIssuesHandler },
36
+ codacy_get_file_coverage: { tool: getFileCoverageTool, handler: getFileCoverageHandler },
37
+ codacy_get_repository_pull_request_files_coverage: {
38
+ tool: getRepositoryPullRequestFilesCoverageTool,
39
+ handler: getRepositoryPullRequestFilesCoverageHandler,
40
+ },
41
+ codacy_get_pull_request_git_diff: {
42
+ tool: getPullRequestGitDiffTool,
43
+ handler: getPullRequestGitDiffHandler,
44
+ },
45
+ codacy_list_pull_request_issues: {
46
+ tool: listPullRequestIssuesTool,
47
+ handler: listPullRequestIssuesHandler,
48
+ },
49
+ };
20
50
  // Register tools
21
- server.setRequestHandler(ListToolsRequestSchema, async () => {
22
- return {
23
- tools: [
24
- listOrganizationRepositoriesTool,
25
- searchRepositoryIssuesTool,
26
- listFilesTool,
27
- listFileIssuesTool,
28
- getFileCoverageTool,
29
- searchSecurityItemsTool,
30
- listRepositoryPullRequestsTool,
31
- listPullRequestIssuesTool,
32
- getRepositoryPullRequestFilesCoverageTool,
33
- getPullRequestGitDiffTool,
34
- ],
35
- };
36
- });
51
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
52
+ tools: Object.values(toolDefinitions).map(({ tool }) => tool),
53
+ }));
37
54
  // Register request handlers
38
55
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
39
56
  try {
40
57
  if (!request.params.arguments) {
41
58
  throw new Error('Arguments are required');
42
59
  }
43
- switch (request.params.name) {
44
- case 'codacy_list_repositories': {
45
- const result = await listOrganizationRepositoriesHandler(request.params.arguments);
46
- return {
47
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
48
- };
49
- }
50
- case 'codacy_list_files': {
51
- const result = await listFilesHandler(request.params.arguments);
52
- return {
53
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
54
- };
55
- }
56
- case 'codacy_get_file_issues': {
57
- const result = await getFileIssuesHandler(request.params.arguments);
58
- return {
59
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
60
- };
61
- }
62
- case 'codacy_get_file_coverage': {
63
- const result = await getFileCoverageHandler(request.params.arguments);
64
- return {
65
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
66
- };
67
- }
68
- case 'codacy_list_repository_issues': {
69
- const result = await searchRepositoryIssuesHandler(request.params.arguments);
70
- return {
71
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
72
- };
73
- }
74
- case 'codacy_list_repository_pull_requests': {
75
- const result = await listRepositoryPullRequestsHandler(request.params.arguments);
76
- return {
77
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
78
- };
79
- }
80
- case 'codacy_list_srm_items': {
81
- const result = await searchSecurityItemsHandler(request.params.arguments);
82
- return {
83
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
84
- };
85
- }
86
- case 'codacy_list_pull_request_issues': {
87
- const result = await listPullRequestIssuesHandler(request.params.arguments);
88
- return {
89
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
90
- };
91
- }
92
- case 'codacy_get_repository_pull_request_files_coverage': {
93
- const result = await getRepositoryPullRequestFilesCoverageHandler(request.params.arguments);
94
- return {
95
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
96
- };
97
- }
98
- case 'codacy_get_pull_request_git_diff': {
99
- const result = await getPullRequestGitDiffHandler(request.params.arguments);
100
- return {
101
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
102
- };
103
- }
104
- default:
105
- throw new Error(`Unknown tool: ${request.params.name}`);
106
- }
60
+ const toolDefinition = toolDefinitions[request.params.name];
61
+ if (!toolDefinition)
62
+ throw new Error(`Unknown tool: ${request.params.name}`);
63
+ const result = await toolDefinition.handler(request.params.arguments);
64
+ return {
65
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
66
+ };
107
67
  }
108
68
  catch (error) {
109
69
  console.error(error);
@@ -1,6 +1,6 @@
1
1
  import { defaultPagination, organizationSchema } from './utils.js';
2
2
  export const listOrganizationRepositoriesTool = {
3
- name: 'codacy_list_repositories',
3
+ name: 'codacy_list_organization_repositories',
4
4
  description: 'List repositories in an organization with pagination',
5
5
  inputSchema: {
6
6
  type: 'object',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",