Skip to main content
Glama

Recover Document

affine_recover_doc

Restore a document to a specific previous version using its timestamp and unique identifier within an AFFiNE workspace, ensuring precise recovery of content.

Instructions

Recover a doc to a previous timestamp.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
guidYes
timestampYes
workspaceIdNo

Implementation Reference

  • The async handler function that executes the tool logic: performs a GraphQL mutation to recover the document at a specific timestamp.
    const recoverDocHandler = async (parsed: { workspaceId?: string; guid: string; timestamp: string }) => {
      const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId;
      if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)");
      const mutation = `mutation Recover($workspaceId:String!,$guid:String!,$timestamp:DateTime!){ recoverDoc(workspaceId:$workspaceId, guid:$guid, timestamp:$timestamp) }`;
      const data = await gql.request<{ recoverDoc: string }>(mutation, { workspaceId, guid: parsed.guid, timestamp: parsed.timestamp });
      return text({ recoveredAt: data.recoverDoc });
    };
  • Registration of the 'affine_recover_doc' tool, specifying title, description, input schema using Zod, and linking to the recoverDocHandler.
    server.registerTool(
      "affine_recover_doc",
      {
        title: "Recover Document",
        description: "Recover a doc to a previous timestamp.",
        inputSchema: {
          workspaceId: z.string().optional(),
          guid: z.string(),
          timestamp: z.string()
        }
      },
      recoverDocHandler as any
    );
  • Input schema definition for the tool using Zod validators.
      workspaceId: z.string().optional(),
      guid: z.string(),
      timestamp: z.string()
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool performs a recovery operation, implying mutation (likely destructive to current state), but doesn't disclose behavioral traits such as permissions required, whether it's reversible, rate limits, or what happens to the current doc version. This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action. There's no wasted words or redundancy, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a mutation tool with no annotations, 3 parameters, 0% schema coverage, and no output schema), the description is incomplete. It lacks details on behavior, parameter usage, output format, and integration with sibling tools like 'affine_list_histories'. For a recovery operation, this leaves too many unknowns for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'timestamp' but doesn't explain its format or source (e.g., from 'affine_list_histories'). It doesn't cover 'guid' (document identifier) or 'workspaceId' (optional parameter). With 3 parameters and no schema descriptions, the description adds minimal value beyond implying timestamp relevance.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Recover') and resource ('a doc'), specifying it's to a previous timestamp. It distinguishes from siblings like 'get_doc' (read) and 'revoke_doc' (remove access), but doesn't explicitly contrast with potential alternatives like 'affine_list_histories' for viewing history. This makes it clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a timestamp from history), exclusions, or related tools like 'affine_list_histories' for finding timestamps. The description only states what it does, not when or why to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DAWNCR0W/affine-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server