Update Note
update_noteEdit the body of an existing comment on a GitLab issue or merge request. Use this to update note content with new text or Markdown.
Instructions
Edit the body of an existing comment (note) on a GitLab issue or merge request. Requires a user token belonging to the note author.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| noteId | Yes | Note ID — either the bare numeric ID or the full GraphQL gid (gid://gitlab/Note/123) | |
| body | Yes | New note body (Markdown supported) | |
| userCredentials | No | Your GitLab credentials (optional — falls back to the configured env token if not provided) |
Implementation Reference
- src/tools.ts:1263-1270 (handler)Handler function for the update_note tool. Extracts user credentials, validates authentication, then calls client.updateNote() with the note ID and new body, returning the updated note.
handler: async (input, client, userConfig) => { const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig; if (!credentials) { throw new Error('User authentication is required for updating notes.'); } const result = await client.updateNote(input.noteId.trim(), input.body, credentials); return result.note; }, - src/tools.ts:1259-1262 (schema)Input schema for update_note: requires a noteId (string) and body (string), with userCredentials added via withUserAuth.
inputSchema: withUserAuth(z.object({ noteId: z.string().min(1).describe('Note ID — either the bare numeric ID or the full GraphQL gid (gid://gitlab/Note/123)'), body: z.string().min(1).describe('New note body (Markdown supported)'), })), - src/tools.ts:1251-1271 (registration)Full tool definition object for update_note including name, title, description, annotations, input schema, and handler.
const updateNoteTool: Tool = { name: 'update_note', title: 'Update Note', description: 'Edit the body of an existing comment (note) on a GitLab issue or merge request. Requires a user token belonging to the note author.', requiresAuth: true, requiresWrite: true, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, inputSchema: withUserAuth(z.object({ noteId: z.string().min(1).describe('Note ID — either the bare numeric ID or the full GraphQL gid (gid://gitlab/Note/123)'), body: z.string().min(1).describe('New note body (Markdown supported)'), })), handler: async (input, client, userConfig) => { const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig; if (!credentials) { throw new Error('User authentication is required for updating notes.'); } const result = await client.updateNote(input.noteId.trim(), input.body, credentials); return result.note; }, }; - src/gitlab-client.ts:2094-2115 (helper)GitLabGraphQLClient.updateNote() — helper that constructs and executes the GraphQL updateNote mutation, converting a bare numeric ID to a full gid as needed.
async updateNote( noteId: string, body: string, userConfig?: UserConfig ): Promise<{ note: { id: string; body: string; updatedAt: string }; errors: string[] }> { const gid = noteId.startsWith('gid://') ? noteId : `gid://gitlab/Note/${noteId}`; const mutation = ` mutation UpdateNote($input: UpdateNoteInput!) { updateNote(input: $input) { note { id body updatedAt } errors } } `; const result = await this.query<{ updateNote: { note: { id: string; body: string; updatedAt: string }; errors: string[] }; }>(mutation, { input: { id: gid, body } }, userConfig, true); if (result.updateNote.errors.length > 0) { throw new Error(`updateNote failed: ${result.updateNote.errors.join('; ')}`); } return result.updateNote; }