Skip to main content
Glama

docs_list_docs

Lists available documentation sources from the MCP documentation server for development frameworks, enabling access to crawled and local documents.

Input Schema

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

Implementation Reference

  • Handler function that lists all loaded document sources, including name, page count, sample pages, and other metadata. Ensures documents are loaded before responding.
    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 defining the optional 'limit' parameter for the maximum number of document sources to return.
    { limit: z.number().optional().default(50).describe("最大返回文档源数量") },
  • server.js:677-753 (registration)
    Registration of the 'docs_list_docs' tool using server.tool(), including name, schema, and handler reference.
    server.tool( "docs_list_docs", // 修改工具名称,添加命名空间前缀 { limit: z.number().optional().default(50).describe("最大返回文档源数量") }, 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) }] }; } } );

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