Skip to main content
Glama

get_user_docs

Retrieve a complete list of your Yuque knowledge base documents, including both private and collaborative workspaces, to manage and access your content efficiently.

Instructions

获取当前用户的所有知识库文档列表,包括私人和协作文档

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accessTokenNo用于认证 API 请求的令牌

Implementation Reference

  • The MCP tool handler function for 'get_user_docs'. It creates a YuqueService instance and calls getUserDocs() to fetch the user's documents, then returns them as a JSON string in the MCP content format. Handles errors appropriately.
    async ({ accessToken }) => { try { Logger.log("Fetching user's documents"); const yuqueService = this.createYuqueService(accessToken); const docs = await yuqueService.getUserDocs(); Logger.log(`Successfully fetched ${docs.length} documents`); return { content: [{ type: "text", text: JSON.stringify(docs) }], }; } catch (error) { Logger.error("Error fetching user docs:", error); return { content: [ { type: "text", text: `Error fetching user docs: ${error}` }, ], }; } } );
  • Input schema for the get_user_docs tool, defined using Zod. The only parameter is an optional accessToken for authentication.
    { accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), },
  • src/server.ts:162-187 (registration)
    Registration of the 'get_user_docs' tool on the McpServer using server.tool(name, description, inputSchema, handler). This is where the tool is made available in the MCP protocol.
    this.server.tool( "get_user_docs", "获取当前用户的所有知识库文档列表,包括私人和协作文档", { accessToken: z.string().optional().describe("用于认证 API 请求的令牌"), }, async ({ accessToken }) => { try { Logger.log("Fetching user's documents"); const yuqueService = this.createYuqueService(accessToken); const docs = await yuqueService.getUserDocs(); Logger.log(`Successfully fetched ${docs.length} documents`); return { content: [{ type: "text", text: JSON.stringify(docs) }], }; } catch (error) { Logger.error("Error fetching user docs:", error); return { content: [ { type: "text", text: `Error fetching user docs: ${error}` }, ], }; } } );
  • Helper method in YuqueService that performs the actual API call to Yuque's /user/docs endpoint to retrieve the list of user documents.
    async getUserDocs(): Promise<YuqueDoc[]> { const response = await this.client.get('/user/docs'); return response.data.data; }
  • TypeScript interface definition for YuqueDoc, which defines the structure of documents returned by getUserDocs.
    export interface YuqueDoc { id: number; slug: string; title: string; description: string; user_id: number; book_id: number; format: string; public: number; status: number; likes_count: number; read_count?: number; comments_count: number; content_updated_at: string; created_at: string; updated_at: string; published_at?: string; first_published_at?: string; word_count: number; body?: string; body_html?: string; body_lake?: string; body_draft?: string; book?: YuqueRepo; user?: YuqueUser; last_editor?: YuqueUser; creator?: YuqueUser; }

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/HenryHaoson/Yuque-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server