Skip to main content
Glama

Get Document

get_doc

Retrieve a document by its ID using GraphQL metadata on the AFFiNE MCP Server. Input workspace ID and document ID to access specific workspace content.

Instructions

Get a document by ID (GraphQL metadata).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docIdYes
workspaceIdNo

Implementation Reference

  • The main handler function that executes the 'get_doc' tool logic: performs a GraphQL query to fetch document metadata by docId in a workspace.
    const getDocHandler = async (parsed: { workspaceId?: string; docId: string }) => {
        const workspaceId = parsed.workspaceId || defaults.workspaceId;
        if (!workspaceId) {
          throw new Error("workspaceId is required. Provide it as a parameter or set AFFINE_WORKSPACE_ID in environment.");
        }
        const query = `query GetDoc($workspaceId:String!, $docId:String!){ workspace(id:$workspaceId){ doc(docId:$docId){ id workspaceId title summary public defaultRole createdAt updatedAt } } }`;
        const data = await gql.request<{ workspace: any }>(query, { workspaceId, docId: parsed.docId });
        return text(data.workspace.doc);
      };
  • The registration of the 'get_doc' MCP tool on the McpServer, including input schema definition using Zod.
    server.registerTool(
      "get_doc",
      {
        title: "Get Document",
        description: "Get a document by ID (GraphQL metadata).",
        inputSchema: {
          workspaceId: z.string().optional(),
          docId: DocId
        }
      },
      getDocHandler as any
    );
  • Zod schema definition for the required 'docId' parameter used in the 'get_doc' tool's inputSchema.
    const DocId = z.string().min(1, "docId required");
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool retrieves metadata but doesn't disclose behavioral traits like whether it's read-only, requires authentication, has rate limits, or what happens if the ID is invalid. The description is minimal and misses key operational details.

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 extremely concise—a single sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word earns its place without redundancy.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on return values, error handling, authentication needs, and parameter usage. For a tool with 2 parameters and no structured support, it should provide more context to be fully helpful.

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 'by ID' which relates to 'docId', but doesn't explain the 'workspaceId' parameter or provide any additional meaning beyond the schema's basic types. With 2 parameters and no schema descriptions, this adds minimal value.

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 ('Get') and resource ('document by ID'), specifying it retrieves GraphQL metadata. It distinguishes from siblings like 'list_docs' (which lists multiple) and 'recent_docs' (which shows recent ones), though it doesn't explicitly name alternatives. The purpose is specific but could be more 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?

The description provides no guidance on when to use this tool versus alternatives like 'list_docs' or 'search_docs', nor does it mention prerequisites such as needing a valid document ID. It implies usage by stating 'by ID' but lacks explicit context or exclusions.

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