affine_list_histories
Retrieve document history timestamps for a specific document in AFFiNE workspaces, enabling version tracking and audit trail management.
Instructions
List doc histories (timestamps) for a doc.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| before | No | ||
| guid | Yes | ||
| take | No | ||
| workspaceId | No |
Implementation Reference
- src/tools/history.ts:7-13 (handler)The handler function that executes the tool logic: queries the GraphQL API for document histories in a workspace, given guid, optional take and before parameters.const listHistoriesHandler = async (parsed: { workspaceId?: string; guid: string; take?: number; before?: string }) => { const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId; if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)"); const query = `query Histories($workspaceId:String!,$guid:String!,$take:Int,$before:DateTime){ workspace(id:$workspaceId){ histories(guid:$guid, take:$take, before:$before){ id timestamp workspaceId } } }`; const data = await gql.request<{ workspace: any }>(query, { workspaceId, guid: parsed.guid, take: parsed.take, before: parsed.before }); return text(data.workspace.histories); };
- src/tools/history.ts:14-27 (registration)Registers the 'affine_list_histories' tool with the MCP server, providing title, description, input schema, and linking to the handler function.server.registerTool( "affine_list_histories", { title: "List Histories", description: "List doc histories (timestamps) for a doc.", inputSchema: { workspaceId: z.string().optional(), guid: z.string(), take: z.number().optional(), before: z.string().optional() } }, listHistoriesHandler as any );
- src/tools/history.ts:19-24 (schema)Zod-based input schema defining parameters for the tool: optional workspaceId, required guid, optional take and before.inputSchema: { workspaceId: z.string().optional(), guid: z.string(), take: z.number().optional(), before: z.string().optional() }
- src/index.ts:68-68 (registration)Top-level call to registerHistoryTools, which in turn registers the 'affine_list_histories' tool among others.registerHistoryTools(server, gql, { workspaceId: config.defaultWorkspaceId });