@codacy/codacy-mcp 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.js +173 -3
  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, AnalysisService, SecurityService, } from './src/api/client/index.js';
5
+ import { OpenAPI, OrganizationService, RepositoryService, AnalysisService, SecurityService, CoverageService, } 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 || '',
@@ -297,6 +297,108 @@ const securityScanTypes = {
297
297
  DAST: 'Dynamic Application Security Testing',
298
298
  PenTesting: 'Penetration testing',
299
299
  };
300
+ //PR endpoints
301
+ const listRepositoryPullRequestsTool = {
302
+ name: 'codacy_list_repository_pull_requests',
303
+ description: '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',
304
+ inputSchema: {
305
+ type: 'object',
306
+ properties: {
307
+ provider: {
308
+ type: 'string',
309
+ description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
310
+ },
311
+ organization: {
312
+ type: 'string',
313
+ description: 'Organization name on the Git provider',
314
+ },
315
+ repository: {
316
+ type: 'string',
317
+ description: 'Repository name on the Git provider organization',
318
+ },
319
+ includeNotAnalyzed: {
320
+ type: 'boolean',
321
+ description: 'If true, includes pull requests that have not been analyzed',
322
+ },
323
+ cursor: {
324
+ type: 'string',
325
+ description: 'Pagination cursor for next page of results',
326
+ },
327
+ limit: {
328
+ type: 'number',
329
+ description: 'Maximum number of results to return (default 100, max 100)',
330
+ default: 100,
331
+ },
332
+ },
333
+ },
334
+ };
335
+ const listPullRequestIssuesTool = {
336
+ name: 'codacy_list_pull_request_issues',
337
+ description: 'Returns a list of issues found in a pull request. We can request either new or fixed issues.',
338
+ inputSchema: {
339
+ type: 'object',
340
+ properties: {
341
+ provider: {
342
+ type: 'string',
343
+ description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
344
+ },
345
+ organization: {
346
+ type: 'string',
347
+ description: 'Organization name on the Git provider',
348
+ },
349
+ repository: {
350
+ type: 'string',
351
+ description: 'Repository name on the Git provider organization',
352
+ },
353
+ pullRequestNumber: {
354
+ type: 'number',
355
+ description: 'Pull request number',
356
+ },
357
+ status: {
358
+ type: 'string',
359
+ description: 'Filter issues by status. Accepted values: all, new, fixed.',
360
+ },
361
+ onlyPotential: {
362
+ type: 'boolean',
363
+ description: 'If true, retrieves only potential issues',
364
+ },
365
+ cursor: {
366
+ type: 'string',
367
+ description: 'Pagination cursor for next page of results',
368
+ },
369
+ limit: {
370
+ type: 'number',
371
+ description: 'Maximum number of results to return (default 100, max 100)',
372
+ default: 100,
373
+ },
374
+ },
375
+ },
376
+ };
377
+ const getRepositoryPullRequestFilesCoverageTool = {
378
+ name: 'codacy_get_repository_pull_request_files_coverage',
379
+ description: 'Get coverage information for all files in a pull request.',
380
+ inputSchema: {
381
+ type: 'object',
382
+ properties: {
383
+ provider: {
384
+ type: 'string',
385
+ description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
386
+ },
387
+ organization: {
388
+ type: 'string',
389
+ description: 'Organization name on the Git provider',
390
+ },
391
+ repository: {
392
+ type: 'string',
393
+ description: 'Repository name on the Git provider organization',
394
+ },
395
+ pullRequestNumber: {
396
+ type: 'number',
397
+ description: 'Pull request number',
398
+ },
399
+ },
400
+ },
401
+ };
300
402
  const searchSecurityItemsTool = {
301
403
  name: 'codacy_list_srm_items',
302
404
  description: `Primary tool to list security items/issues/vulnerabilities/findings, results are related to the organization security and risk management (SRM) dashboard on Codacy. This tool contains pagination. Returns comprehensive security analysis including ${Object.keys(securityScanTypes).join(', ')} security issues. Provides advanced filtering by security categories, priorities, and scan types. Use this as the first tool when investigating security or compliance concerns. Map the results statuses as open issues: ${securityStatuses.Open.join(', ')}; and closed issues: ${securityStatuses.Closed.join(', ')}. Prioritize the open issues as the most important ones in the results.`,
@@ -379,7 +481,31 @@ const searchSecurityItemsTool = {
379
481
  },
380
482
  },
381
483
  };
