recent_docs
Retrieve a list of recently updated documents in a specified workspace using the GraphQL API. Manage document operations efficiently with input parameters like workspace ID and pagination options.
Instructions
List recently updated docs in a workspace.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| after | No | ||
| first | No | ||
| offset | No | ||
| workspaceId | No |
Implementation Reference
- src/tools/docs.ts:140-149 (handler)The main handler function for the 'recent_docs' tool. It performs a GraphQL query to list documents in the workspace (using the standard docs field as a proxy for recent docs).const recentDocsHandler = async (parsed: { workspaceId?: string; first?: number; offset?: number; after?: 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."); } // Note: AFFiNE doesn't have a separate 'recentlyUpdatedDocs' field, just use docs const query = `query RecentDocs($workspaceId:String!, $first:Int, $offset:Int, $after:String){ workspace(id:$workspaceId){ docs(pagination:{first:$first, offset:$offset, after:$after}){ totalCount pageInfo{ hasNextPage endCursor } edges{ cursor node{ id workspaceId title summary public defaultRole createdAt updatedAt } } } } }`; const data = await gql.request<{ workspace: any }>(query, { workspaceId, first: parsed.first, offset: parsed.offset, after: parsed.after }); return text(data.workspace.docs); };
- src/tools/docs.ts:150-162 (registration)Registration of the 'recent_docs' tool with the MCP server, including input schema and handler reference.server.registerTool( "recent_docs", { title: "Recent Documents", description: "List recently updated docs in a workspace.", inputSchema: { workspaceId: z.string().optional(), first: z.number().optional(), offset: z.number().optional(), after: z.string().optional() } }, recentDocsHandler as any