AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
feat: expose notebook rename via MCP
tianma-if639e7e6335bd
diff --git a/apps/api/src/index.ts b/apps/api/src/index.tsindex 2bfc7083..bcdb3345 100644--- a/apps/api/src/index.ts+++ b/apps/api/src/index.ts@@ -963,6 +963,24 @@ const callMcpTool = async (return { notebook };}+ case "rename_notebook": {+ assertScope(auth, "write:notebooks");+ const name = getRequiredString(args.name, "name");++ if (name.length > 80) {+ throw new AppError("invalid_params", "name must be at most 80 characters", 400);+ }++ const notebook = await updateNotebookRecord(+ c.env.storage.db,+ auth.workspaceId,+ getRequiredString(args.notebookId, "notebookId"),+ { name },+ getAuditActor(c)+ );++ return { notebook };+ }case "get_notebook": {assertScope(auth, "read:notebooks");const notebook = await getNotebook(c.env.storage.db, auth.workspaceId, getRequiredString(args.notebookId, "notebookId"));diff --git a/apps/api/src/mcp-tools.test.mjs b/apps/api/src/mcp-tools.test.mjsindex f11a359b..56c8817e 100644--- a/apps/api/src/mcp-tools.test.mjs+++ b/apps/api/src/mcp-tools.test.mjs@@ -32,5 +32,16 @@ describe("MCP tool catalog", () => {destructiveHint: false,idempotentHint: true,});+ expect(byName.get("rename_notebook")?.annotations).toMatchObject({+ readOnlyHint: false,+ destructiveHint: false,+ idempotentHint: true,+ });+ expect(byName.get("rename_notebook")?.inputSchema).toMatchObject({+ required: ["notebookId", "name"],+ properties: {+ name: { type: "string", minLength: 1, maxLength: 80 },+ },+ });});});diff --git a/apps/api/src/mcp-tools.ts b/apps/api/src/mcp-tools.tsindex c43c9b15..6e9cfb49 100644--- a/apps/api/src/mcp-tools.ts+++ b/apps/api/src/mcp-tools.ts@@ -358,6 +358,19 @@ const MCP_TOOL_DEFINITIONS = [},},},+ {+ name: "rename_notebook",+ description: "Rename an active notebook in the authenticated user's workspace.",+ inputSchema: {+ type: "object",+ required: ["notebookId", "name"],+ additionalProperties: false,+ properties: {+ notebookId: { type: "string", description: "The exact EdgeEver notebook ID." },+ name: { type: "string", minLength: 1, maxLength: 80 },+ },+ },+ },{name: "get_notebook",description: "Get one active notebook by ID from the authenticated user's workspace.",@@ -456,6 +469,7 @@ const NON_DESTRUCTIVE_MCP_TOOLS = new Set(["upload_memo_attachment","move_notebook","create_notebook",+ "rename_notebook",]);const IDEMPOTENT_MCP_TOOLS = new Set(["restore_memos",@@ -464,6 +478,7 @@ const IDEMPOTENT_MCP_TOOLS = new Set(["remove_tags_from_memos","import_memos","move_notebook",+ "rename_notebook",]);export const MCP_TOOLS = MCP_TOOL_DEFINITIONS.map((tool) => {diff --git a/scripts/test-mcp.mjs b/scripts/test-mcp.mjsindex addeb075..bb08a7e1 100644--- a/scripts/test-mcp.mjs+++ b/scripts/test-mcp.mjs@@ -90,7 +90,7 @@ sqlite.run("MCP regression",tokenHash,token,- JSON.stringify(["read:notebooks", "read:memos", "write:memos", "read:resources", "read:tags"]),+ JSON.stringify(["read:notebooks", "write:notebooks", "read:memos", "write:memos", "read:resources", "read:tags"]),],);@@ -155,6 +155,9 @@ assert.equal(tools.get("trash_memos").annotations.destructiveHint, true);assert.equal(tools.get("create_memo").annotations.destructiveHint, false);assert.equal(tools.get("import_memos").annotations.idempotentHint, true);assert.equal(tools.get("import_memos").annotations.destructiveHint, false);+assert.equal(tools.get("rename_notebook").annotations.readOnlyHint, false);+assert.equal(tools.get("rename_notebook").annotations.destructiveHint, false);+assert.equal(tools.get("rename_notebook").annotations.idempotentHint, true);body = await callTool(4, "get_current_user");assert.equal(body.result.structuredContent.user.username, "zack42");@@ -181,6 +184,15 @@ assert.equal(body.result.structuredContent.error.code, "not_found");body = await callTool(10, "list_notebooks");assert.ok(!body.result.structuredContent.notebooks.some((notebook) => notebook.id === "nb_other"));+body = await callTool(101, "rename_notebook", { notebookId: "nb_flomo", name: "Flomo Archive" });+assert.equal(body.result.isError, false);+assert.equal(body.result.structuredContent.notebook.name, "Flomo Archive");+assert.equal(sqlite.query("SELECT name FROM notebooks WHERE id = ?").get("nb_flomo").name, "Flomo Archive");++body = await callTool(102, "rename_notebook", { notebookId: "nb_other", name: "Leaked" });+assert.equal(body.result.isError, true);+assert.equal(body.result.structuredContent.error.code, "not_found");+body = await callTool(11, "import_memos", {source: "Flomo",notebookId: "nb_flomo",@@ -259,4 +271,4 @@ assert.equal(response.status, 202);response = await fetchMcp(null, { method: "GET" });assert.equal(response.status, 405);-console.log("MCP protocol, identity, notebook lookup, and idempotent import regression passed");+console.log("MCP protocol, identity, notebook lookup and rename, and idempotent import regression passed");