382
- // Handlers
484
+ const getPullRequestGitDiffTool = {
485
+ name: 'codacy_get_pull_request_git_diff',
486
+ description: 'Returns the human-readable Git diff of a pull request',
487
+ inputSchema: {
488
+ type: 'object',
489
+ properties: {
490
+ provider: {
491
+ type: 'string',
492
+ description: "Organization's git provider: GitHub (gh), GitLab (gl) or BitBucket (bb). Accepted values: gh, gl, bb.",
493
+ },
494
+ organization: {
495
+ type: 'string',
496
+ description: 'Organization name on the Git provider',
497
+ },
498
+ repository: {
499
+ type: 'string',
500
+ description: 'Repository name on the Git provider organization',
501
+ },
502
+ pullRequestNumber: {
503
+ type: 'number',
504
+ description: 'Pull request number',
505
+ },
506
+ },
507
+ },
508
+ };
383
509
  const listOrganizationRepositoriesHandler = async (args) => {
384
510
  const { provider, organization, limit, cursor } = args;
385
511
  return await OrganizationService.listOrganizationRepositories(provider, organization, cursor, limit);
@@ -390,7 +516,7 @@ const listFilesHandler = async (args) => {
390
516
  };
391
517
  const getFileIssuesHandler = async (args) => {
392
518
  const { provider, organization, repository, fileId, limit, cursor } = args;
393
- return await RepositoryService.getFileIssues(provider, organization, repository, fileId, limit, cursor);
519
+ return await RepositoryService.getFileIssues(provider, organization, repository, fileId, cursor, limit);
394
520
  };
395
521
  const getFileCoverageHandler = async (args) => {
396
522
  const { provider, organization, repository, fileId } = args;
@@ -400,10 +526,26 @@ const searchRepositoryIssuesHandler = async (args) => {
400
526
  const { provider, organization, repository, limit, cursor, body } = args;
401
527
  return await AnalysisService.searchRepositoryIssues(provider, organization, repository, cursor, limit, body);
402
528
  };
529
+ const listRepositoryPullRequestsHandler = async (args) => {
530
+ const { provider, organization, repository, search, includeNotAnalyzed, cursor, limit } = args;
531
+ return await AnalysisService.listRepositoryPullRequests(provider, organization, repository, limit, cursor, search, includeNotAnalyzed);
532
+ };
403
533
  const searchSecurityItemsHandler = async (args) => {
404
534
  const { provider, organization, cursor, limit, sort, direction, body } = args;
405
535
  return await SecurityService.searchSecurityItems(provider, organization, cursor, limit, sort, direction, body);
406
536
  };
537
+ const listPullRequestIssuesHandler = async (args) => {
538
+ const { provider, organization, repository, pullRequestNumber, status, onlyPotential, cursor, limit, } = args;
539
+ return await AnalysisService.listPullRequestIssues(provider, organization, repository, pullRequestNumber, status, onlyPotential, cursor, limit);
540
+ };
541
+ const getRepositoryPullRequestFilesCoverageHandler = async (args) => {
542
+ const { provider, organization, repository, pullRequestNumber } = args;
543
+ return await CoverageService.getRepositoryPullRequestFilesCoverage(provider, organization, repository, pullRequestNumber);
544
+ };
545
+ const getPullRequestGitDiffHandler = async (args) => {
546
+ const { provider, organization, repository, pullRequestNumber } = args;
547
+ return await CoverageService.getPullRequestGitDiff(provider, organization, repository, pullRequestNumber);
548
+ };
407
549
  // Register tools
408
550
  server.setRequestHandler(ListToolsRequestSchema, async () => {
409
551
  return {
@@ -414,6 +556,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
414
556
  getFileIssuesTool,
415
557
  getFileCoverageTool,
416
558
  searchSecurityItemsTool,
559
+ listRepositoryPullRequestsTool,
560
+ listPullRequestIssuesTool,
561
+ getRepositoryPullRequestFilesCoverageTool,
562
+ getPullRequestGitDiffTool,
417
563
  ],
418
564
  };
419
565
  });
@@ -454,12 +600,36 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
454
600
  content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
455
601
  };
456
602
  }
603
+ case 'codacy_list_repository_pull_requests': {
604
+ const result = await listRepositoryPullRequestsHandler(request.params.arguments);
605
+ return {
606
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
607
+ };
608
+ }
457
609
  case 'codacy_list_srm_items': {
458
610
  const result = await searchSecurityItemsHandler(request.params.arguments);
459
611
  return {
460
612
  content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
461
613
  };
462
614
  }
615
+ case 'codacy_list_pull_request_issues': {
616
+ const result = await listPullRequestIssuesHandler(request.params.arguments);
617
+ return {
618
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
619
+ };
620
+ }
621
+ case 'codacy_get_repository_pull_request_files_coverage': {
622
+ const result = await getRepositoryPullRequestFilesCoverageHandler(request.params.arguments);
623
+ return {
624
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
625
+ };
626
+ }
627
+ case 'codacy_get_pull_request_git_diff': {
628
+ const result = await getPullRequestGitDiffHandler(request.params.arguments);
629
+ return {
630
+ content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
631
+ };
632
+ }
463
633
  default:
464
634
  throw new Error(`Unknown tool: ${request.params.name}`);
465
635
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/codacy-mcp",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Codacy MCP server",
5
5
  "license": "MIT",
6
6
  "author": "Codacy",