Skip to content

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search

feat(mcp): add update-bookmark tool (#2717)

Vladimir Balkoc699bc90a441
diff --git a/apps/mcp/src/bookmarks.ts b/apps/mcp/src/bookmarks.ts
index 0968207f..15e4cf0e 100644
--- a/apps/mcp/src/bookmarks.ts
+++ b/apps/mcp/src/bookmarks.ts
@@ -142,6 +142,88 @@ mcpServer.tool(
},
);
+mcpServer.tool(
+ "update-bookmark",
+ `Update fields on an existing bookmark. Only the fields you pass are modified; omitted fields stay unchanged. Returns the updated bookmark.`,
+ {
+ bookmarkId: z.string().describe(`The bookmarkId to update.`),
+ title: z
+ .string()
+ .nullable()
+ .optional()
+ .describe(`The bookmark's user-set title. Pass null to clear it.`),
+ note: z.string().optional().describe(`A free-form note on the bookmark.`),
+ summary: z
+ .string()
+ .nullable()
+ .optional()
+ .describe(`The bookmark's summary. Pass null to clear it.`),
+ archived: z
+ .boolean()
+ .optional()
+ .describe(`Whether the bookmark is archived.`),
+ favourited: z
+ .boolean()
+ .optional()
+ .describe(`Whether the bookmark is favourited.`),
+ url: z.string().url().optional().describe(`New URL for a link bookmark.`),
+ description: z
+ .string()
+ .nullable()
+ .optional()
+ .describe(`Link description. Pass null to clear it.`),
+ author: z
+ .string()
+ .nullable()
+ .optional()
+ .describe(`Link author. Pass null to clear it.`),
+ publisher: z
+ .string()
+ .nullable()
+ .optional()
+ .describe(`Link publisher. Pass null to clear it.`),
+ createdAt: z
+ .string()
+ .datetime()
+ .optional()
+ .describe(`Override the bookmark's createdAt timestamp (ISO 8601).`),
+ },
+ async ({ bookmarkId, ...fields }): Promise<CallToolResult> => {
+ const patchRes = await karakeepClient.PATCH(`/bookmarks/{bookmarkId}`, {
+ params: {
+ path: {
+ bookmarkId,
+ },
+ },
+ body: fields,
+ });
+ if (!patchRes.data) {
+ return toMcpToolError(patchRes.error);
+ }
+ const getRes = await karakeepClient.GET(`/bookmarks/{bookmarkId}`, {
+ params: {
+ path: {
+ bookmarkId,
+ },
+ query: {
+ includeContent: false,
+ },
+ },
+ });
+ if (!getRes.data) {
+ return toMcpToolError(getRes.error);
+ }
+ return {
+ content: [
+ {
+ type: "text",
+ text: compactBookmark(getRes.data),
+ },
+ ],
+ };
+ },
+);
+
mcpServer.tool(
"get-bookmark-content",
`Get the content of the bookmark in markdown`,