Skip to main content
Glama

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");

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