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
| Name | Required | Description | Default |
|---|---|---|---|
| docId | Yes | ||
| workspaceId | No |
Implementation Reference
- src/tools/docs.ts:64-72 (handler)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); };
- src/tools/docs.ts:73-84 (registration)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 );
- src/tools/docs.ts:9-9 (schema)Zod schema definition for the required 'docId' parameter used in the 'get_doc' tool's inputSchema.const DocId = z.string().min(1, "docId required");