Skip to main content
Glama
Dsazz

JIRA MCP Server

jira_delete_worklog

Remove a worklog entry from a JIRA issue to correct time tracking errors or delete incorrect entries.

Instructions

Delete a worklog entry from an issue

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueKeyYes
worklogIdYes

Implementation Reference

  • DeleteWorklogHandler class: core implementation of the jira_delete_worklog tool handler, including validation, use case execution, and enhanced error handling.
    export class DeleteWorklogHandler extends BaseToolHandler<
      DeleteWorklogParams,
      string
    > {
      /**
       * Create a new DeleteWorklogHandler with use case and validator
       *
       * @param deleteWorklogUseCase - Use case for deleting worklog entries
       * @param worklogValidator - Validator for worklog parameters
       */
      constructor(
        private readonly deleteWorklogUseCase: DeleteWorklogUseCase,
        private readonly worklogValidator: WorklogValidator,
      ) {
        super("JIRA", "Delete Worklog");
      }
    
      /**
       * Execute the handler logic
       * Deletes a worklog entry and returns a success message
       *
       * @param params - Parameters for worklog deletion
       */
      protected async execute(params: DeleteWorklogParams): Promise<string> {
        try {
          // Step 1: Validate parameters
          const validatedParams =
            this.worklogValidator.validateDeleteWorklogParams(params);
          this.logger.info(
            `Deleting worklog ${validatedParams.worklogId} from issue: ${validatedParams.issueKey}`,
          );
    
          // Step 2: Delete worklog using use case
          const response = await this.deleteWorklogUseCase.execute({
            issueKey: validatedParams.issueKey,
            worklogId: validatedParams.worklogId,
          });
    
          // Step 3: Return success message
          return `✅ **Worklog Deleted Successfully**\n\n${response.message}`;
        } catch (error) {
          this.logger.error(`Failed to delete worklog: ${error}`);
          throw this.enhanceError(error, params);
        }
      }
    
      /**
       * Enhance error messages for better user guidance
       */
      private enhanceError(error: unknown, params?: DeleteWorklogParams): Error {
        const issueContext = params?.issueKey
          ? ` for issue ${params.issueKey}`
          : "";
        const worklogContext = params?.worklogId
          ? ` (worklog ${params.worklogId})`
          : "";
    
        if (error instanceof JiraNotFoundError) {
          return new Error(
            `❌ **Issue or Worklog Not Found**\n\nNo issue or worklog found${issueContext}${worklogContext}.\n\n**Solutions:**\n- Verify the issue key is correct\n- Verify the worklog ID exists\n- Check if you have permission to view the issue\n\n**Example:** \`jira_delete_worklog issueKey="PROJ-123" worklogId="12345"\``,
          );
        }
    
        if (error instanceof JiraPermissionError) {
          return new Error(
            `❌ **Permission Denied**\n\nYou don't have permission to delete worklog entries${issueContext}.\n\n**Solutions:**\n- Check your JIRA permissions\n- Contact your JIRA administrator\n- Verify you have work on issues permission\n- Ensure you can delete this specific worklog\n\n**Required Permissions:** Work on Issues`,
          );
        }
    
        if (error instanceof JiraApiError) {
          return new Error(
            `❌ **JIRA API Error**\n\n${error.message}\n\n**Solutions:**\n- Check the issue key is valid (format: PROJ-123)\n- Verify the worklog ID exists\n- Verify your JIRA connection\n\n**Example:** \`jira_delete_worklog issueKey="PROJ-123" worklogId="12345"\``,
          );
        }
    
        if (error instanceof Error) {
          return new Error(
            `❌ **Worklog Deletion Failed**\n\n${error.message}${issueContext}${worklogContext}\n\n**Solutions:**\n- Check your parameters are valid\n- Verify your JIRA connection\n- Verify the worklog ID exists\n\n**Example:** \`jira_delete_worklog issueKey="PROJ-123" worklogId="12345"\``,
          );
        }
    
        return new Error(
          `❌ **Unknown Error**\n\nAn unknown error occurred during worklog deletion${issueContext}${worklogContext}.\n\nPlease check your parameters and try again.`,
        );
      }
    }
  • Zod schema defining input parameters for jira_delete_worklog: issueKey and worklogId.
    export const deleteWorklogParamsSchema = z.object({
      issueKey: issueKeySchema,
      worklogId: z.string().min(1, "Worklog ID is required"),
    });
    
    /**
     * Type for delete worklog parameters
     */
    export type DeleteWorklogParams = z.infer<typeof deleteWorklogParamsSchema>;
  • ToolConfig object for jira_delete_worklog in worklog-tools.config.ts, defining name, description, params schema, and handler binding.
    {
      name: "jira_delete_worklog",
      description: "Delete a worklog entry from an issue",
      params: deleteWorklogParamsSchema.shape,
      handler: tools.jira_delete_worklog.handle.bind(tools.jira_delete_worklog),
    },
  • Creation of the jira_delete_worklog tool handler object in tool.factory.ts, wrapping DeleteWorklogHandler.handle.
    jira_delete_worklog: {
      handle: async (args: unknown) => deleteWorklogHandler.handle(args),
    },
  • Inclusion of jira_delete_worklog in worklogs tool group configuration for MCP server registration.
    groupName: "worklogs",
    configs: createWorklogToolsConfig({
      jira_add_worklog: tools.jira_add_worklog,
      jira_get_worklogs: tools.jira_get_worklogs,
      jira_update_worklog: tools.jira_update_worklog,
      jira_delete_worklog: tools.jira_delete_worklog,
    }),

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/Dsazz/mcp-jira'

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