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)
            }]
          };
        }
      }
    );
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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