@codacy/codacy-mcp 0.6.17 → 0.6.19
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 +13 -1
- package/dist/index.js +10 -32
- package/dist/src/cli/MacCodacyCli.js +2 -3
- package/dist/src/handlers/cliInstall.js +17 -0
- package/dist/src/handlers/index.js +1 -0
- package/dist/src/schemas.js +1 -0
- package/dist/src/tools/cliInstallTool.js +24 -0
- package/dist/src/tools/index.js +1 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -236,7 +236,19 @@ npm run update-api
|
|
|
236
236
|
npm run build
|
|
237
237
|
```
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
### Testing with Inspector
|
|
240
|
+
|
|
241
|
+
You can test the MCP server using the inspector tool. You can either set a `CODACY_ACCOUNT_TOKEN` environment variable or pass it inline:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
CODACY_ACCOUNT_TOKEN=your_token_here npm run inspect
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
This will build the project and launch the MCP inspector with your Codacy token.
|
|
248
|
+
|
|
249
|
+
### Testing with an Agent
|
|
250
|
+
|
|
251
|
+
You can test your local instance configuring the MCP Server as follows:
|
|
240
252
|
|
|
241
253
|
```
|
|
242
254
|
"codacy": {
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
4
|
import { OpenAPI } from './src/api/client/index.js';
|
|
6
5
|
import * as Tools from './src/tools/index.js';
|
|
7
6
|
import * as Handlers from './src/handlers/index.js';
|
|
7
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
8
|
// Check for API key
|
|
9
9
|
const CODACY_ACCOUNT_TOKEN = process.env.CODACY_ACCOUNT_TOKEN;
|
|
10
10
|
OpenAPI.BASE = 'https://app.codacy.com/api/v3';
|
|
@@ -12,40 +12,13 @@ OpenAPI.HEADERS = {
|
|
|
12
12
|
'api-token': CODACY_ACCOUNT_TOKEN || '',
|
|
13
13
|
'X-Codacy-Origin': 'mcp-server',
|
|
14
14
|
};
|
|
15
|
-
const
|
|
15
|
+
const mcpServer = new McpServer({
|
|
16
16
|
name: 'codacy-mcp-server',
|
|
17
17
|
version: '0.1.0',
|
|
18
18
|
}, {
|
|
19
19
|
capabilities: {
|
|
20
20
|
tools: {},
|
|
21
21
|
resources: {},
|
|
22
|
-
triggers: {
|
|
23
|
-
patterns: [
|
|
24
|
-
'codacy',
|
|
25
|
-
'code quality',
|
|
26
|
-
'code analysis',
|
|
27
|
-
'security vulnerabilities',
|
|
28
|
-
'repository issues',
|
|
29
|
-
'pull request analysis',
|
|
30
|
-
'code coverage',
|
|
31
|
-
'issues',
|
|
32
|
-
'security',
|
|
33
|
-
'srm',
|
|
34
|
-
'analysis',
|
|
35
|
-
'tool',
|
|
36
|
-
'pattern',
|
|
37
|
-
'pull request',
|
|
38
|
-
'repository',
|
|
39
|
-
'file',
|
|
40
|
-
'coverage',
|
|
41
|
-
'git',
|
|
42
|
-
'diff',
|
|
43
|
-
'branch',
|
|
44
|
-
'commit',
|
|
45
|
-
'severity',
|
|
46
|
-
'organization',
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
22
|
},
|
|
50
23
|
});
|
|
51
24
|
const toolDefinitions = {
|
|
@@ -140,19 +113,24 @@ const toolDefinitions = {
|
|
|
140
113
|
handler: Handlers.cliAnalyzeHandler,
|
|
141
114
|
noAuth: true,
|
|
142
115
|
},
|
|
116
|
+
codacy_cli_install: {
|
|
117
|
+
tool: Tools.cliInstallTool,
|
|
118
|
+
handler: Handlers.cliInstallHandler,
|
|
119
|
+
noAuth: true,
|
|
120
|
+
},
|
|
143
121
|
codacy_setup_repository: {
|
|
144
122
|
tool: Tools.setupRepositoryTool,
|
|
145
123
|
handler: Handlers.setupRepositoryHandler,
|
|
146
124
|
},
|
|
147
125
|
};
|
|
148
126
|
// Register tools
|
|
149
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
127
|
+
mcpServer.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
150
128
|
tools: Object.values(toolDefinitions)
|
|
151
129
|
.filter(({ noAuth }) => CODACY_ACCOUNT_TOKEN || noAuth)
|
|
152
130
|
.map(({ tool }) => tool),
|
|
153
131
|
}));
|
|
154
132
|
// Register request handlers
|
|
155
|
-
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
133
|
+
mcpServer.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
156
134
|
try {
|
|
157
135
|
if (!request.params.arguments) {
|
|
158
136
|
throw new Error('Arguments are required');
|
|
@@ -179,7 +157,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
179
157
|
});
|
|
180
158
|
async function runServer() {
|
|
181
159
|
const transport = new StdioServerTransport();
|
|
182
|
-
await
|
|
160
|
+
await mcpServer.connect(transport);
|
|
183
161
|
console.error('Codacy MCP Server running on stdio');
|
|
184
162
|
}
|
|
185
163
|
runServer().catch(error => {
|
|
@@ -14,9 +14,8 @@ export class MacCodacyCli extends CodacyCli {
|
|
|
14
14
|
this.setCliCommand(this._cliVersion ? `CODACY_CLI_V2_VERSION=${this._cliVersion} ${localPath}` : localPath);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
// CLI not found,
|
|
18
|
-
|
|
19
|
-
return;
|
|
17
|
+
// CLI not found, throw error
|
|
18
|
+
throw new Error(`Codacy CLI not found. Please install it first.`);
|
|
20
19
|
}
|
|
21
20
|
async preflightCodacyCli() {
|
|
22
21
|
// is there a command?
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cli } from '../cli/index.js';
|
|
2
|
+
export const cliInstallHandler = async (args) => {
|
|
3
|
+
const cli = await Cli.get(args);
|
|
4
|
+
try {
|
|
5
|
+
await cli.install();
|
|
6
|
+
return {
|
|
7
|
+
success: true,
|
|
8
|
+
result: 'CLI installed successfully',
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
return {
|
|
13
|
+
success: false,
|
|
14
|
+
output: error instanceof Error ? error.message : 'Unknown error',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
package/dist/src/schemas.js
CHANGED
|
@@ -20,6 +20,7 @@ export const toolNames = {
|
|
|
20
20
|
CODACY_GET_ISSUE: 'codacy_get_issue',
|
|
21
21
|
CODACY_GET_PATTERN: 'codacy_get_pattern',
|
|
22
22
|
CODACY_CLI_ANALYZE: 'codacy_cli_analyze',
|
|
23
|
+
CODACY_CLI_INSTALL: 'codacy_cli_install',
|
|
23
24
|
CODACY_GET_FILE_CLONES: 'codacy_get_file_clones',
|
|
24
25
|
CODACY_SETUP_REPOSITORY: 'codacy_setup_repository',
|
|
25
26
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { generalOrganizationMistakes, generalRepositoryMistakes } from '../rules.js';
|
|
2
|
+
import { repositorySchema, toolNames } from '../schemas.js';
|
|
3
|
+
const rules = `
|
|
4
|
+
Common use cases:
|
|
5
|
+
- When the user tried to use Codacy CLI and it is not installed
|
|
6
|
+
|
|
7
|
+
Common mistakes:
|
|
8
|
+
${generalOrganizationMistakes}
|
|
9
|
+
${generalRepositoryMistakes}
|
|
10
|
+
`;
|
|
11
|
+
const optionalRepositorySchema = JSON.parse(JSON.stringify(repositorySchema));
|
|
12
|
+
optionalRepositorySchema.provider.description = `Optional. ${repositorySchema.provider.description}`;
|
|
13
|
+
optionalRepositorySchema.organization.description = `Optional. ${repositorySchema.organization.description}`;
|
|
14
|
+
optionalRepositorySchema.repository.description = `Optional. ${repositorySchema.repository.description}`;
|
|
15
|
+
export const cliInstallTool = {
|
|
16
|
+
name: toolNames.CODACY_CLI_INSTALL,
|
|
17
|
+
description: `Install the Codacy CLI used for local analysis. \n ${rules}`,
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
...optionalRepositorySchema,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
package/dist/src/tools/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/codacy-mcp",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
|
+
"mcpName": "io.github.codacy/codacy-mcp-server",
|
|
4
5
|
"description": "Codacy MCP server",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "Codacy",
|
|
@@ -28,10 +29,10 @@
|
|
|
28
29
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
29
30
|
"format": "prettier --write \"**/*.{ts,json,md}\"",
|
|
30
31
|
"format:check": "prettier --check \"**/*.{ts,json,md}\"",
|
|
31
|
-
"inspect": "npm run build && npx @modelcontextprotocol/inspector -e CODACY_ACCOUNT_TOKEN
|
|
32
|
+
"inspect": "npm run build && npx @modelcontextprotocol/inspector -e CODACY_ACCOUNT_TOKEN=$CODACY_ACCOUNT_TOKEN node dist/index.js"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@modelcontextprotocol/sdk": "1.
|
|
35
|
+
"@modelcontextprotocol/sdk": "1.25.2",
|
|
35
36
|
"@types/node": "^22",
|
|
36
37
|
"@types/node-fetch": "^2.6.12",
|
|
37
38
|
"@types/sarif": "2.1.7",
|