Skip to main content
Glama
Qihoo360

360 AI Cloud Drive MCP Server

by Qihoo360

file-share

Generate shareable links for files stored in 360 AI Cloud Drive. Create links for single files or multiple files at once to enable easy access and distribution.

Instructions

生成云盘文件的分享链接。支持批量生成多个文件的分享链接。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYes要分享的文件全路径,多个文件用竖线(|)隔开,例如:/文件1.txt|/文件夹2/文件2.txt

Implementation Reference

  • The main execution handler for the 'file-share' tool. It retrieves authentication info, calls the shareFiles helper to generate share links via API, processes the response, and returns formatted content with success details or error message.
      async ({ paths }, mcpReq: any) => {
        const httpContext = gethttpContext(mcpReq, server);
        
        // 使用transport中的authInfo
        const transportAuthInfo = httpContext.authInfo;
        try {
          let authInfo: AuthInfo;
          // 注意:paths不计算sign,所以这里不传入extraParams
          try {
            // 传入方法名,但不传入paths
            authInfo = await getAuthInfo({
              method: 'Share.preShare'
              // 不传入paths作为extraParams,因为它不参与sign计算
            }, transportAuthInfo);
            
            authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
          } catch (authError) {
            console.error("自动获取鉴权信息失败:", authError);
            throw new Error("获取鉴权信息失败,请提供有效的API_KEY");
          }
    
          // 调用API生成分享链接
          const apiResponse = await shareFiles(authInfo, paths);
    
          // 检查API响应是否成功
          if (apiResponse && apiResponse.errno === 0 && apiResponse.data && apiResponse.data.share) {
            const share = apiResponse.data.share;
            return {
              content: [
                {
                  type: "text",
                  text: `分享链接生成成功!\n链接: ${share.url}\n提取码: ${share.password || '无'}\n短链: ${share.shorturl}\n二维码: ${share.qrcode}`,
                },
                {
                  type: "text",
                  text: TOOL_LIMIT_NOTE,
                },
              ],
              shareInfo: share
            };
          } else {
            const errorMsg = apiResponse?.errmsg || "API请求失败";
            throw new Error(errorMsg);
          }
        } catch (error: any) {
          console.error("生成分享链接出错:", error);
          return {
            content: [
              {
                type: "text",
                text: `生成分享链接时发生错误: ${error.message}`,
              },
              {
                type: "text",
                text: TOOL_LIMIT_NOTE,
              },
            ],
          };
        }
      },
    );
  • Input schema using Zod validating the 'paths' parameter as a string describing file paths separated by '|'.
      paths: z.string().describe("要分享的文件全路径,多个文件用竖线(|)隔开,例如:/文件1.txt|/文件夹2/文件2.txt"),
    },
  • The registerFileShareTool function registers the 'file-share' tool on the MCP server, specifying name, description, input schema, and handler.
    export function registerFileShareTool(server: McpServer) {
      server.tool(
        "file-share",
        "生成云盘文件的分享链接。支持批量生成多个文件的分享链接。",
        {
          paths: z.string().describe("要分享的文件全路径,多个文件用竖线(|)隔开,例如:/文件1.txt|/文件夹2/文件2.txt"),
        },
        async ({ paths }, mcpReq: any) => {
          const httpContext = gethttpContext(mcpReq, server);
          
          // 使用transport中的authInfo
          const transportAuthInfo = httpContext.authInfo;
          try {
            let authInfo: AuthInfo;
            // 注意:paths不计算sign,所以这里不传入extraParams
            try {
              // 传入方法名,但不传入paths
              authInfo = await getAuthInfo({
                method: 'Share.preShare'
                // 不传入paths作为extraParams,因为它不参与sign计算
              }, transportAuthInfo);
              
              authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
            } catch (authError) {
              console.error("自动获取鉴权信息失败:", authError);
              throw new Error("获取鉴权信息失败,请提供有效的API_KEY");
            }
    
            // 调用API生成分享链接
            const apiResponse = await shareFiles(authInfo, paths);
    
            // 检查API响应是否成功
            if (apiResponse && apiResponse.errno === 0 && apiResponse.data && apiResponse.data.share) {
              const share = apiResponse.data.share;
              return {
                content: [
                  {
                    type: "text",
                    text: `分享链接生成成功!\n链接: ${share.url}\n提取码: ${share.password || '无'}\n短链: ${share.shorturl}\n二维码: ${share.qrcode}`,
                  },
                  {
                    type: "text",
                    text: TOOL_LIMIT_NOTE,
                  },
                ],
                shareInfo: share
              };
            } else {
              const errorMsg = apiResponse?.errmsg || "API请求失败";
              throw new Error(errorMsg);
            }
          } catch (error: any) {
            console.error("生成分享链接出错:", error);
            return {
              content: [
                {
                  type: "text",
                  text: `生成分享链接时发生错误: ${error.message}`,
                },
                {
                  type: "text",
                  text: TOOL_LIMIT_NOTE,
                },
              ],
            };
          }
        },
      );
    }
  • Helper function that performs the HTTP POST request to the cloud disk API to generate share links for the given file paths, handling form data, authentication headers, and response parsing.
    async function shareFiles(authInfo: AuthInfo, paths: string): Promise<any> {
      try {
        const url = new URL(authInfo.request_url || '');
    
        // 构建请求头
        const headers = {
          'Access-Token': authInfo.access_token || '',
          'Content-Type': 'application/x-www-form-urlencoded'
        };
    
        // 构建请求参数(注意:paths不计算sign,所以不包含在baseParams中)
        const baseParams: Record<string, string> = {
          'method': 'Share.preShare',
          'access_token': authInfo.access_token || '',
          'qid': authInfo.qid || '',
          'sign': authInfo.sign || ''
        };
    
        // 构建表单数据
        const formData = new URLSearchParams();
        Object.entries(baseParams).forEach(([key, value]) => {
          formData.append(key, String(value));
        });
        // 单独添加paths参数(不参与sign计算)
        formData.append('paths', paths);
    
        console.error("请求URL:", url.toString());
        console.error("请求参数:", Object.fromEntries(formData.entries()));
    
        const response = await fetch(url.toString(), {
          method: 'POST',
          headers: headers,
          body: formData
        });
    
        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;
      }
    }
  • Secondary registration: calls registerFileShareTool within registerAllTools to include 'file-share' tool when registering all tools.
    registerFileShareTool(server);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While it states the tool generates sharing links and supports batch processing, it doesn't describe important behavioral aspects: what permissions are required, whether links are public or private, expiration settings, rate limits, or what the output looks like. For a tool that creates shareable links (potentially sensitive operation), this is a significant gap.

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 perfectly concise - two sentences that directly state the tool's function and its batch capability. Every word earns its place with zero redundancy. The structure is front-loaded with the primary purpose followed by an important capability.

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

Completeness2/5

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

Given this is a file-sharing tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the sharing links look like, their properties (expiration, permissions), error conditions, or how results are returned for batch operations. For a tool that creates potentially sensitive sharing links, more context about the operation's behavior and output is needed.

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?

The schema description coverage is 100%, with the single parameter 'paths' fully documented in the schema. The description adds minimal value beyond the schema - it mentions batch processing ('支持批量生成多个文件的分享链接') which aligns with the schema's pipe-separated format, but doesn't provide additional semantic context about path formats, validation rules, or edge cases. Baseline 3 is appropriate when schema does the heavy lifting.

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: '生成云盘文件的分享链接' (generate sharing links for cloud drive files). It specifies the verb (generate) and resource (cloud drive file sharing links), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get-download-url' 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 Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It mentions batch processing capability ('支持批量生成多个文件的分享链接'), but doesn't clarify when to use this versus single-file sharing methods or how it differs from 'get-download-url'. No exclusions, prerequisites, or context for tool selection are provided.

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