kibela_update_note_content
Update an existing Kibela note's content using its note ID. Fetches current content for version control and replaces it entirely with new markdown content.
Instructions
Update note content by note id. This tool allows you to modify the content of an existing Kibela note. Before updating, it fetches the current content of the note to ensure proper version control. Note that you need the note ID (not the note path) to use this tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Note id - not note path (e.g. /notes/123). If you want to update note content by note path, please use kibela_get_note_from_path tool first and get note id from the response | |
| content | Yes | New content of the note in markdown format. The content will completely replace the existing note content. Make sure to include all necessary formatting, headers, and sections you want to preserve. |
Implementation Reference
- src/tools/updateNoteContent.ts:33-61 (handler)The handler function that executes the tool logic: validates id and content, fetches the current note via getNote to obtain baseContent for version control, then calls updateNoteContent mutation with clientMutationId, id, newContent, and baseContent. Returns the mutation response as JSON.
handler: async ({ id, content }) => { if (!id || !content) { throw new Error('Note id and content are required') } const noteRes = await getNote({ id }) if (!noteRes.note) { throw new Error('Note not found') } const response = await updateNoteContent({ input: { clientMutationId: uuid(), id, newContent: content, baseContent: noteRes.note.content, }, }) return { content: [ { type: 'text', text: JSON.stringify(response.updateNoteContent, null, 2), }, ], } }, } - src/tools/updateNoteContent.ts:6-31 (schema)Type definition (UpdateNoteContentArgs) and inputSchema for the tool: requires 'id' (string, the note ID) and 'content' (string, the new markdown content). The inputSchema is the JSON Schema used for validation.
export type UpdateNoteContentArgs = { id: string content: string } export const updateNoteContentTool: ToolDefinition<UpdateNoteContentArgs> = { tool: { name: 'kibela_update_note_content', description: 'Update note content by note id. This tool allows you to modify the content of an existing Kibela note. Before updating, it fetches the current content of the note to ensure proper version control. Note that you need the note ID (not the note path) to use this tool.', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Note id - not note path (e.g. /notes/123). If you want to update note content by note path, please use kibela_get_note_from_path tool first and get note id from the response', }, content: { type: 'string', description: 'New content of the note in markdown format. The content will completely replace the existing note content. Make sure to include all necessary formatting, headers, and sections you want to preserve.', }, }, required: ['id', 'content'], }, - src/tools/index.ts:14-16 (registration)The tool is registered in the toolDefinitions map under the key 'kibela_update_note_content', mapping to updateNoteContentTool which is imported from './updateNoteContent'.
kibela_update_note_content: updateNoteContentTool, kibela_create_note: createNoteTool, } as const - The GraphQL mutation helper that sends the 'UpdateNoteContent' mutation to the Kibela API. Accepts variables: clientMutationId, id, newContent, and baseContent (for optimistic locking/version control).
import { TypedDocumentNode } from '@graphql-typed-document-node/core' import { gql } from 'graphql-tag' import { gqlRequest } from '../request' type UpdateNoteContentResponse = { updateNoteContent: { clientMutationId: string note: { id: string } } } type UpdateNoteContentVariables = { input: { clientMutationId: string id: string newContent: string baseContent: string } } const updateNoteContentMutation: TypedDocumentNode<UpdateNoteContentResponse, UpdateNoteContentVariables> = gql` mutation UpdateNoteContent($input: UpdateNoteContentInput!) { updateNoteContent(input: $input) { clientMutationId note { id } } } ` export async function updateNoteContent(variables: UpdateNoteContentVariables): Promise<UpdateNoteContentResponse> { return gqlRequest(updateNoteContentMutation, variables) } - src/graphql/queries/getNote.ts:1-29 (helper)The GraphQL query helper that fetches a note by ID (including content field), used by the handler to get the current baseContent before updating.
import { TypedDocumentNode } from '@graphql-typed-document-node/core' import { gql } from 'graphql-tag' import { gqlRequest } from '../request' type GetNoteResponse = { note: { id: string title: string content: string } } type GetNoteVariables = { id: string } const getNoteQuery: TypedDocumentNode<GetNoteResponse, GetNoteVariables> = gql` query GetNote($id: ID!) { note(id: $id) { id title content } } ` export async function getNote(variables: GetNoteVariables): Promise<GetNoteResponse> { return gqlRequest(getNoteQuery, variables) }