Skip to main content
Glama

docs_list_docs

Retrieve a list of documentation sources from McpDocServer using MCP protocol, enabling efficient access and management of development framework resources. Customize results with a limit parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo最大返回文档源数量

Implementation Reference

  • The handler function for the 'docs_list_docs' tool. It lists all available document sources, including name, display name, URL, last updated time, page count, and sample pages from the first 5 pages. Returns JSON formatted content via MCP protocol.
    async ({ limit }) => { log(`收到文档列表请求: 限制=${limit}`); try { // 确保文档已加载 if (Object.keys(docData).length === 0) { log(`文档数据为空,尝试加载...`); const loadResult = await ensureDocsLoaded(); if (!loadResult || Object.keys(docData).length === 0) { return { content: [{ type: "text", text: JSON.stringify({ error: "文档数据不可用", message: "无法加载文档数据" }, null, 2) }] }; } } // 获取所有文档源的摘要信息 const docSources = Object.entries(docData) .map(([sourceName, data]) => { const pageCount = data.pages ? Object.keys(data.pages).length : 0; // 获取前5个页面作为示例 const samplePages = data.pages ? Object.entries(data.pages) .slice(0, 5) .map(([id, page]) => ({ id, title: page.title || id })) : []; return { name: sourceName, displayName: data.source?.name || sourceName, url: data.source?.url || "", lastUpdated: data.lastUpdated || "", pageCount: pageCount, samplePages: samplePages }; }) .sort((a, b) => a.name.localeCompare(b.name)) .slice(0, limit); // 返回文档源列表 return { content: [{ type: "text", text: JSON.stringify({ success: true, count: docSources.length, sources: docSources }, null, 2) }] }; } catch (error) { log(`获取文档列表时发生错误: ${error.message}`); return { content: [{ type: "text", text: JSON.stringify({ error: "获取文档列表时发生错误", details: error.message }, null, 2) }] }; } }
  • Input schema for the 'docs_list_docs' tool using Zod. Defines an optional 'limit' parameter (default 50) for the maximum number of document sources to return.
    { limit: z.number().optional().default(50).describe("最大返回文档源数量") },
  • server.js:677-678 (registration)
    Registration of the 'docs_list_docs' tool on the MCP server using server.tool(name, schema, handler).
    server.tool( "docs_list_docs", // 修改工具名称,添加命名空间前缀

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/ruan11223344/McpDocServer'

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