Skip to main content
Glama
Qihoo360

360 AI Cloud Drive MCP Server

by Qihoo360

file-list

Retrieve detailed file and folder listings from 360 AI Cloud Drive with pagination support, including file names, sizes, and timestamps.

Instructions

获取云盘指定路径下的文件和文件夹列表,支持分页查询。返回文件名、大小、创建时间、修改时间等详细信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNo页码,默认从0开始。
page_sizeNo每页显示的条目数,默认50条。
pathNo要查询的云盘路径,默认为根目录'/'/

Implementation Reference

  • The registerGetFilesTool function registers the "file-list" MCP tool, defining its name, description, input schema, and inline execution handler that authenticates, fetches the file list from YunPan API, formats the results, and returns structured text content or error.
    export function registerGetFilesTool(server: McpServer) {
      server.tool(
        "file-list",
        "获取云盘指定路径下的文件和文件夹列表,支持分页查询。返回文件名、大小、创建时间、修改时间等详细信息。",
        {
          page: z.number().optional().default(0).describe("页码,默认从0开始。"),
          page_size: z.number().optional().default(50).describe("每页显示的条目数,默认50条。"),
          path: z.string().optional().default("/").describe("要查询的云盘路径,默认为根目录'/'"),
        },
        async ({ page, page_size, path }, mcpReq: any) => {
          const httpContext = gethttpContext(mcpReq, server);
          const transportAuthInfo = httpContext.authInfo;
    
          try {
            let authInfo: AuthInfo;
            const extraParams = {
              path: path || '/',
              page: page || 0,
              page_size: page_size || 100,
            }
            try {
              authInfo = await getAuthInfo({
                method: 'File.getList',
                extraParams: extraParams
              }, transportAuthInfo);
              
              authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
            } catch (authError) {
            
              return {
                content: [{
                  type: "text",
                  text: "获取鉴权信息失败,请提供有效的API_KEY"
                }],
                isError: true
              };
            }
            
            const apiResponse = await fetchFileList(authInfo, extraParams);
            
            if (apiResponse && apiResponse.errno === 0) {
              const files = (apiResponse.data && apiResponse.data.node_list) || [];
              
              if (files.length === 0) {
                return {
                  content: [{
                    type: "text",
                    text: "没有找到符合条件的文件"
                  }]
                };
              }
              
              const dirCount = files.filter((file: YunPanFile) => file.type === "1").length;
              const fileCount = files.length - dirCount;
              
              const filesText = [
                `云盘文件列表 (路径: ${path})`,
                `共 ${files.length} 项 (${dirCount} 个文件夹, ${fileCount} 个文件)`,
                "",
                ...files.map(formatFileInfo)
              ].join("\n");
              
              return {
                content: [
                  {
                    type: "text",
                    text: filesText
                  },
                  {
                    type: "text",
                    text: TOOL_LIMIT_NOTE
                  }
                ]
              };
            } else {
              return {
                content: [{
                  type: "text",
                  text: apiResponse?.errmsg || "API请求失败"
                }],
                isError: true
              };
            }
          } catch (error: any) {
            return {
              content: [
                {
                  type: "text",
                  text: `获取文件列表出错: ${error.message || "未知错误"}`,
                },
                {
                  type: "text",
                  text: TOOL_LIMIT_NOTE,
                }
              ],
              isError: true
            };
          }
        },
      );
    } 
  • Zod input schema defining optional parameters for the file-list tool: page (default 0), page_size (default 50), path (default '/').
    {
      page: z.number().optional().default(0).describe("页码,默认从0开始。"),
      page_size: z.number().optional().default(50).describe("每页显示的条目数,默认50条。"),
      path: z.string().optional().default("/").describe("要查询的云盘路径,默认为根目录'/'"),
    },
  • Handler function for the file-list tool: retrieves authentication, calls the YunPan File.getList API, processes the response, formats file information (name, size, times, nid), counts dirs/files, and returns formatted text content or error response.
    async ({ page, page_size, path }, mcpReq: any) => {
      const httpContext = gethttpContext(mcpReq, server);
      const transportAuthInfo = httpContext.authInfo;
    
      try {
        let authInfo: AuthInfo;
        const extraParams = {
          path: path || '/',
          page: page || 0,
          page_size: page_size || 100,
        }
        try {
          authInfo = await getAuthInfo({
            method: 'File.getList',
            extraParams: extraParams
          }, transportAuthInfo);
          
          authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
        } catch (authError) {
        
          return {
            content: [{
              type: "text",
              text: "获取鉴权信息失败,请提供有效的API_KEY"
            }],
            isError: true
          };
        }
        
        const apiResponse = await fetchFileList(authInfo, extraParams);
        
        if (apiResponse && apiResponse.errno === 0) {
          const files = (apiResponse.data && apiResponse.data.node_list) || [];
          
          if (files.length === 0) {
            return {
              content: [{
                type: "text",
                text: "没有找到符合条件的文件"
              }]
            };
          }
          
          const dirCount = files.filter((file: YunPanFile) => file.type === "1").length;
          const fileCount = files.length - dirCount;
          
          const filesText = [
            `云盘文件列表 (路径: ${path})`,
            `共 ${files.length} 项 (${dirCount} 个文件夹, ${fileCount} 个文件)`,
            "",
            ...files.map(formatFileInfo)
          ].join("\n");
          
          return {
            content: [
              {
                type: "text",
                text: filesText
              },
              {
                type: "text",
                text: TOOL_LIMIT_NOTE
              }
            ]
          };
        } else {
          return {
            content: [{
              type: "text",
              text: apiResponse?.errmsg || "API请求失败"
            }],
            isError: true
          };
        }
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `获取文件列表出错: ${error.message || "未知错误"}`,
            },
            {
              type: "text",
              text: TOOL_LIMIT_NOTE,
            }
          ],
          isError: true
        };
      }
    },
  • Top-level registration call to registerGetFilesTool within registerAllTools, including the file-list tool among others.
    registerGetFilesTool(server);
  • Helper function that performs the actual HTTP GET request to the YunPan API endpoint for File.getList, constructs URL params including method, auth tokens, qid, sign, and path/page params, parses JSON response.
    async function fetchFileList(authInfo: AuthInfo, extraParams: Record<string|number, string|number>): Promise<any> {
      try {
        const url = new URL(authInfo.request_url || '');
        
        // 构建请求头
        const headers = {
          'Access-Token': authInfo.access_token || ''
        };
    
        // 确保所有参数都是字符串
        const stringifiedParams: Record<string, string> = {};
        for (const [key, value] of Object.entries(extraParams)) {
          // 去除 access_token
          if (key !== 'access_token') {
            stringifiedParams[String(key)] = String(value);
          }
        }
    
        const baseParams: Record<string, string> = {
          'method': 'File.getList',
          'access_token': authInfo.access_token || '',
          'qid': authInfo.qid || '',
          'sign': authInfo.sign || '',
          ...stringifiedParams
        };
    
        // 确保所有参数被正确添加
        Object.entries(baseParams).forEach(([key, value]) => {
          url.searchParams.append(key, String(value));
        });
        
        const response = await fetch(url.toString(), {
          method: 'GET',
          headers: headers
        });
        
        if (!response.ok) {
          throw new Error(`API 请求失败,状态码: ${response.status}`);
        }
        
        // 先获取原始响应文本
        const responseText = await response.text();
        
        try {
          // 尝试解析为JSON
          const data = JSON.parse(responseText);
          return data;
        } catch (jsonError) {
          console.error("JSON解析错误:", jsonError);
          throw new Error(`无法解析API响应: ${responseText.substring(0, 100)}...`);
        }
      } catch (error) {
        console.error('获取文件列表失败:', error);
        throw error;
      }
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it's a read operation (获取列表), supports pagination (分页查询), and returns detailed metadata (文件名、大小、创建时间、修改时间等). However, it doesn't mention potential limitations like rate limits, authentication requirements, or error conditions. The description adds value but lacks comprehensive behavioral context for a tool with no annotations.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose and key features (pagination, return details). Every part earns its place: the first clause states the action, the second adds pagination support, and the third specifies return values. There is no wasted text or redundancy.

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

Completeness3/5

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

Given no annotations and no output schema, the description provides basic completeness for a read-only list tool. It covers the purpose, pagination behavior, and return details, but lacks information on error handling, authentication, or output structure. For a tool with 3 parameters and no structured output definition, this is adequate but leaves gaps in contextual understanding.

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

Parameters3/5

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

Schema description coverage is 100%, with all three parameters (page, page_size, path) well-documented in the schema. The description adds minimal semantic context by mentioning '指定路径' (specified path) and '分页查询' (pagination query), which aligns with the parameters but doesn't provide additional meaning beyond what the schema already covers. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the tool's purpose: '获取云盘指定路径下的文件和文件夹列表' (get file and folder list from cloud drive at specified path). It specifies the verb (获取/获取列表) and resource (云盘指定路径下的文件和文件夹), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like file-search, which might have overlapping functionality.

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

Usage Guidelines3/5

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

The description implies usage context through '指定路径' (specified path) and '分页查询' (pagination query), suggesting this is for browsing directory contents rather than searching. However, it doesn't explicitly state when to use this versus alternatives like file-search (which might search across directories) or provide any exclusion criteria. The guidance is implied but not explicit.

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/Qihoo360/ecs_mcp_server'

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