Skip to main content
Glama

deepsource_update_metric_setting

Configure reporting and enforcement of quality metrics in DeepSource projects. Enable or disable metric display in the UI/API and set thresholds to fail checks when unmet.

Instructions

Update the settings for a quality metric in a DeepSource project.

This allows configuring how metrics are used in the project:

  • Enable/disable reporting the metric in the UI and API

  • Enable/disable enforcing thresholds (failing checks when thresholds aren't met)

Example:

  • Enable reporting and enforce thresholds: isReported=true, isThresholdEnforced=true

  • Only report but don't enforce: isReported=true, isThresholdEnforced=false

  • Disable completely: isReported=false, isThresholdEnforced=false

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
isReportedYesWhether the metric should be reported
isThresholdEnforcedYesWhether the threshold should be enforced (can fail checks)
metricShortcodeYesThe shortcode of the metric to update
projectKeyYesThe unique identifier for the DeepSource project
repositoryIdYesThe GraphQL repository ID (get this from deepsource_quality_metrics response)

Implementation Reference

  • Core handler factory implementing the tool logic: adapts parameters, calls DeepSourceClient.updateMetricSetting API, logs, and returns formatted response.
    export const createUpdateMetricSettingHandler: HandlerFactory< BaseHandlerDeps, DeepsourceUpdateMetricSettingParams > = createBaseHandlerFactory( 'update_metric_setting', async (deps, { projectKey, repositoryId, metricShortcode, isReported, isThresholdEnforced }) => { const apiKey = deps.getApiKey(); deps.logger.debug('API key retrieved from config', { length: apiKey.length, prefix: `${apiKey.substring(0, 5)}...`, }); const client = new DeepSourceClient(apiKey); deps.logger.info('Updating metric setting', { projectKey, repositoryId, metricShortcode, isReported, isThresholdEnforced, }); const result = await client.updateMetricSetting({ repositoryId, metricShortcode, isReported, isThresholdEnforced, }); deps.logger.info('Metric setting update result', { success: result.ok, projectKey, metricShortcode, }); const updateResult = { ok: result.ok, projectKey, // Echo back the project key for context metricShortcode, settings: { isReported, isThresholdEnforced, }, message: result.ok ? `Successfully updated settings for ${metricShortcode}` : `Failed to update settings for ${metricShortcode}`, next_steps: result.ok ? ['Use quality_metrics to view the updated metrics'] : ['Check if you have sufficient permissions', 'Verify the repository ID is correct'], }; return wrapInApiResponse(updateResult); } );
  • Exported handler function that creates dependencies and invokes the update metric setting handler factory.
    export async function handleDeepsourceUpdateMetricSetting( params: DeepsourceUpdateMetricSettingParams ) { const deps = createDefaultHandlerDeps({ logger }); const handler = createUpdateMetricSettingHandler(deps); return handler(params); }
  • TypeScript interface defining input parameters for the tool handler.
    export interface DeepsourceUpdateMetricSettingParams { /** DeepSource project key to identify the project */ projectKey: string; /** Repository GraphQL ID */ repositoryId: string; /** Code for the metric to update */ metricShortcode: MetricShortcode; /** Whether the metric should be reported */ isReported: boolean; /** Whether the threshold should be enforced */ isThresholdEnforced: boolean; }
  • Registers the tool handler in TOOL_HANDLERS for 'update_metric_setting', adapting params and calling handleDeepsourceUpdateMetricSetting.
    update_metric_setting: async (params: unknown) => { const typedParams = params as Record<string, unknown>; return handleDeepsourceUpdateMetricSetting({ projectKey: typedParams.projectKey as string, repositoryId: typedParams.repositoryId as string, metricShortcode: typedParams.metricShortcode as MetricShortcode, isReported: typedParams.isReported as boolean, isThresholdEnforced: typedParams.isThresholdEnforced as boolean, }); },
  • Registers the tool using updateMetricSettingToolSchema with adapted handler calling the main handler function.
    toolRegistry.registerTool({ ...updateMetricSettingToolSchema, handler: async (params) => { const adaptedParams = adaptUpdateMetricSettingParams(params); return handleDeepsourceUpdateMetricSetting(adaptedParams); }, });
  • Adapter function to convert raw MCP params to typed DeepsourceUpdateMetricSettingParams for the handler.
    export function adaptUpdateMetricSettingParams( params: unknown ): DeepsourceUpdateMetricSettingParams { const typedParams = params as Record<string, unknown>; return { projectKey: typedParams.projectKey as string, // Handler still expects string repositoryId: typedParams.repositoryId as string, // Handler still expects string metricShortcode: typedParams.metricShortcode as MetricShortcode, isReported: typedParams.isReported as boolean, isThresholdEnforced: typedParams.isThresholdEnforced as boolean, }; }

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