Skip to main content
Glama

update_metric_threshold

Adjust quality metric thresholds in DeepSource projects to control when issues are flagged, enabling teams to customize code quality standards based on their requirements.

Instructions

Update the threshold for a specific quality metric

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectKeyYesDeepSource project key to identify the project
repositoryIdYesRepository GraphQL ID
metricShortcodeYesCode for the metric to update
metricKeyYesContext key for the metric
thresholdValueNoNew threshold value, or null to remove

Implementation Reference

  • Core implementation of the update_metric_threshold tool handler. Creates DeepSourceClient and calls setMetricThreshold mutation.
    export const createUpdateMetricThresholdHandler: HandlerFactory< BaseHandlerDeps, DeepsourceUpdateMetricThresholdParams > = createBaseHandlerFactory( 'update_metric_threshold', async (deps, { projectKey, repositoryId, metricShortcode, metricKey, thresholdValue }) => { 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 threshold', { projectKey, repositoryId, metricShortcode, metricKey, thresholdValue, }); const result = await client.setMetricThreshold({ repositoryId, metricShortcode, metricKey, thresholdValue: thresholdValue ?? null, }); deps.logger.info('Metric threshold update result', { success: result.ok, projectKey, metricShortcode, metricKey, }); const updateResult = { ok: result.ok, projectKey, // Echo back the project key for context metricShortcode, metricKey, thresholdValue, message: result.ok ? `Successfully ${thresholdValue !== null && thresholdValue !== undefined ? 'updated' : 'removed'} threshold for ${metricShortcode} (${metricKey})` : `Failed to update threshold for ${metricShortcode} (${metricKey})`, 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 wrapper function for the update_metric_threshold handler that creates dependencies and invokes the core handler.
    export async function handleDeepsourceUpdateMetricThreshold( params: DeepsourceUpdateMetricThresholdParams ) { const deps = createDefaultHandlerDeps({ logger }); const handler = createUpdateMetricThresholdHandler(deps); return handler(params); }
  • Zod schema definition for the update_metric_threshold tool, defining input and output validation.
    export const updateMetricThresholdToolSchema = { name: 'update_metric_threshold', description: 'Update the threshold for a specific quality metric', inputSchema: { projectKey: z.string().describe('DeepSource project key to identify the project'), repositoryId: z.string().describe('Repository GraphQL ID'), metricShortcode: z.nativeEnum(MetricShortcode).describe('Code for the metric to update'), metricKey: z.string().describe('Context key for the metric'), thresholdValue: z .number() .nullable() .optional() .describe('New threshold value, or null to remove'), }, outputSchema: { ok: z.boolean(), projectKey: z.string(), metricShortcode: z.string(), metricKey: z.string(), thresholdValue: z.number().nullable().optional(), message: z.string(), next_steps: z.array(z.string()), }, };
  • Registration of the update_metric_threshold tool in the legacy index-registry, using the schema and adapted handler.
    toolRegistry.registerTool({ ...updateMetricThresholdToolSchema, handler: async (params) => { const adaptedParams = adaptUpdateMetricThresholdParams(params); return handleDeepsourceUpdateMetricThreshold(adaptedParams); }, });
  • Adapter function to convert raw MCP params to typed DeepsourceUpdateMetricThresholdParams for the handler.
    export function adaptUpdateMetricThresholdParams( params: unknown ): DeepsourceUpdateMetricThresholdParams { const typedParams = params as Record<string, unknown>; const result: DeepsourceUpdateMetricThresholdParams = { projectKey: typedParams.projectKey as string, // Handler still expects string repositoryId: typedParams.repositoryId as string, // Handler still expects string metricShortcode: typedParams.metricShortcode as MetricShortcode, metricKey: typedParams.metricKey as MetricKey, }; const thresholdValue = typedParams.thresholdValue as number | null | undefined; if (thresholdValue !== undefined) { result.thresholdValue = thresholdValue; } return result; }

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