Skip to main content
Glama
Qihoo360

360 AI Cloud Drive MCP Server

by Qihoo360

make-dir

Create new folders in 360 AI Cloud Drive by specifying exact paths for organized file storage and management.

Instructions

在云盘中创建新文件夹,支持指定路径。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fnameYes要创建的文件夹完整路径,例如:/新文件夹/ 或 /文档/子文件夹/

Implementation Reference

  • Main execution logic for the 'make-dir' tool, including authentication, API call to create directory, and response handling.
    async ({ fname }, mcpReq: any) => {
      const httpContext = gethttpContext(mcpReq, server);
      
      // 使用transport中的authInfo
      const transportAuthInfo = httpContext.authInfo;
      try {
        let authInfo: AuthInfo;
        const extraParams = {
          fname: fname
        };
        
        try {
          // 传入方法名和路径等参数
          authInfo = await getAuthInfo({
            method: 'File.mkdir',
            extraParams: extraParams
          }, transportAuthInfo);
          
          authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
        } catch (authError) {
          console.error("自动获取鉴权信息失败:", authError);
          throw new Error("获取鉴权信息失败,请提供有效的API_KEY");
        }
        
        // 调用API创建文件夹
        const apiResponse = await createDirectory(authInfo, fname);
        
        // 检查API响应是否成功
        if (apiResponse && apiResponse.errno === 0) {
          const folderData = apiResponse.data || {};
          const folderId = folderData.nid || '';
          
          // 返回创建成功信息
          return {
            content: [
              {
                type: "text",
                text: `文件夹"${fname}"创建成功!\n文件夹ID: ${folderId}`,
              },
              {
                type: "text",
                text: TOOL_LIMIT_NOTE,
              },
            ],
          };
        } 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 for the 'make-dir' tool, defining the 'fname' parameter.
    {
      fname: z.string().describe("要创建的文件夹完整路径,例如:/新文件夹/ 或 /文档/子文件夹/"),
    },
  • Registers the 'make-dir' tool on the MCP server within the registerMakeDirTool function.
    server.tool(
      "make-dir",
      "在云盘中创建新文件夹,支持指定路径。",
      {
        fname: z.string().describe("要创建的文件夹完整路径,例如:/新文件夹/ 或 /文档/子文件夹/"),
      },
      async ({ fname }, mcpReq: any) => {
        const httpContext = gethttpContext(mcpReq, server);
        
        // 使用transport中的authInfo
        const transportAuthInfo = httpContext.authInfo;
        try {
          let authInfo: AuthInfo;
          const extraParams = {
            fname: fname
          };
          
          try {
            // 传入方法名和路径等参数
            authInfo = await getAuthInfo({
              method: 'File.mkdir',
              extraParams: extraParams
            }, transportAuthInfo);
            
            authInfo.request_url = getConfig(transportAuthInfo?.ecsEnv).request_url
          } catch (authError) {
            console.error("自动获取鉴权信息失败:", authError);
            throw new Error("获取鉴权信息失败,请提供有效的API_KEY");
          }
          
          // 调用API创建文件夹
          const apiResponse = await createDirectory(authInfo, fname);
          
          // 检查API响应是否成功
          if (apiResponse && apiResponse.errno === 0) {
            const folderData = apiResponse.data || {};
            const folderId = folderData.nid || '';
            
            // 返回创建成功信息
            return {
              content: [
                {
                  type: "text",
                  text: `文件夹"${fname}"创建成功!\n文件夹ID: ${folderId}`,
                },
                {
                  type: "text",
                  text: TOOL_LIMIT_NOTE,
                },
              ],
            };
          } 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 actual API request to the cloud disk service to create the directory.
    async function createDirectory(authInfo: AuthInfo, fname: 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'
        };
    
        // 构建请求参数
        const baseParams: Record<string, string> = {
          'method': 'File.mkdir',
          'access_token': authInfo.access_token || '',
          'qid': authInfo.qid || '',
          'sign': authInfo.sign || '',
          'fname': fname
        };
    
        // 构建表单数据
        const formData = new URLSearchParams();
        Object.entries(baseParams).forEach(([key, value]) => {
          formData.append(key, String(value));
        });
        
        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;
      }
    }
  • Invocation of make-dir tool registration as part of registering all tools.
    registerMakeDirTool(server);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While '创建新文件夹' implies a write operation, it doesn't address permissions needed, whether it overwrites existing folders, error conditions, or what happens on success/failure. The description adds minimal behavioral context beyond the basic action.

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

Conciseness4/5

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

The description is a single, efficient sentence that states the core function and key capability. It's appropriately brief and front-loaded with the main action. No wasted words, though it could be slightly more informative about behavioral aspects.

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?

For a write operation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the tool returns, error conditions, permissions required, or how it interacts with existing files/folders. Given the complexity of a folder creation operation, more context 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?

Schema description coverage is 100%, so the schema already documents the single parameter 'fname' with its type, description, and example. The description adds no additional parameter information beyond what's in the schema, meeting 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 action ('创建新文件夹' - create new folder) and resource ('在云盘中' - in cloud storage), making the purpose immediately understandable. It doesn't specifically distinguish from siblings like 'file-move' or 'file-rename', but the core function is unambiguous.

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. There's no mention of prerequisites, when not to use it, or how it differs from other file operations like 'file-save' or 'file-upload-stdio' in the sibling list.

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