Skip to main content
Glama
sapientpants

DeepSource MCP Server

by sapientpants

compliance_report

Fetch security compliance reports for DeepSource projects, including OWASP Top 10, SANS Top 25, and code quality metrics to identify vulnerabilities and track issue resolution.

Instructions

Get security compliance reports from a DeepSource project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectKeyYesDeepSource project key to identify the project
reportTypeYesType of compliance report to fetch

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes
titleYes
statusYes
trendsNo
analysisYes
currentValueYes
recommendationsYes
securityIssueStatsYes

Implementation Reference

  • Registers the 'compliance_report' tool with the ToolRegistry, using the schema and a handler that adapts parameters and calls the main handler function.
    toolRegistry.registerTool({
      ...complianceReportToolSchema,
      handler: async (params) => {
        const adaptedParams = adaptComplianceReportParams(params);
        return handleDeepsourceComplianceReport(adaptedParams);
      },
    });
  • Defines the Zod schema for the 'compliance_report' tool, including input parameters (projectKey, reportType) and detailed output structure with analysis and recommendations.
    export const complianceReportToolSchema = {
      name: 'compliance_report',
      description: 'Get security compliance reports from a DeepSource project',
      inputSchema: {
        projectKey: z.string().describe('DeepSource project key to identify the project'),
        reportType: z.nativeEnum(ReportType).describe('Type of compliance report to fetch'),
      },
      outputSchema: {
        key: z.string(),
        title: z.string(),
        currentValue: z.number().nullable(),
        status: z.string(),
        securityIssueStats: z.array(
          z.object({
            key: z.string(),
            title: z.string(),
            occurrence: z.object({
              critical: z.number(),
              major: z.number(),
              minor: z.number(),
              total: z.number(),
            }),
          })
        ),
        trends: z.record(z.string(), z.unknown()).optional(),
        analysis: z.object({
          summary: z.string(),
          status_explanation: z.string(),
          critical_issues: z.number(),
          major_issues: z.number(),
          minor_issues: z.number(),
          total_issues: z.number(),
        }),
        recommendations: z.object({
          actions: z.array(z.string()),
          resources: z.array(z.string()),
        }),
      },
    };
  • Core handler logic that fetches the compliance report from the repository using domain aggregate, formats it with security stats, analysis, and recommendations, and returns as JSON text content.
    return async function handleComplianceReport(params: DeepsourceComplianceReportParams) {
      try {
        const { projectKey, reportType } = params;
        const projectKeyBranded = asProjectKey(projectKey);
        deps.logger.info('Fetching compliance report from repository', { projectKey, reportType });
    
        // Get the compliance report from repository
        const domainReport = await deps.complianceReportRepository.findByProjectAndType(
          projectKeyBranded,
          reportType
        );
    
        if (!domainReport) {
          throw new Error(`Report of type '${reportType}' not found for project '${projectKey}'`);
        }
    
        deps.logger.info('Successfully fetched compliance report', {
          projectKey,
          reportType,
          status: domainReport.status,
        });
    
        const reportData = {
          key: `${domainReport.projectKey}:${domainReport.reportType}`,
          title: `${domainReport.reportType} Compliance Report`,
          currentValue: domainReport.summary.complianceScore.value,
          status:
            domainReport.status === 'READY'
              ? 'PASSING'
              : domainReport.status === 'ERROR'
                ? 'FAILING'
                : 'NOT_APPLICABLE',
          securityIssueStats: domainReport.categories.map((category) => ({
            key: category.name,
            title: category.name,
            occurrence: {
              critical: category.severity === 'CRITICAL' ? category.nonCompliant.count : 0,
              major: category.severity === 'MAJOR' ? category.nonCompliant.count : 0,
              minor: category.severity === 'INFO' ? category.nonCompliant.count : 0,
              total: category.issueCount.count,
            },
          })),
          trends: domainReport.trend ? [domainReport.trend] : [],
          // Include helpful analysis of the report
          analysis: {
            summary: `This report shows compliance with ${domainReport.reportType} security standards.`,
            status_explanation:
              domainReport.status === 'READY'
                ? 'Your project is currently meeting all required security standards.'
                : domainReport.status === 'ERROR'
                  ? 'Your project has security issues that need to be addressed to meet compliance standards.'
                  : 'This report is not applicable to your project.',
            critical_issues: domainReport.summary.severityDistribution.critical.count,
            major_issues: domainReport.summary.severityDistribution.major.count,
            minor_issues: domainReport.summary.severityDistribution.info.count,
            total_issues: domainReport.summary.totalIssues.count,
          },
          // Include recommendations based on the report
          recommendations: {
            actions:
              domainReport.status === 'ERROR'
                ? [
                    'Fix critical security issues first',
                    'Use project_issues to view specific issues',
                    'Implement security best practices for your codebase',
                  ]
                : ['Continue monitoring security compliance', 'Run regular security scans'],
            resources: [
              reportType === ReportType.OWASP_TOP_10
                ? 'OWASP Top 10: https://owasp.org/www-project-top-ten/'
                : reportType === ReportType.SANS_TOP_25
                  ? 'SANS Top 25: https://www.sans.org/top25-software-errors/'
                  : reportType === ReportType.MISRA_C
                    ? 'MISRA-C: https://www.misra.org.uk/'
                    : 'Security best practices for your project',
            ],
          },
        };
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(reportData),
            },
          ],
        };
      } catch (error) {
        deps.logger.error('Error in handleComplianceReport', {
          errorType: typeof error,
          errorName: error instanceof Error ? error.name : 'Unknown',
          errorMessage: error instanceof Error ? error.message : String(error),
          errorStack: error instanceof Error ? error.stack : 'No stack available',
        });
    
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        deps.logger.debug('Returning error response', { errorMessage });
    
        return {
          isError: true,
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify({
                error: errorMessage,
                details: 'Failed to retrieve compliance report',
              }),
            },
          ],
        };
      }
    };
  • Top-level handler function called from registry; creates repository dependencies and delegates to the core domain handler.
    export async function handleDeepsourceComplianceReport(params: DeepsourceComplianceReportParams) {
      const baseDeps = createDefaultHandlerDeps({ logger });
      const apiKey = baseDeps.getApiKey();
      const repositoryFactory = new RepositoryFactory({ apiKey });
      const complianceReportRepository = repositoryFactory.createComplianceReportRepository();
    
      const deps: ComplianceReportHandlerDeps = {
        complianceReportRepository,
        logger,
      };
    
      const handler = createComplianceReportHandlerWithRepo(deps);
      const result = await handler(params);
    
      // If the domain handler returned an error response, throw an error for backward compatibility
      if (result.isError) {
        const firstContent = result.content[0];
        if (firstContent) {
          const errorData = JSON.parse(firstContent.text);
          throw new Error(errorData.error);
        } else {
          throw new Error('Unknown compliance report error');
        }
      }
    
      return result;
    }
  • Adapter function that converts raw MCP tool parameters to typed DeepsourceComplianceReportParams for the handler.
    export function adaptComplianceReportParams(params: unknown): DeepsourceComplianceReportParams {
      const typedParams = params as Record<string, unknown>;
      return {
        projectKey: typedParams.projectKey as string, // Handler still expects string
        reportType: typedParams.reportType as ReportType,
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It states 'Get' which implies a read operation, but doesn't mention authentication requirements, rate limits, error conditions, or what the output contains (though an output schema exists). For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any fluff. It's appropriately sized and front-loaded, with every word contributing to understanding what the tool does.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that there's an output schema (which handles return values) and 100% schema description coverage, the description is minimally adequate. However, with no annotations and multiple sibling tools, it lacks context about when this specific compliance report tool should be chosen over other project data tools.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with both parameters clearly documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema (e.g., it doesn't explain what 'OWASP_TOP_10' means or how 'projectKey' is formatted). This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get') and resource ('security compliance reports from a DeepSource project'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'quality_metrics' or 'project_issues' that might also retrieve project-related data, preventing a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'quality_metrics' and 'project_issues' available, there's no indication whether this is for compliance-specific reports versus general metrics or issues, leaving the agent to guess based on context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sapientpants/deepsource-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server