Skip to main content
Glama

Apply Document Updates

affine_apply_doc_updates

Apply CRDT updates to documents in AFFiNE workspaces, enabling advanced synchronization and modification of collaborative content via specified operations and updates.

Instructions

Apply CRDT updates to a doc (advanced).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docIdYes
opYes
updatesYes
workspaceIdNo

Implementation Reference

  • The async handler function that applies CRDT updates to a document via a GraphQL mutation.
    const applyDocUpdatesHandler = async (parsed: { workspaceId?: string; docId: string; op: string; updates: string }) => {
      const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId;
      if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)");
      const query = `query Apply($workspaceId:String!,$docId:String!,$op:String!,$updates:String!){ applyDocUpdates(workspaceId:$workspaceId, docId:$docId, op:$op, updates:$updates) }`;
      const data = await gql.request<{ applyDocUpdates: string }>(query, { workspaceId, docId: parsed.docId, op: parsed.op, updates: parsed.updates });
      return text(data.applyDocUpdates);
    };
  • Zod input schema defining the parameters: workspaceId (optional), docId, op, updates.
    inputSchema: {
      workspaceId: z.string().optional(),
      docId: z.string(),
      op: z.string(),
      updates: z.string()
    }
  • Registration of the 'affine_apply_doc_updates' tool with the MCP server, including title, description, schema, and handler.
    server.registerTool(
      "affine_apply_doc_updates",
      {
        title: "Apply Document Updates",
        description: "Apply CRDT updates to a doc (advanced).",
        inputSchema: {
          workspaceId: z.string().optional(),
          docId: z.string(),
          op: z.string(),
          updates: z.string()
        }
      },
      applyDocUpdatesHandler as any
    );
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions 'CRDT updates' which hints at conflict resolution in distributed systems, but doesn't disclose critical traits like whether this is a mutation (likely yes), permission requirements, side effects (e.g., versioning), or error handling. The '(advanced)' note suggests complexity but lacks specifics.

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

Conciseness4/5

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

The description is very concise—a single sentence with no wasted words. It's front-loaded with the core action ('Apply CRDT updates to a doc'), though the brevity leads to under-specification rather than efficient clarity. Every word earns its place, but more content would be beneficial.

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 implied by 'CRDT updates' and '(advanced)', no annotations, 0% schema coverage, and no output schema, the description is incomplete. It doesn't explain the tool's behavior, parameter usage, or expected outcomes, making it inadequate for safe and effective use by an AI agent in this context.

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 parameters (docId, op, updates, workspaceId) are undocumented in the schema. The description adds no meaning beyond the tool name—it doesn't explain what 'op' or 'updates' represent, their formats, or how they interact. This fails to compensate for the schema gap, leaving parameters largely ambiguous.

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

Purpose3/5

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

The description states the tool applies CRDT updates to a document, which gives a basic purpose (verb+resource). However, it's vague about what 'CRDT updates' entail and doesn't differentiate from siblings like 'update_comment' or 'update_settings' that also modify content. The '(advanced)' qualifier adds some context but doesn't make the purpose specific.

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 specific document state), exclusions, or how it differs from other update-related tools like 'update_comment' or 'update_settings'. The '(advanced)' hint implies specialized use but gives no concrete direction.

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