Skip to main content
Glama

update_metric_setting

Modify quality metric reporting and threshold enforcement settings for DeepSource projects to customize code analysis.

Instructions

Update the settings for a quality metric

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectKeyYesDeepSource project key to identify the project
repositoryIdYesRepository GraphQL ID
metricShortcodeYesCode for the metric to update
isReportedYesWhether the metric should be reported
isThresholdEnforcedYesWhether the threshold should be enforced

Implementation Reference

  • Core handler factory for update_metric_setting tool. Creates DeepSourceClient, calls client.updateMetricSetting to perform the update, logs activity, formats response with success status, message, and next steps.
    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); }
  • Tool handler registration in TOOL_HANDLERS object, performs type casting on input params and calls the main handler function.
    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, }); },
  • Zod schema definition for the update_metric_setting tool, including input parameters (projectKey, repositoryId, metricShortcode, isReported, isThresholdEnforced) and output structure.
    export const updateMetricSettingToolSchema = { name: 'update_metric_setting', description: 'Update the settings for a 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'), isReported: z.boolean().describe('Whether the metric should be reported'), isThresholdEnforced: z.boolean().describe('Whether the threshold should be enforced'), }, outputSchema: { ok: z.boolean(), projectKey: z.string(), metricShortcode: z.string(), settings: z.object({ isReported: z.boolean(), isThresholdEnforced: z.boolean(), }), message: z.string(), next_steps: z.array(z.string()), }, };
  • MetricsClient method that executes the GraphQL mutation to update metric settings via DeepSource API.
    async updateMetricSetting( params: UpdateMetricSettingParams ): Promise<MetricSettingUpdateResponse> { try { this.logger.info('Updating metric setting', { repositoryId: params.repositoryId, metricShortcode: params.metricShortcode, }); const mutation = MetricsClient.buildUpdateSettingMutation(); const response = await this.executeGraphQL(mutation, { ...params }); if (!response.data) { throw new Error('No data received from GraphQL API'); } this.logger.info('Successfully updated metric setting'); return { ok: true }; } catch (error) { this.logger.error('Error updating metric setting', { error }); throw error; } }

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