update_pull_request_comment
Update an existing comment on a Backlog pull request by specifying the comment ID and new content.
Instructions
Updates a comment on a pull request
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The numeric ID of the project (e.g., 12345) | |
| projectKey | No | The key of the project (e.g., 'PROJECT') | |
| repoId | No | Repository ID | |
| repoName | No | Repository name | |
| number | Yes | Pull request number | |
| commentId | Yes | Comment ID | |
| content | Yes | Comment content | |
| organization | No | Optional organization name. Use list_organizations to inspect available organizations. |
Implementation Reference
- The handler function that executes the 'update_pull_request_comment' tool logic. It resolves project ID/key and repo ID/name, then calls backlog.patchPullRequestComments() to update a pull request comment.
handler: async ({ projectId, projectKey, repoId, repoName, number, commentId, content, }) => { const result = resolveIdOrKey( 'project', { id: projectId, key: projectKey }, t ); if (!result.ok) { throw result.error; } const repoResult = resolveIdOrName( 'repository', { id: repoId, name: repoName }, t ); if (!repoResult.ok) { throw repoResult.error; } return backlog.patchPullRequestComments( result.value, String(repoResult.value), number, commentId, { content } ); }, - Input schema definition for update_pull_request_comment using Zod. Defines fields: projectId, projectKey, repoId, repoName, number, commentId, content.
const updatePullRequestCommentSchema = buildToolSchema((t) => ({ projectId: z .number() .optional() .describe( t( 'TOOL_UPDATE_PULL_REQUEST_COMMENT_PROJECT_ID', 'The numeric ID of the project (e.g., 12345)' ) ), projectKey: z .string() .optional() .describe( t( 'TOOL_UPDATE_PULL_REQUEST_COMMENT_PROJECT_KEY', "The key of the project (e.g., 'PROJECT')" ) ), repoId: z .number() .optional() .describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_REPO_ID', 'Repository ID')), repoName: z .string() .optional() .describe( t('TOOL_UPDATE_PULL_REQUEST_COMMENT_REPO_NAME', 'Repository name') ), number: z .number() .describe( t('TOOL_UPDATE_PULL_REQUEST_COMMENT_NUMBER', 'Pull request number') ), commentId: z .number() .describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_COMMENT_ID', 'Comment ID')), content: z .string() .describe(t('TOOL_UPDATE_PULL_REQUEST_COMMENT_CONTENT', 'Comment content')), })); - PullRequestCommentSchema - the output schema used as the return type for the update_pull_request_comment tool.
export const PullRequestCommentSchema = z.object({ id: z.number(), content: z.string(), changeLog: z.array(PullRequestChangeLogSchema), createdUser: UserSchema, created: z.string(), updated: z.string(), stars: z.array(StarSchema), notifications: z.array(CommentNotificationSchema), }); - src/tools/tools.ts:151-151 (registration)Registration of updatePullRequestCommentTool in the 'git' toolset group within the tools.ts registry.
updatePullRequestCommentTool(backlog, helper), - src/utils/resolveIdOrKey.ts:1-65 (helper)Helper utilities resolveIdOrKey and resolveIdOrName used by the handler to resolve project/repository identifiers.
import { TranslationHelper } from '../createTranslationHelper.js'; export type EntityName = 'issue' | 'project' | 'repository'; type ResolveResult = | { ok: true; value: string | number } | { ok: false; error: Error }; type ResolveIdOrFieldInput<F extends string> = { id?: number; } & { [K in F]?: string; }; /** * Generic resolver for entity identification by ID or named field (e.g., key, name, slug). * @param entity - The entity name, e.g., "project" * @param fieldName - The name of the alternative to `id`, e.g., "key", "name", "slug" * @param values - An object with `id?: number` and `[fieldName]?: string` * @param t - Translator */ function resolveIdOrField<E extends EntityName, F extends string>( entity: E, fieldName: F, values: ResolveIdOrFieldInput<F>, t: TranslationHelper['t'] ): ResolveResult { const value = tryResolveIdOrField(fieldName, values); if (value === undefined) { return { ok: false, error: new Error( t( `${entity.toUpperCase()}_ID_OR_${fieldName.toUpperCase()}_REQUIRED`, `${capitalize(entity)} ID or ${fieldName} is required` ) ), }; } return { ok: true, value }; } function tryResolveIdOrField<F extends string>( fieldName: F, values: ResolveIdOrFieldInput<F> ): string | number | undefined { return values.id !== undefined ? values.id : values[fieldName]; } export const resolveIdOrKey = <E extends EntityName>( entity: E, values: { id?: number; key?: string }, t: TranslationHelper['t'] ): ResolveResult => resolveIdOrField(entity, 'key', values, t); export const resolveIdOrName = <E extends EntityName>( entity: E, values: { id?: number; name?: string }, t: TranslationHelper['t'] ): ResolveResult => resolveIdOrField(entity, 'name', values, t); function capitalize(str: string): string { return str.charAt(0).toUpperCase() + str.slice(1); }